-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
41 lines (38 loc) · 1.47 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
SHELL := /bin/bash
# build with version infos
versionDir = "bj-pfd2/pkg/v"
target = "app"
gitTag = $(shell if [ "`git describe --tags --abbrev=0 2>/dev/null`" != "" ];then git describe --tags --abbrev=0; else git log --pretty=format:'%h' -n 1; fi)
buildDate = $(shell TZ=Asia/Shanghai date +%FT%T%z)
gitCommit = $(shell git log --pretty=format:'%H' -n 1)
gitTreeState = $(shell if git status|grep -q -E 'clean|干净';then echo clean; else echo dirty; fi)
ldflags=" -extldflags '-static' -s -w -X ${versionDir}.gitTag=${gitTag} -X ${versionDir}.buildDate=${buildDate} -X ${versionDir}.gitCommit=${gitCommit} -X ${versionDir}.gitTreeState=${gitTreeState}"
# -tags netgo 解决 exec user process caused: no such file or directory
all: build
.PHONY: build
build: test
go build -a -v -tags netgo -ldflags ${ldflags} -o ${target} .
.PHONY: clean
clean:
rm -f ${target}
find . -name "[._]*.s[a-w][a-z]" | xargs -i rm -f {}
.PHONY: build
test:
gofmt -w .
go vet . | grep -v vendor;true
.PHONY: ca
ca:
openssl req -new -nodes -x509 -out conf/server.crt -keyout conf/server.key -days 3650 -subj "/C=DE/ST=NRW/L=Earth/O=Random Company/OU=IT/CN=127.0.0.1/[email protected]"
.PHONY: run
run:
if [ -e ./config.yaml ] ; then cp config.yaml ./tmp/; fi
air
.PHONY: test
test:
go test -v ./...
.PHONY: help
help:
@echo "make - compile the source code"
@echo "make clean - remove binary file and vim swp files"
@echo "make gotool - run go tool 'fmt' and 'vet'"
@echo "make ca - generate ca files"