-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
91 lines (71 loc) · 2.29 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
86
87
88
89
90
91
define AYI_HELP_MSG
Make commands for ayi
help show help
Dev:
install install ./cmd/ayi to $$GOPATH/bin/ayi
fmt gofmt
test unit test
generate generate code using gommon
Dev first time:
dep-install install dependencies based on lock file
dep-update update dependency based on Gopkg.toml and code
Build:
build build binary of all platforms and package to zip
clean remove generated binary and zip files
endef
export AYI_HELP_MSG
.PHONY: help
help:
@echo "$$AYI_HELP_MSG"
VERSION = 0.2.2
BUILD_COMMIT = $(shell git rev-parse HEAD)
BUILD_TIME = $(shell date +%Y-%m-%dT%H:%M:%S%z)
CURRENT_USER = $(USER)
FLAGS = -X main.version=$(VERSION) -X main.commit=$(BUILD_COMMIT) -X main.buildTime=$(BUILD_TIME) -X main.buildUser=$(CURRENT_USER)
GO = CGO_ENABLED=0 go
GO_LINUX_BUILD = GOOS=linux GOARCH=amd64
GO_MAC_BUILD = GOOS=darwin GOARCH=amd64
GO_WINDOWS_BUILD = GOOS=windows GOARCH=amd64
.PHONY: fmt
fmt:
goimports -d -l -w ./cmd ./app ./config ./util
.PHONY: test
test:
go test -v -cover ./app/... ./config ./util/...
.PHONY: install
install:
go install -ldflags "$(FLAGS)" ./cmd/ayi
.PHONY: dep-install
dep-install:
dep ensure -v
.PHONY: dep-update
dep-update:
dep ensure -update -v
.PHONY: generate
generate:
gommon generate -v
# TODO: should have a build folder instead of putting everything under project root
.PHONY: build clean build-linux build-mac build-windows
build: build-linux build-mac build-windows
build-linux:
rm -f ayi-v$(VERSION)-linux-amd64.zip
$(GO_LINUX_BUILD) go build -ldflags "$(FLAGS)" -o ayi-v$(VERSION)-linux-amd64 ./cmd/ayi
zip ayi-v$(VERSION)-linux-amd64.zip ayi-v$(VERSION)-linux-amd64
rm ayi-v$(VERSION)-linux-amd64
build-mac:
rm -f ayi-v$(VERSION)-darwin-amd64.zip
$(GO_MAC_BUILD) go build -ldflags "$(FLAGS)" -o ayi-v$(VERSION)-darwin-amd64 ./cmd/ayi
zip ayi-v$(VERSION)-darwin-amd64.zip ayi-v$(VERSION)-darwin-amd64
rm ayi-v$(VERSION)-darwin-amd64
build-windows:
rm -f ayi-v$(VERSION)-windows-amd64.zip
$(GO_WINDOWS_BUILD) go build -ldflags "$(FLAGS)" -o ayi-v$(VERSION)-windows-amd64 ./cmd/ayi
zip ayi-v$(VERSION)-windows-amd64.zip ayi-v$(VERSION)-windows-amd64
rm ayi-v$(VERSION)-windows-amd64
clean:
rm -f ayi-*
.PHONY: loc
# https://github.com/Aaronepower/tokei respect ignore file
# exclude playground
loc:
tokei .