forked from axelarnetwork/axelar-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
208 lines (167 loc) · 7.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
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
PACKAGES=$(shell go list ./... | grep -v '/simulation')
VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
BUILD_TAGS := ledger
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
HTTPS_GIT := https://github.com/axelarnetowrk/axelar-core.git
PUSH_DOCKER_IMAGE=true
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=axelar \
-X github.com/cosmos/cosmos-sdk/version.AppName=axelard \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(BUILD_TAGS)" \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT)
BUILD_FLAGS := -tags "$(BUILD_TAGS)" -ldflags '$(ldflags)'
USER_ID := $(shell id -u)
GROUP_ID := $(shell id -g)
.PHONY: all
all: generate lint build docker-image docker-image-debug
go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
GO111MODULE=on go mod verify
# Uncomment when you have some tests
# test:
# @go test -mod=readonly $(PACKAGES)
.PHONY: lint
# look into .golangci.yml for enabling / disabling linters
lint:
@echo "--> Running linter"
@golangci-lint run
@go mod verify
# Build the project with release flags
.PHONY: build
build: go.sum
go build -o ./bin/axelard -mod=readonly $(BUILD_FLAGS) ./cmd/axelard
.PHONY: build-binaries
build-binaries: guard-SEMVER
./scripts/build-binaries.sh ${SEMVER} '$(BUILD_TAGS)' '$(ldflags)'
.PHONY: build-binaries-in-docker
build-binaries-in-docker: guard-SEMVER
DOCKER_BUILDKIT=1 docker build \
--ssh default \
--build-arg SEMVER=${SEMVER} \
-t axelar/core:binaries \
-f Dockerfile.binaries .
./scripts/copy-binaries-from-image.sh
# Build the project with debug flags
.PHONY: debug
debug: go.sum
go build -o ./bin/axelard -mod=readonly $(BUILD_FLAGS) -gcflags="all=-N -l" ./cmd/axelard
# Build a release image
.PHONY: docker-image
docker-image:
@DOCKER_BUILDKIT=1 docker build --ssh default -t axelar/core .
# Build a release image
.PHONY: docker-image-local-user
docker-image-local-user: guard-VERSION guard-GROUP_ID guard-USER_ID
@DOCKER_BUILDKIT=1 docker build \
--ssh default \
--build-arg USER_ID=${USER_ID} \
--build-arg GROUP_ID=${GROUP_ID} \
-t axelarnet/axelar-core:${VERSION}-local .
.PHONY: build-push-docker-image
build-push-docker-images: guard-SEMVER
@DOCKER_BUILDKIT=1 docker buildx build \
--platform linux/arm64,linux/amd64,linux/arm/v7,linux/arm/v6 \
--ssh default \
--output "type=image,push=${PUSH_DOCKER_IMAGE}" \
-t axelarnet/axelar-core:${SEMVER} .
# Build a docker image that is able to run dlv and a debugger can be hooked up to
.PHONY: docker-image-debug
docker-image-debug:
@DOCKER_BUILDKIT=1 docker build --ssh default -t axelar/core-debug -f ./Dockerfile.debug .
# Install all generate prerequisites
.Phony: prereqs
prereqs:
ifeq (which moq,)
go get github.com/matryer/moq
endif
ifeq (which mdformat,)
pip3 install mdformat
endif
ifeq (which protoc,)
@echo "Please install protoc for grpc (https://grpc.io/docs/languages/go/quickstart/)"
endif
# Run all the code generators in the project
.PHONY: generate
generate:
go generate -x ./...
.PHONE: tofnd-client
tofnd-client:
@echo -n Generating protobufs...
@protoc --go_out=. --go-grpc_out=. --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative proto/tss/tofnd/v1beta1/tofnd.proto
@echo done
###############################################################################
### Protobuf ###
###############################################################################
proto-all: proto-update-deps proto-format proto-lint proto-gen
proto-gen:
@echo "Generating Protobuf files"
@DOCKER_BUILDKIT=1 docker build --ssh default -t axelar/proto-gen -f ./Dockerfile.protocgen .
@$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace axelar/proto-gen sh ./scripts/protocgen.sh
proto-format:
@echo "Formatting Protobuf files"
@$(DOCKER) run --rm -v $(CURDIR):/workspace \
--workdir /workspace tendermintdev/docker-build-proto \
find ./ -not -path "./third_party/*" -name "*.proto" -exec clang-format -i {} \;
proto-swagger-gen:
@./scripts/protoc-swagger-gen.sh
proto-lint:
@echo "Linting Protobuf files"
@$(DOCKER_BUF) lint
# this will only work when the repo is made public
proto-check-breaking:
@$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=main
TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.0-rc6/proto/tendermint
GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos
GOOGLE_API_URL = https://raw.githubusercontent.com/googleapis/googleapis/master/google/api
COSMOS_PROTO_URL = https://raw.githubusercontent.com/regen-network/cosmos-proto/master
CONFIO_URL = https://raw.githubusercontent.com/confio/ics23/v0.6.4
TM_CRYPTO_TYPES = third_party/proto/tendermint/crypto
TM_ABCI_TYPES = third_party/proto/tendermint/abci
TM_TYPES = third_party/proto/tendermint/types
TM_VERSION = third_party/proto/tendermint/version
TM_LIBS = third_party/proto/tendermint/libs/bits
TM_P2P = third_party/proto/tendermint/p2p
GOGO_PROTO_TYPES = third_party/proto/gogoproto
GOOGLE_API_TYPES = third_party/proto/google/api
COSMOS_PROTO_TYPES = third_party/proto/cosmos_proto
CONFIO_TYPES = third_party/proto/confio
proto-update-deps:
@mkdir -p $(GOGO_PROTO_TYPES)
@curl -sSL $(GOGO_PROTO_URL)/gogoproto/gogo.proto > $(GOGO_PROTO_TYPES)/gogo.proto
@mkdir -p $(GOOGLE_API_TYPES)
@curl -sSL $(GOOGLE_API_URL)/annotations.proto > $(GOOGLE_API_TYPES)/annotations.proto
@curl -sSL $(GOOGLE_API_URL)/http.proto > $(GOOGLE_API_TYPES)/http.proto
@mkdir -p $(COSMOS_PROTO_TYPES)
@curl -sSL $(COSMOS_PROTO_URL)/cosmos.proto > $(COSMOS_PROTO_TYPES)/cosmos.proto
## Importing of tendermint protobuf definitions currently requires the
## use of `sed` in order to build properly with cosmos-sdk's proto file layout
## (which is the standard Buf.build FILE_LAYOUT)
## Issue link: https://github.com/tendermint/tendermint/issues/5021
@mkdir -p $(TM_ABCI_TYPES)
@curl -sSL $(TM_URL)/abci/types.proto > $(TM_ABCI_TYPES)/types.proto
@mkdir -p $(TM_VERSION)
@curl -sSL $(TM_URL)/version/types.proto > $(TM_VERSION)/types.proto
@mkdir -p $(TM_TYPES)
@curl -sSL $(TM_URL)/types/types.proto > $(TM_TYPES)/types.proto
@curl -sSL $(TM_URL)/types/evidence.proto > $(TM_TYPES)/evidence.proto
@curl -sSL $(TM_URL)/types/params.proto > $(TM_TYPES)/params.proto
@curl -sSL $(TM_URL)/types/validator.proto > $(TM_TYPES)/validator.proto
@curl -sSL $(TM_URL)/types/block.proto > $(TM_TYPES)/block.proto
@mkdir -p $(TM_CRYPTO_TYPES)
@curl -sSL $(TM_URL)/crypto/proof.proto > $(TM_CRYPTO_TYPES)/proof.proto
@curl -sSL $(TM_URL)/crypto/keys.proto > $(TM_CRYPTO_TYPES)/keys.proto
@mkdir -p $(TM_LIBS)
@curl -sSL $(TM_URL)/libs/bits/types.proto > $(TM_LIBS)/types.proto
@mkdir -p $(TM_P2P)
@curl -sSL $(TM_URL)/p2p/types.proto > $(TM_P2P)/types.proto
@mkdir -p $(CONFIO_TYPES)
@curl -sSL $(CONFIO_URL)/proofs.proto > $(CONFIO_TYPES)/proofs.proto
## insert go package option into proofs.proto file
## Issue link: https://github.com/confio/ics23/issues/32
@./scripts/sed.sh $(CONFIO_TYPES)/proofs.proto
@./scripts/proto-copy-cosmos-sdk.sh
.PHONY: proto-all proto-gen proto-gen-any proto-swagger-gen proto-format proto-lint proto-check-breaking proto-update-deps
guard-%:
@ if [ -z '${${*}}' ]; then echo 'Environment variable $* not set' && exit 1; fi