-
Notifications
You must be signed in to change notification settings - Fork 27
/
Makefile
113 lines (93 loc) · 2.42 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
VERSION=0.4.0
GOVERSION=$(shell go version)
USER=$(shell id -u -n)
TIME=$(shell date)
JR_HOME=jr
ifndef XDG_DATA_DIRS
ifeq ($(OS), Windows_NT)
detectedOS := Windows
else
detectedOS := $(shell sh -c 'uname 2>/dev/null || echo Unknown')
endif
ifeq ($(detectedOS), Darwin)
JR_SYSTEM_DIR="$(HOME)/Library/Application Support"
endif
ifeq ($(detectedOS), Linux)
JR_SYSTEM_DIR="$(HOME)/.config"
endif
ifeq ($(detectedOS), Windows_NT)
JR_SYSTEM_DIR="$(LOCALAPPDATA)"
endif
else
JR_SYSTEM_DIR=$(XDG_DATA_DIRS)
endif
ifndef XDG_DATA_HOME
ifeq ($(OS), Windows_NT)
detectedOS := Windows
else
detectedOS := $(shell sh -c 'uname 2>/dev/null || echo Unknown')
endif
ifeq ($(detectedOS), Darwin)
JR_USER_DIR="$(HOME)/.local/share"
endif
ifeq ($(detectedOS), Linux)
JR_USER_DIR="$(HOME)/.local/share"
endif
ifeq ($(detectedOS), Windows_NT)
JR_USER_DIR="$(LOCALAPPDATA)" //@TODO
endif
else
JR_USER_DIR=$(XDG_DATA_HOME)
endif
hello:
@echo "JR,the JSON Random Generator"
@echo " Version: $(VERSION)"
@echo " Go Version: $(GOVERSION)"
@echo " Build User: $(USER)"
@echo " Build Time: $(TIME)"
@echo " Detected OS: $(detectedOS)"
@echo " JR System Dir: $(JR_SYSTEM_DIR)"
@echo " JR User Dir: $(JR_USER_DIR)"
install-gogen:
go install github.com/actgardner/gogen-avro/v10/cmd/...@latest
#go install github.com/hamba/avro/v2/cmd/avrogen@latest
generate:
go generate pkg/generator/generate.go
compile:
@echo "Compiling"
go build -v -ldflags="-s -w -X 'github.com/jrnd-io/jr/pkg/cmd.Version=$(VERSION)' \
-X 'github.com/jrnd-io/jr/pkg/cmd.GoVersion=$(GOVERSION)' \
-X 'github.com/jrnd-io/jr/pkg/cmd.BuildUser=$(USER)' \
-X 'github.com/jrnd-io/jr/pkg/cmd.BuildTime=$(TIME)'" \
-o build/jr jr.go
run: compile
./build/jr
clean:
go clean
rm build/*
test:
go test ./...
test_coverage:
go test ./... -coverprofile=coverage.out
dep:
go mod download
vet:
go vet
lint:
golangci-lint run --config .localci/lint/golangci.yml --out-format tab
help: hello
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}all${RESET}'
@echo ''
copy_templates:
mkdir -p $(JR_SYSTEM_DIR)/$(JR_HOME)/kafka && \
cp -r templates $(JR_SYSTEM_DIR)/$(JR_HOME) && \
cp -r pkg/producers/kafka/*.properties.example $(JR_SYSTEM_DIR)/$(JR_HOME)/kafka/
copy_config:
mkdir -p $(JR_SYSTEM_DIR)/$(JR_HOME) && \
cp config/* $(JR_SYSTEM_DIR)/$(JR_HOME)/
install:
install build/jr /usr/local/bin
all: hello install-gogen generate compile
all_offline: hello generate compile