-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
75 lines (57 loc) · 1.33 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
BINARY=diglet
VERSION=`git describe --always --tags`
BUILD_TIME=`date +%FT%T%z`
#LDFLAGS=-ldflags "-X main.Version=${VERSION}"
LDFLAGS=-ldflags "-extldflags '-static' -X main.Version=${VERSION}"
PACKAGES=`go list ./... | grep -v /vendor/`
#TODO make sure this export works correctly
export GO15VENDOREXPERIMENT := 1
.PHONY: build doc fmt lint run test clean get vet vendor vendor_clean vendor_list version list
# Default will usually be build
default: test
# Use this to ignore the vendor folder
list:
@echo $(PACKAGES)
build:
mkdir -p ./dist
go generate
go build -v ${LDFLAGS} -o ./dist/$(BINARY)
chmod +x ./dist/$(BINARY)
doc:
godoc -http=:6060 -index
fmt:
go fmt $(PACKAGES)
# https://github.com/golang/lint
# go get github.com/golang/lint/golint
lint:
golint $(PACKAGES)
get:
go get -v ./...
vet:
go vet $(PACKAGES)
run:
# not sure if this works
$(build)
./dist/$(BINARY)
test:
go generate
go test -v $(PACKAGES)
clean:
rm -rf ./dist
rm -rf ./resources
# get and vendor update
# go get -u github.com/kardianos/govendor
vendor:
govendor init
govendor add +external
govendor update +external
vendor_clean:
rm -dRf ./vendor/*
vendor_list:
go list ./... | grep /vendor/
version:
@echo ${VERSION}
xcompile:
go get -u github.com/mitchellh/gox
mkdir -p ./dist
gox ${LDFLAGS} -output "./dist/$(BINARY)_{{.OS}}_{{.Arch}}"