-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
139 lines (109 loc) · 4.4 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
134
135
136
137
138
139
# Nebulant bridge Makefile.
# github.com/develatio/nebulant-bridge
VERSION = 0
PATCHLEVEL = 5
SUBLEVEL = 1
EXTRAVERSION = -beta
# EXTRAVERSION := -beta-git-$(shell git log -1 --format=%h)
NAME =
######
BRIDGEVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
DATE = $(shell git log -1 --date=format:'%Y%m%d' --format=%cd)
COMMIT = $(shell git log -1 --format=%h)
GOVERSION = $(shell go env GOVERSION)
PRERELEASE = true
ifeq ($(shell expr $(PATCHLEVEL) % 2), 0)
PRERELEASE = false
endif
PKG_LIST := $(shell go list ./... | grep -v /vendor/)
LDFLAGS = -X github.com/develatio/nebulant-bridge/bconfig.Version=$(BRIDGEVERSION)\
-X github.com/develatio/nebulant-bridge/bconfig.VersionDate=$(DATE)\
-X github.com/develatio/nebulant-bridge/bconfig.VersionCommit=$(COMMIT)\
-X 'github.com/develatio/nebulant-bridge/bconfig.VersionGo=$(GOVERSION)'
MINGOVERSION = 1.21.0
ifndef $(GOPATH)
GOPATH=$(shell go env GOPATH)
export GOPATH
endif
ifndef $(GOOS)
GOOS=$(shell go env GOOS)
export GOOS
endif
ifndef $(GOARCH)
GOARCH=$(shell go env GOARCH)
export GOARCH
endif
GOEXE=$(shell go env GOEXE)
.PHONY: create-network
create-network:
docker network create nebulant-lan 2> /dev/null || true
.PHONY: runrace
runrace:
CGO_ENABLED=1 go run -race -ldflags "$(LDFLAGS)" bridge.go $(ARGS)
.PHONY: run
run:
CGO_ENABLED=1 go run -ldflags "$(LDFLAGS)" bridge.go $(ARGS)
.PHONY: rundocker
rundocker: create-network
docker compose -f docker-compose.yml up bridge
build:
GO111MODULE=on CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -a -trimpath -ldflags "-w -s $(LDFLAGS)" -o dist/nebulant-bridge$(GOEXE) bridge.go
.PHONY: build_platform
build_platform:
@mkdir -p dist/v$(BRIDGEVERSION)
GO111MODULE=on CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -a -trimpath -ldflags "-w -s $(LDFLAGS) $(EXTRAFLAGS)" -o dist/v$(BRIDGEVERSION)/nebulant-bridge$(DIST_SUFFIX) bridge.go
@shasum -a 256 dist/v$(BRIDGEVERSION)/nebulant-bridge$(DIST_SUFFIX) > dist/v$(BRIDGEVERSION)/nebulant-bridge$(DIST_SUFFIX).checksum
@printf "sha256: "
@cat dist/v$(BRIDGEVERSION)/nebulant-bridge$(DIST_SUFFIX).checksum
.PHONY: buildall
buildall:
GOOS=linux GOARCH=arm GOEXE= DIST_SUFFIX=-linux-arm $(MAKE) build_platform
GOOS=linux GOARCH=arm64 GOEXE= DIST_SUFFIX=-linux-arm64 $(MAKE) build_platform
GOOS=linux GOARCH=386 GOEXE= DIST_SUFFIX=-linux-386 $(MAKE) build_platform
GOOS=linux GOARCH=amd64 GOEXE= DIST_SUFFIX=-linux-amd64 $(MAKE) build_platform
GOOS=freebsd GOARCH=arm GOEXE= DIST_SUFFIX=-freebsd-arm $(MAKE) build_platform
GOOS=freebsd GOARCH=arm64 GOEXE= DIST_SUFFIX=-freebsd-arm64 $(MAKE) build_platform
GOOS=freebsd GOARCH=386 GOEXE= DIST_SUFFIX=-freebsd-386 $(MAKE) build_platform
GOOS=freebsd GOARCH=amd64 GOEXE= DIST_SUFFIX=-freebsd-amd64 $(MAKE) build_platform
GOOS=openbsd GOARCH=arm GOEXE= DIST_SUFFIX=-openbsd-arm $(MAKE) build_platform
GOOS=openbsd GOARCH=arm64 GOEXE= DIST_SUFFIX=-openbsd-arm64 $(MAKE) build_platform
GOOS=openbsd GOARCH=386 GOEXE= DIST_SUFFIX=-openbsd-386 $(MAKE) build_platform
GOOS=openbsd GOARCH=amd64 GOEXE= DIST_SUFFIX=-openbsd-amd64 $(MAKE) build_platform
GOOS=windows GOARCH=arm GOEXE=.exe DIST_SUFFIX=-windows-arm.exe $(MAKE) build_platform
GOOS=windows GOARCH=arm64 GOEXE=.exe DIST_SUFFIX=-windows-arm64.exe $(MAKE) build_platform
GOOS=windows GOARCH=386 GOEXE=.exe DIST_SUFFIX=-windows-386.exe $(MAKE) build_platform
GOOS=windows GOARCH=amd64 GOEXE=.exe DIST_SUFFIX=-windows-amd64.exe $(MAKE) build_platform
GOOS=darwin GOARCH=arm64 GOEXE= DIST_SUFFIX=-darwin-arm64 $(MAKE) build_platform
GOOS=darwin GOARCH=amd64 GOEXE= DIST_SUFFIX=-darwin-amd64 $(MAKE) build_platform
# GOOS=js GOARCH=wasm GOEXE= DIST_SUFFIX=-js-wasm $(MAKE) build_platform
.PHONY: secure
secure:
# https://github.com/securego/gosec/blob/master/README.md
# G307 -- https://github.com/securego/gosec/issues/512
$(GOPATH)/bin/gosec -exclude=G307 ./...
.PHONY: staticanalysis
staticanalysis:
# https://github.com/praetorian-inc/gokart
$(GOPATH)/bin/gokart scan -v
.PHONY: unittest
unittest:
go test -v -race $(PKG_LIST)
.PHONY: cover
cover:
go test -cover -v -race $(PKG_LIST)
.PHONY: htmlcover
htmlcover:
go test -coverprofile cover.out -v -race $(PKG_LIST)
go tool cover -html=cover.out
.PHONY: bridgeversion
bridgeversion:
@echo $(BRIDGEVERSION)
.PHONY: ispre
ispre:
@echo $(PRERELEASE)
.PHONY: versiondate
versiondate:
@echo $(DATE)
.PHONY: goversion
goversion:
@echo $(MINGOVERSION)