-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
41 lines (27 loc) · 934 Bytes
/
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
MODULE := $(shell head -1 go.mod | cut -d ' ' -f2)
GOIMPORTS := $(shell go env GOPATH)/bin/goimports
OGEN := $(shell go env GOPATH)/bin/ogen
$(GOIMPORTS):
go install golang.org/x/tools/cmd/goimports@latest
$(OGEN):
go install github.com/ogen-go/ogen/cmd/[email protected]
fmt: $(GOIMPORTS)
$(GOIMPORTS) -local $(MODULE) -l -w $(shell find . -type f -name '*.go' -not -path "./vendor/*")
gen: $(OGEN)
go generate ./...
test: gen
go test -v ./...
bin/%: gen $(wildcard ./internal/**/*) $(wildcard ./cmd$@/**/*)
go build -o $@ -v ./$(subst bin,cmd,$@)
bin: $(subst ./cmd,bin,$(wildcard ./cmd/*))
%/schema.json: bin/hoarder
mkdir -p $(dir $@) && ./$^ --dump.schema > $@
%/defaults.json: bin/hoarder
mkdir -p $(dir $@) && ./$^ --dump.values > $@
config: config/schema.json config/defaults.json
install: bin
cp bin/* /usr/local/bin/
uninstall:
rm -f $(subst ./cmd,/usr/local/bin,$(wildcard ./cmd/*))
clean:
rm -rf bin/*