-
Notifications
You must be signed in to change notification settings - Fork 37
/
Makefile
34 lines (23 loc) · 973 Bytes
/
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
name ?= nebula-console
# Set the default GOPROXY
GOPROXY ?= https://proxy.golang.org,direct
# build with version info
buildDate = $(shell TZ=UTC date +%FT%T%z)
gitCommit = ${GITHUB_SHA::7}
gitCommit ?= $(shell git log --pretty=format:'%h' -1)
ldflags="-w -X main.gitTag=${gitTag} -X main.buildDate=${buildDate} -X main.gitCommit=${gitCommit}"
.PHONY: build vendorbuild clean fmt gen
default: build
build: clean fmt
@GOPROXY=$(GOPROXY) CGO_ENABLED=0 go build -o ${name} -ldflags ${ldflags}
vendorbuild: clean fmt
@GOPROXY=$(GOPROXY) CGO_ENABLED=0 go mod vendor && go build -mod vendor -o ${name} --tags netgo -ldflags ${ldflags}
clean:
@rm -rf ${name} vendor
clean-all:
@rm -rf ${name} vendor box/blob.go
fmt:
@GOPROXY=$(GOPROXY) go mod tidy && find . -path vendor -prune -o -type f -iname '*.go' -exec go fmt {} \;
# generate box/blob.go (NOTE: `go generate` command may not support cross-platform)
gen:
@GOPROXY=$(GOPROXY) CGO_ENABLED=0 go generate ./...