forked from codenotary/immudb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
264 lines (221 loc) · 8.83 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# Copyright 2019-2020 vChain, Inc. \
\
Licensed under the Apache License, Version 2.0 (the "License"); \
you may not use this file except in compliance with the License. \
You may obtain a copy of the License at \
\
http://www.apache.org/licenses/LICENSE-2.0 \
\
Unless required by applicable law or agreed to in writing, software \
distributed under the License is distributed on an "AS IS" BASIS, \
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \
See the License for the specific language governing permissions and \
limitations under the License.
export GO111MODULE=on
SHELL=/bin/bash -o pipefail
VERSION=0.6.2
TARGETS=linux/amd64 windows/amd64 darwin/amd64 linux/s390x
SERVICE_EXE=${SERVICE_NAME}-v${VERSION}-windows-amd64.exe
PWD = $(shell pwd)
GO ?= go
DOCKER ?= docker
PROTOC ?= protoc
STRIP = strip
V_COMMIT := $(shell git rev-parse HEAD)
#V_BUILT_BY := "$(shell echo "`git config user.name`<`git config user.email`>")"
V_BUILT_BY := $(shell git config user.email)
V_BUILT_AT := $(shell date +%s)
V_LDFLAGS_COMMON := -X "github.com/codenotary/immudb/cmd/version.Version=$(VERSION)" \
-X "github.com/codenotary/immudb/cmd/version.Commit=$(V_COMMIT)" \
-X "github.com/codenotary/immudb/cmd/version.BuiltBy=$(V_BUILT_BY)"\
-X "github.com/codenotary/immudb/cmd/version.BuiltAt=$(V_BUILT_AT)"
V_LDFLAGS_STATIC := ${V_LDFLAGS_COMMON} \
-X github.com/codenotary/immudb/cmd/version.Static=static \
-extldflags "-static"
.PHONY: all
all: immudb immuclient immugw immuadmin immutest
@echo 'Build successful, now you can make the manuals or check the status of the database with immuadmin.'
.PHONY: rebuild
rebuild: clean build/codegen all
.PHONY: immuclient
immuclient:
$(GO) build -v -ldflags '$(V_LDFLAGS_COMMON)' ./cmd/immuclient
.PHONY: immuadmin
immuadmin:
$(GO) build -v -ldflags '$(V_LDFLAGS_COMMON)' ./cmd/immuadmin
.PHONY: immudb
immudb:
$(GO) build -v -ldflags '$(V_LDFLAGS_COMMON)' ./cmd/immudb
.PHONY: immugw
immugw:
$(GO) build -v -ldflags '$(V_LDFLAGS_COMMON)' ./cmd/immugw
.PHONY: immutest
immutest:
$(GO) build -v -ldflags '$(V_LDFLAGS_COMMON)' ./cmd/immutest
.PHONY: immuclient-static
immuclient-static:
CGO_ENABLED=0 $(GO) build -a -tags netgo -ldflags '$(V_LDFLAGS_STATIC) -extldflags "-static"' ./cmd/immuclient
.PHONY: immuadmin-static
immuadmin-static:
CGO_ENABLED=0 $(GO) build -a -tags netgo -ldflags '$(V_LDFLAGS_STATIC) -extldflags "-static"' ./cmd/immuadmin
.PHONY: immudb-static
immudb-static:
CGO_ENABLED=0 $(GO) build -a -tags netgo -ldflags '$(V_LDFLAGS_STATIC) -extldflags "-static"' ./cmd/immudb
.PHONY: immugw-static
immugw-static:
CGO_ENABLED=0 $(GO) build -a -tags netgo -ldflags '$(V_LDFLAGS_STATIC) -extldflags "-static"' ./cmd/immugw
.PHONY: immutest-static
immutest-static:
CGO_ENABLED=0 $(GO) build -a -tags netgo -ldflags '$(V_LDFLAGS_STATIC) -extldflags "-static"' ./cmd/immutest
.PHONY: vendor
vendor:
$(GO) mod vendor
# To view coverage as HTML run: go tool cover -html=coverage.txt
.PHONY: test
test:
$(GO) vet ./...
$(GO) test -v -failfast $(go list ./... | grep -v test) --race -coverprofile=coverage.txt -covermode=atomic ./...
.PHONY: build/codegen
build/codegen:
$(PROTOC) -I pkg/api/schema/ pkg/api/schema/schema.proto \
-I${GOPATH}/pkg/mod \
-I${GOPATH}/pkg/mod/github.com/grpc-ecosystem/[email protected]/third_party/googleapis \
-I${GOPATH}/pkg/mod/github.com/dgraph-io/badger/[email protected] \
-I${GOPATH}/pkg/mod/github.com/grpc-ecosystem/[email protected] \
--go_out=plugins=grpc,paths=source_relative:pkg/api/schema
$(PROTOC) -I pkg/api/schema/ pkg/api/schema/schema.proto \
-I${GOPATH}/pkg/mod \
-I${GOPATH}/pkg/mod/github.com/grpc-ecosystem/[email protected]/third_party/googleapis \
-I${GOPATH}/pkg/mod/github.com/dgraph-io/badger/[email protected] \
-I${GOPATH}/pkg/mod/github.com/grpc-ecosystem/[email protected] \
--grpc-gateway_out=logtostderr=true,paths=source_relative:pkg/api/schema \
$(PROTOC) -I pkg/api/schema/ pkg/api/schema/schema.proto \
-I${GOPATH}/pkg/mod \
-I${GOPATH}/pkg/mod/github.com/grpc-ecosystem/[email protected]/third_party/googleapis \
-I${GOPATH}/pkg/mod/github.com/dgraph-io/badger/[email protected] \
-I${GOPATH}/pkg/mod/github.com/grpc-ecosystem/[email protected] \
--swagger_out=logtostderr=true:pkg/api/schema
$(PROTOC) -I pkg/api/schema/ pkg/api/schema/schema.proto \
-I${GOPATH}/pkg/mod \
-I${GOPATH}/pkg/mod/github.com/grpc-ecosystem/[email protected]/third_party/googleapis \
-I${GOPATH}/pkg/mod/github.com/dgraph-io/badger/[email protected] \
-I${GOPATH}/pkg/mod/github.com/grpc-ecosystem/[email protected] \
--doc_out=pkg/api/schema --doc_opt=markdown,docs.md \
.PHONY: clean
clean:
rm -f immudb immuclient immugw immuadmin immutest
.PHONY: nimmu
nimmu:
$(GO) build -o nimmu ./tools/nimmu
.PHONY: bm
bm:
$(GO) build -ldflags '-s -w' ./tools/bm
$(STRIP) bm
.PHONY: bm/function
bm/function: bm
./bm function
.PHONY: bm/rpc
bm/rpc: bm
./bm rpc
.PHONY: bench
bench:
$(DOCKER) build -t immu_bench -f ./Dockerfile.bench .
$(DOCKER) run --rm -it immu_bench
.PHONY: tools/comparison/mongodb
tools/comparison/mongodb:
$(DOCKER) build -t immu_mongodb ./tools/comparison/mongodb
$(DOCKER) run --rm -it immu_mongodb
.PHONY: tools/comparison/scylladb
tools/comparison/scylladb:
$(DOCKER) build -t immu_scylladb ./tools/comparison/scylladb
$(DOCKER) run --rm -it immu_scylladb
.PHONY: man
man:
$(GO) run ./cmd/immuclient mangen ./cmd/docs/man/immuclient
$(GO) run ./cmd/immuadmin mangen ./cmd/docs/man/immuadmin
$(GO) run ./cmd/immudb mangen ./cmd/docs/man/immudb
$(GO) run ./cmd/immugw mangen ./cmd/docs/man/immugw
$(GO) run ./cmd/immutest mangen ./cmd/docs/man/immutest
.PHONY: prerequisites
prerequisites:
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.11.4/protoc-3.11.4-linux-x86_64.zip -O /tmp/protoc.zip
unzip -o /tmp/protoc.zip -d $(GOPATH)/bin
rm -rf $(GOPATH)/pkg/mod/google
mv $(GOPATH)/bin/include/google $(GOPATH)/pkg/mod
rmdir $(GOPATH)/bin/include
rm /tmp/protoc.zip
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
go get -u google.golang.org/grpc
go get -u github.com/golang/protobuf/
go get -u github.com/golang/protobuf/proto
go get -u github.com/golang/protobuf/protoc-gen-go
go get -u github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc
########################## releases scripts ############################################################################
.PHONY: CHANGELOG.md
CHANGELOG.md:
git-chglog -o CHANGELOG.md
.PHONY: CHANGELOG.md.next-tag
CHANGELOG.md.next-tag:
git-chglog -o CHANGELOG.md --next-tag v${VERSION}
.PHONY: build/xgo
build/xgo:
$(DOCKER) build \
-f ./build/xgo/Dockerfile \
-t ${SERVICE_NAME}-xgo \
--pull=true \
./build/xgo
.PHONY: build/makensis
build/makensis:
$(DOCKER) build \
-f ./build/makensis/Dockerfile \
-t ${SERVICE_NAME}-makensis \
./build/makensis
.PHONY: clean/dist
clean/dist:
rm -Rf ./dist
.PHONY: dist
dist: clean/dist build/xgo
mkdir -p dist
$(GO) build -a -tags netgo -ldflags '${V_LDFLAGS_STATIC}' \
-o ./dist/${SERVICE_NAME}-v${VERSION}-linux-amd64-static \
./cmd/${SERVICE_NAME}
$(DOCKER) run --rm \
-v "${PWD}/dist:/dist" \
-v "${PWD}:/source:ro" \
-e GO111MODULE=on \
-e FLAG_LDFLAGS="-s ${V_LDFLAGS_COMMON}" \
-e TARGETS="${TARGETS}" \
-e PACK=cmd/${SERVICE_NAME} \
-e OUT=${SERVICE_NAME}-v${VERSION} \
${SERVICE_NAME}-xgo .
mv ./dist/${SERVICE_NAME}-v${VERSION}-windows-4.0-amd64.exe ./dist/${SERVICE_EXE}
mv ./dist/${SERVICE_NAME}-v${VERSION}-darwin-10.6-amd64 ./dist/${SERVICE_NAME}-v${VERSION}-darwin-amd64
.PHONY: dist/${SERVICE_EXE}
dist/${SERVICE_EXE}:
echo ${SIGNCODE_PVK_PASSWORD} | $(DOCKER) run --rm -i \
-v ${PWD}/dist:/dist \
-v ${SIGNCODE_SPC}:/certs/f.spc:ro \
-v ${SIGNCODE_PVK}:/certs/f.pvk:ro \
mono:6.8.0 signcode \
-spc /certs/f.spc -v /certs/f.pvk \
-a sha1 -$ commercial \
-n "CodeNotary ${SERVICE_NAME}" \
-i https://codenotary.io/ \
-t http://timestamp.comodoca.com -tr 10 \
$@
rm -Rf [email protected]
.PHONY: dist/sign
dist/sign: vendor ${SERVICE_NAME}
for f in ./dist/*; do vcn sign -p $$f; printf "\n\n"; done
# SERVICE_NAME=immudb|immuclient|immugw SIGNCODE_PVK_PASSWORD=<pvk password> SIGNCODE_PVK=<path to vchain.pvk> SIGNCODE_SPC=<path to vchain.spc> make dist/all
.PHONY: dist/all
dist/all: dist dist/${SERVICE_EXE}
.PHONY: dist/binary.md
dist/binary.md:
@for f in ./dist/*; do \
ff=$$(basename $$f); \
shm_id=$$(sha256sum $$f | awk '{print $$1}'); \
printf "[$$ff](https://github.com/vchain-us/immudb/releases/download/v${VERSION}/$$ff) | $$shm_id \n" ; \
done
########################## releases scripts end ########################################################################