-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathMakefile
67 lines (51 loc) · 2 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
SHELL := /bin/bash
BASEDIR = $(shell pwd)
# build with verison infos
versionDir = "ffly-plus/internal/version"
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 'clean';then echo clean; else echo dirty; fi)
ldflags="-w -X ${versionDir}.gitTag=${gitTag} -X ${versionDir}.buildDate=${buildDate} -X ${versionDir}.gitCommit=${gitCommit} -X ${versionDir}.gitTreeState=${gitTreeState}"
PROJECT_NAME := "ffly-plus"
PKG := "$(PROJECT_NAME)"
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/)
GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/ | grep -v _test.go)
.PHONY: all
all: build
.PHONY: build
build: ## Build the binary file
@protoc -I ./internal internal/proto/*.proto --go_out=plugins=grpc:./internal
@swag init
@go build -v -ldflags ${ldflags} .
@gofmt -w .
.PHONY: clean
clean:
rm -f ffly-plus
rm cover.out coverage.txt
find . -name "[._]*.s[a-w][a-z]" | xargs -i rm -f {}
.PHONY: test
test: ## view test result
@go test -short -coverprofile cover.out -covermode=atomic ${PKG_LIST}
@cat cover.out > coverage.txt
@go tool cover -html=coverage.txt
.PHONY: docs
docs:
@swag init
@echo "gen-docs done"
@echo "see docs by: http://localhost:8080/swagger/index.html"
.PHONY: ca
ca:
openssl req -new -nodes -x509 -out config/server.crt -keyout config/server.key -days 3650 -subj "/C=DE/ST=NRW/L=Earth/O=Random Company/OU=IT/CN=127.0.0.1/[email protected]"
.PHONY: proto
proto:
protoc -I ./internal internal/proto/*.proto --go_out=plugins=grpc:./internal
.PHONY: help
help:
@echo "make - compile the source code"
@echo "make clean - remove binary file and vim swp files"
@echo "make ca - generate ca files"
@echo "make docs - gen swag doc"
@echo "make test - go test"
@echo "make build - go build"
@echo "make proto - build proto"