-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
49 lines (35 loc) · 824 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
42
43
44
45
46
47
48
# go source files, ignore vendor directory
PATTERNS = $(shell find cmd -mindepth 1 -maxdepth 1 -type d -printf '%f\n')
SRC = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
GO := go
GOFMT := gofmt
GO_GCFLAGS =
GO_BUILD_FLAGS=
GO_LDFLAGS = -ldflags "-s -w"
BINARIES = $(addprefix target/,$(PATTERNS))
FORCE:
define BUILD_BINARY
@echo "Build $@"
$(GO) build ${GO_GCFLAGS} ${GO_BUILD_FLAGS} -o $@ ${GO_LDFLAGS} ./$<
endef
target/%: cmd/% FORCE
$(call BUILD_BINARY)
.PHONY: precommit
precommit: clean format lint compile
.PHONY: commit
commit: clean compile
ls -lha target/
.PHONY: clean
clean:
rm -rf target
target:
mkdir target
.PHONY: compile
compile: target $(BINARIES) ## build binaries
@echo "Build $@"
.PHONY: format
format:
@$(GOFMT) -l -w $(SRC)
.PHONY: lint
lint:
golangci-lint run