-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
31 lines (25 loc) · 902 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
GIT_COMMIT = $(shell git rev-parse --short HEAD)
GIT_STATUS = $(shell test -n "`git status --porcelain`" && echo "+CHANGES")
.PHONY: build binary
build: docker
docker run --rm dlgrab cat /dlgrab/bin/dlgrab > dlgrab
chmod +x dlgrab
docker:
docker build --force-rm -t dlgrab .
CHECKDIFF = [ $$(cat diff | wc -l) -gt 0 ]
check:
gofmt -d -e -s . >diff 2>&1 || true
$(CHECKDIFF) && echo "go fmt failed" && cat diff && exit 1 || true
go tool vet -all -printf=false . >diff 2>&1 || true
$(CHECKDIFF) && echo "go vet failed" && cat diff && exit 1 || true
go tool fix -force -diff . >diff 2>&1 || true
$(CHECKDIFF) && echo "go fix failed" && cat diff && exit 1 || true
rm diff
binary:
# static build - https://github.com/golang/go/issues/9344
go build \
-a \
-tags netgo \
-installsuffix cgo \
-ldflags "-X main.GITCOMMIT $(GIT_COMMIT)$(GIT_STATUS)" \
-o ./bin/dlgrab