forked from pactus-project/pactus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
87 lines (71 loc) · 2.43 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
PACKAGES=$(shell go list ./... | grep -v 'tests')
HERUMI= $(shell pwd)/.herumi
CGO_LDFLAGS=CGO_LDFLAGS="-L$(HERUMI)/bls/lib -lbls384_256 -lm -lstdc++ -g -O2"
BUILD_LDFLAGS= -ldflags "-X github.com/zarbchain/zarb-go/version.build=`git rev-parse --short=8 HEAD`"
RELEASE_LDFLAGS= -ldflags "-s -w"
all: install test
########################################
### Tools needed for development
devtools:
@echo "Installing devtools"
go install zombiezen.com/go/capnproto2/capnpc-go@v2.18.0
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.43.0
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@v2.3.0
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@v2.3.0
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.27.1
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1.0
go install github.com/bufbuild/buf/cmd/buf@v0.39.1
go install github.com/rakyll/statik@v0.1.7
herumi:
@if [ ! -d $(HERUMI) ]; then \
git clone --recursive https://github.com/herumi/bls.git $(HERUMI)/bls && cd $(HERUMI)/bls && make minimized_static; \
fi
########################################
### Building
build:
go build $(BUILD_LDFLAGS) ./cmd/zarb
install:
go install $(BUILD_LDFLAGS) ./cmd/zarb
release: herumi
$(CGO_LDFLAGS) go build $(RELEASE_LDFLAGS) ./cmd/zarb
########################################
### Testing
unit_test:
go test $(PACKAGES)
test:
go test ./... -covermode=atomic
test_race:
go test ./... --race
########################################
### Docker
docker:
docker build --tag zarb .
########################################
### capnp and proto
capnp:
capnp compile \
-ogo ./www/capnp/zarb.capnp
proto:
cd www/grpc/ && buf generate --path ./proto/zarb.proto --path proto/payloads.proto
# Generate static assets for OpenAPI UI
cd www/grpc/ && statik -m -f -src third_party/OpenAPI/
########################################
### Formatting, linting, and vetting
fmt:
gofmt -s -w .
golangci-lint run -e "SA1019" \
--timeout=5m0s \
--enable=gofmt \
--enable=unconvert \
--enable=unparam \
--enable=revive \
--enable=asciicheck \
--enable=misspell \
--enable=gosec
# To avoid unintended conflicts with file names, always add to .PHONY
# unless there is a reason not to.
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
.PHONY: build install release
.PHONY: test unit_test test_race
.PHONY: devtools herumi capnp proto
.PHONY: fmt docker