-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
133 lines (96 loc) · 3.26 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
NAME := lsec2
PROF_DIR := ./.profile
PKG_AWS_SDK_GO := github.com/aws/aws-sdk-go
PKG_URFAVE_CLI := github.com/urfave/cli
MOD_QUERY_AWS_SDK_GO := <v1.30
MOD_QUERY_URFAVE_CLI := <v1.23
# Note: NOT use lazy initializer because make is unstable.
#SRCS = $(eval SRCS := $(shell find . -type f -name '*.go' | \grep -v 'vendor'))$(SRCS)
#PACKAGES = $(eval PACKAGES := $(shell ./scripts/_packages.sh))$(PACKAGES)
#GOVERSION = $(eval GOVERSION := $(shell go version | awk '{print $$3;}'))$(GOVERSION)
SRCS = $(shell find . -type f -name '*.go' | \grep -v 'vendor')
PACKAGES = $(shell ./scripts/_packages.sh)
GOVERSION = $(shell go version | awk '{print $$3;}')
.DEFAULT_GOAL := bin/$(NAME)
.PHONY: version
version:
@echo $(shell ./scripts/_version.sh)
bin/$(NAME): $(SRCS)
@./scripts/build.sh bin/$(NAME)
.PHONY: rm
rm:
@rm bin/$(NAME)
.PHONY: rebuild
rebuild: rm bin/$(NAME)
.PHONY: install
install:
@./scripts/install.sh
.PHONY: test
test:
@go test -race -cover -v $(PACKAGES)
.PHONY: prof
prof:
@[ ! -d $(PROF_DIR) ] && mkdir $(PROF_DIR); go test -bench . -benchmem -cover -coverprofile $(PROF_DIR)/cover.out $(PACKAGES)
func_prof_full = [ ! -d $(PROF_DIR) ] && mkdir $(PROF_DIR); go test -bench . -benchmem -blockprofile $(PROF_DIR)/block.out -cover -coverprofile $(PROF_DIR)/cover.out -cpuprofile $(PROF_DIR)/cpu.out -memprofile $(PROF_DIR)/mem.out ./$1
prof-full-awsec2:
@$(call func_prof_full,awsec2)
prof-full-printer:
@$(call func_prof_full,printer)
prof-full-cmd-cli:
@$(call func_prof_full,cmd/lsec2/cli)
.PHONY: vet
vet:
@go vet $(PACKAGES)
.PHONY: lint
lint:
@golint -set_exit_status $(PACKAGES)
.PHONY: validate
validate: vet lint
chk_latest = go list -u -m $1
chk-latest-all:
@$(call chk_latest,all)
chk-latest-aws-sdk-go:
@$(call chk_latest,$(PKG_AWS_SDK_GO))
chk-latest-urfave-cli:
@$(call chk_latest,$(PKG_URFAVE_CLI))
chk_versions = go list -u -m -versions $1 | tr ' ' '\n'
chk-versions-aws-sdk-go:
@$(call chk_versions,$(PKG_AWS_SDK_GO))
chk-versions-urfave-cli:
@$(call chk_versions,$(PKG_URFAVE_CLI))
update-pkg = echo query="$2"; GO111MODULE=on go get $1@'$2'
update-pkg-manualy = read -p 'Input Module Query(e.g. "<v1.20")?: ' query; echo query=$$query; GO111MODULE=on go get $1@''$$query''
#@read -p 'Input Module Query(e.g. "<v1.20")?: ' query; echo query=$$query; GO111MODULE=on go get $(PKG_AWS_SDK_GO)@''$$query''
update-aws-sdk-go:
@$(call update-pkg,$(PKG_AWS_SDK_GO),$(MOD_QUERY_AWS_SDK_GO))
update-urfave-cli:
@$(call update-pkg,$(PKG_URFAVE_CLI),$(MOD_QUERY_URFAVE_CLI))
mod-dl:
@GO111MODULE=on go mod download
mod-tidy:
@GO111MODULE=on go mod tidy
mod-golint-install: mod-tidy
@GO111MODULE=on go install golang.org/x/lint/golint
ci-test:
@./scripts/ci-test.sh
.PHONY: ci
ci: ci-test vet
.PHONY: vendor
vendor:
@GO111MODULE=on go mod vendor
vendor-build:
@./scripts/build.sh bin/$(NAME) "-mod vendor"
# Note: require "brew install rpmbuild" on OS X
test-goreleaser:
@GOVERSION=$(GOVERSION) goreleaser release --snapshot --skip-publish --rm-dist
ci-goreleaser:
@export GOVERSION=$(GOVERSION) && curl -sL http://git.io/goreleaser | bash -s -- release --snapshot --skip-publish --rm-dist
.PHONY: clean
clean:
@go clean $(PACKAGES)
@rm -f bin/$(NAME)
@rm -fr dist pkg
@find . -name '*.test' -delete
@rm -fr $(PROF_DIR)
mod-clean:
@go clean -modcache