-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
85 lines (66 loc) · 2.23 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
76
77
78
79
80
81
82
83
84
85
# Borrowed from:
# https://github.com/silven/go-example/blob/master/Makefile
# https://vic.demuzere.be/articles/golang-makefile-crosscompile/
BINARY = blanket
VET_REPORT = vet.report
TEST_REPORT = tests.xml
GOARCH = amd64
COMMIT=$(shell git rev-parse HEAD)
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
# Symlink into GOPATH
GITHUB_USERNAME=turtlemonvh
# Setup the -ldflags option for go build here, interpolate the variable values
LDFLAGS = -ldflags "-X main.COMMIT=${COMMIT} -X main.BRANCH=${BRANCH}"
# Build the project
all: clean test-xunit vet linux darwin windows
setup-dep:
# OSX
# https://golang.github.io/dep/docs/installation.html
brew install dep
# Setup for bindata
setup-bindata:
go get github.com/jteeuwen/go-bindata/...
go get github.com/elazarl/go-bindata-assetfs/...
setup-ui-dev:
cd ui; \
npm install; \
npm install -g bower gulp; \
npm install --save-dev jshint gulp-jshint; \
bower install
update-bindata:
# WARNING: We get an `unknown provider` warning when trying to use this version
# FIX: https://stackoverflow.com/questions/20340644/angular-unknown-provider-error-after-minification-with-grunt-build-in-yeoman-a
# Exit early to force using `dev` instead until this is fixed
exit 1
cd ui && gulp build
cd ui && go-bindata-assetfs -pkg=server public/...
mv ui/bindata.go server/
update-bindata-dev:
# Change 'dev' to 'public' for un-minified code
cd ui && gulp build-dev
cd ui && go-bindata-assetfs -pkg=server dev/...
mv ui/bindata.go server/
linux:
GOOS=linux GOARCH=${GOARCH} go build ${LDFLAGS} -o ${BINARY}-linux-${GOARCH} .
darwin:
GOOS=darwin GOARCH=${GOARCH} go build ${LDFLAGS} -o ${BINARY}-darwin-${GOARCH} .
windows:
GOOS=windows GOARCH=${GOARCH} go build ${LDFLAGS} -o ${BINARY}-windows-${GOARCH}.exe .
test:
# To test just a module:
# go test ./tasks
go test -v ./...
test-xunit:
# To test just a module:
# go test ./tasks
if ! hash go2xunit 2>/dev/null; then go install github.com/tebeka/go2xunit; fi
go test -v ./... 2>&1 | go2xunit -output ${TEST_REPORT}
vet:
go vet ./... > ${VET_REPORT} 2>&1
fmt:
go fmt $$(go list ./... | grep -v /vendor/)
clean:
-rm -f ${TEST_REPORT}
-rm -f ${VET_REPORT}
-rm -f ${BINARY}-*
.PHONY: linux darwin windows test test-xunit vet fmt clean update-bindata