-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
50 lines (41 loc) · 1.48 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
SHELL = bash
TOOLING ?= golang.org/x/tools/cmd/goimports github.com/kardianos/govendor github.com/pquerna/ffjson
FORMAT_FILES ?= $(find . -name '*.go' -a -not -regex '.+/vendor/.+')
.ONESHELL:
default: maxmind
maxmind:
@govendor build -i -o bin/maxmind
# vet runs the Go source code static analysis tool `vet` to find
# any common errors.
vet:
@go list -f '{{.Dir}}' ./... | grep -v /vendor/
| grep -v '.*github.com/rabbitt/maxmind$$'
| xargs govendor tool vet -all
# prep runs `go generate` to build the dynamically generated
# source files.
prep: format-check
@echo "==> Rebuilding ffjson stubs..."
@govendor generate $$(go list ./... | grep -v /vendor/)
# bootstrap the build by downloading additional tools
bootstrap:
@for tool in $(TOOLING) ; do
echo "==> Installing/Updating $$tool"
go get -u $$tool
done
echo "==> Syncing vendor directory..."
govendor sync
format:
@echo "==> formating code according to gofmt requirements..."
gofmt -w $$(find . -name '*.go' -a -not -regex '.+/vendor/.+')
format-check:
@echo "==> Checking that code complies with gofmt requirements..."
declare -a files
files=( $$(gofmt -l $$(find . -name '*.go' -a -not -regex '.+/vendor/.+' | tr ' ' '\n')) )
if [[ $${#files[@]} -ge 1 ]]; then
echo "Found $${#files[@]} files that need reformatting:"
for ((i = 0; i < $${#files[@]}; i++)); do
echo -e "\t$${files[$$i]}"
done
echo "You can reformat all of them using: make format"
fi
.PHONY: bin default prep test vet bootstrap format format-check