github.com/opzlabs/tendermint@v0.34.27-terra.rc.2/Makefile (about) 1 PACKAGES=$(shell go list ./...) 2 BUILDDIR?=$(CURDIR)/build 3 OUTPUT?=$(BUILDDIR)/cometbft 4 5 BUILD_TAGS?=cometbft 6 7 COMMIT_HASH := $(shell git rev-parse --short HEAD) 8 LD_FLAGS = -X github.com/cometbft/cometbft/version.TMGitCommitHash=$(COMMIT_HASH) 9 BUILD_FLAGS = -mod=readonly -ldflags "$(LD_FLAGS)" 10 HTTPS_GIT := https://github.com/cometbft/cometbft.git 11 CGO_ENABLED ?= 0 12 13 # handle nostrip 14 ifeq (,$(findstring nostrip,$(COMETBFT_BUILD_OPTIONS))) 15 BUILD_FLAGS += -trimpath 16 LD_FLAGS += -s -w 17 endif 18 19 # handle race 20 ifeq (race,$(findstring race,$(COMETBFT_BUILD_OPTIONS))) 21 CGO_ENABLED=1 22 BUILD_FLAGS += -race 23 endif 24 25 # handle cleveldb 26 ifeq (cleveldb,$(findstring cleveldb,$(COMETBFT_BUILD_OPTIONS))) 27 CGO_ENABLED=1 28 BUILD_TAGS += cleveldb 29 endif 30 31 # handle badgerdb 32 ifeq (badgerdb,$(findstring badgerdb,$(COMETBFT_BUILD_OPTIONS))) 33 BUILD_TAGS += badgerdb 34 endif 35 36 # handle rocksdb 37 ifeq (rocksdb,$(findstring rocksdb,$(COMETBFT_BUILD_OPTIONS))) 38 CGO_ENABLED=1 39 BUILD_TAGS += rocksdb 40 endif 41 42 # handle boltdb 43 ifeq (boltdb,$(findstring boltdb,$(COMETBFT_BUILD_OPTIONS))) 44 BUILD_TAGS += boltdb 45 endif 46 47 # allow users to pass additional flags via the conventional LDFLAGS variable 48 LD_FLAGS += $(LDFLAGS) 49 50 # Process Docker environment varible TARGETPLATFORM 51 # in order to build binary with correspondent ARCH 52 # by default will always build for linux/amd64 53 TARGETPLATFORM ?= 54 GOOS ?= linux 55 GOARCH ?= amd64 56 GOARM ?= 57 58 ifeq (linux/arm,$(findstring linux/arm,$(TARGETPLATFORM))) 59 GOOS=linux 60 GOARCH=arm 61 GOARM=7 62 endif 63 64 ifeq (linux/arm/v6,$(findstring linux/arm/v6,$(TARGETPLATFORM))) 65 GOOS=linux 66 GOARCH=arm 67 GOARM=6 68 endif 69 70 ifeq (linux/arm64,$(findstring linux/arm64,$(TARGETPLATFORM))) 71 GOOS=linux 72 GOARCH=arm64 73 GOARM=7 74 endif 75 76 ifeq (linux/386,$(findstring linux/386,$(TARGETPLATFORM))) 77 GOOS=linux 78 GOARCH=386 79 endif 80 81 ifeq (linux/amd64,$(findstring linux/amd64,$(TARGETPLATFORM))) 82 GOOS=linux 83 GOARCH=amd64 84 endif 85 86 ifeq (linux/mips,$(findstring linux/mips,$(TARGETPLATFORM))) 87 GOOS=linux 88 GOARCH=mips 89 endif 90 91 ifeq (linux/mipsle,$(findstring linux/mipsle,$(TARGETPLATFORM))) 92 GOOS=linux 93 GOARCH=mipsle 94 endif 95 96 ifeq (linux/mips64,$(findstring linux/mips64,$(TARGETPLATFORM))) 97 GOOS=linux 98 GOARCH=mips64 99 endif 100 101 ifeq (linux/mips64le,$(findstring linux/mips64le,$(TARGETPLATFORM))) 102 GOOS=linux 103 GOARCH=mips64le 104 endif 105 106 ifeq (linux/riscv64,$(findstring linux/riscv64,$(TARGETPLATFORM))) 107 GOOS=linux 108 GOARCH=riscv64 109 endif 110 111 all: check build test install 112 .PHONY: all 113 114 include tests.mk 115 116 ############################################################################### 117 ### Build CometBFT ### 118 ############################################################################### 119 120 build: 121 CGO_ENABLED=$(CGO_ENABLED) go build $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' -o $(OUTPUT) ./cmd/cometbft/ 122 .PHONY: build 123 124 install: 125 CGO_ENABLED=$(CGO_ENABLED) go install $(BUILD_FLAGS) -tags $(BUILD_TAGS) ./cmd/cometbft 126 .PHONY: install 127 128 129 ############################################################################### 130 ### Mocks ### 131 ############################################################################### 132 133 mockery: 134 go generate -run="./scripts/mockery_generate.sh" ./... 135 .PHONY: mockery 136 137 ############################################################################### 138 ### Protobuf ### 139 ############################################################################### 140 141 check-proto-deps: 142 ifeq (,$(shell which protoc-gen-gogofaster)) 143 @go install github.com/gogo/protobuf/protoc-gen-gogofaster@latest 144 endif 145 .PHONY: check-proto-deps 146 147 check-proto-format-deps: 148 ifeq (,$(shell which clang-format)) 149 $(error "clang-format is required for Protobuf formatting. See instructions for your platform on how to install it.") 150 endif 151 .PHONY: check-proto-format-deps 152 153 proto-gen: check-proto-deps 154 @echo "Generating Protobuf files" 155 @go run github.com/bufbuild/buf/cmd/buf generate 156 @mv ./proto/tendermint/abci/types.pb.go ./abci/types/ 157 .PHONY: proto-gen 158 159 # These targets are provided for convenience and are intended for local 160 # execution only. 161 proto-lint: check-proto-deps 162 @echo "Linting Protobuf files" 163 @go run github.com/bufbuild/buf/cmd/buf lint 164 .PHONY: proto-lint 165 166 proto-format: check-proto-format-deps 167 @echo "Formatting Protobuf files" 168 @find . -name '*.proto' -path "./proto/*" -exec clang-format -i {} \; 169 .PHONY: proto-format 170 171 proto-check-breaking: check-proto-deps 172 @echo "Checking for breaking changes in Protobuf files against local branch" 173 @echo "Note: This is only useful if your changes have not yet been committed." 174 @echo " Otherwise read up on buf's \"breaking\" command usage:" 175 @echo " https://docs.buf.build/breaking/usage" 176 @go run github.com/bufbuild/buf/cmd/buf breaking --against ".git" 177 .PHONY: proto-check-breaking 178 179 proto-check-breaking-ci: 180 @go run github.com/bufbuild/buf/cmd/buf breaking --against $(HTTPS_GIT)#branch=v0.34.x 181 .PHONY: proto-check-breaking-ci 182 183 ############################################################################### 184 ### Build ABCI ### 185 ############################################################################### 186 187 build_abci: 188 @go build -mod=readonly -i ./abci/cmd/... 189 .PHONY: build_abci 190 191 install_abci: 192 @go install -mod=readonly ./abci/cmd/... 193 .PHONY: install_abci 194 195 ############################################################################### 196 ### Distribution ### 197 ############################################################################### 198 199 # dist builds binaries for all platforms and packages them for distribution 200 # TODO add abci to these scripts 201 dist: 202 @BUILD_TAGS=$(BUILD_TAGS) sh -c "'$(CURDIR)/scripts/dist.sh'" 203 .PHONY: dist 204 205 go-mod-cache: go.sum 206 @echo "--> Download go modules to local cache" 207 @go mod download 208 .PHONY: go-mod-cache 209 210 go.sum: go.mod 211 @echo "--> Ensure dependencies have not been modified" 212 @go mod verify 213 @go mod tidy 214 215 draw_deps: 216 @# requires brew install graphviz or apt-get install graphviz 217 go get github.com/RobotsAndPencils/goviz 218 @goviz -i github.com/cometbft/cometbft/cmd/cometbft -d 3 | dot -Tpng -o dependency-graph.png 219 .PHONY: draw_deps 220 221 get_deps_bin_size: 222 @# Copy of build recipe with additional flags to perform binary size analysis 223 $(eval $(shell go build -work -a $(BUILD_FLAGS) -tags $(BUILD_TAGS) -o $(OUTPUT) ./cmd/cometbft/ 2>&1)) 224 @find $(WORK) -type f -name "*.a" | xargs -I{} du -hxs "{}" | sort -rh | sed -e s:${WORK}/::g > deps_bin_size.log 225 @echo "Results can be found here: $(CURDIR)/deps_bin_size.log" 226 .PHONY: get_deps_bin_size 227 228 ############################################################################### 229 ### Libs ### 230 ############################################################################### 231 232 # generates certificates for TLS testing in remotedb and RPC server 233 gen_certs: clean_certs 234 certstrap init --common-name "cometbft.com" --passphrase "" 235 certstrap request-cert --common-name "server" -ip "127.0.0.1" --passphrase "" 236 certstrap sign "server" --CA "cometbft.com" --passphrase "" 237 mv out/server.crt rpc/jsonrpc/server/test.crt 238 mv out/server.key rpc/jsonrpc/server/test.key 239 rm -rf out 240 .PHONY: gen_certs 241 242 # deletes generated certificates 243 clean_certs: 244 rm -f rpc/jsonrpc/server/test.crt 245 rm -f rpc/jsonrpc/server/test.key 246 .PHONY: clean_certs 247 248 ############################################################################### 249 ### Formatting, linting, and vetting ### 250 ############################################################################### 251 252 format: 253 find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs gofmt -w -s 254 find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs goimports -w -local github.com/cometbft/cometbft 255 .PHONY: format 256 257 lint: 258 @echo "--> Running linter" 259 @go run github.com/golangci/golangci-lint/cmd/golangci-lint run 260 .PHONY: lint 261 262 vulncheck: 263 @go run golang.org/x/vuln/cmd/govulncheck@latest ./... 264 .PHONY: vulncheck 265 266 DESTINATION = ./index.html.md 267 268 269 ############################################################################### 270 ### Documentation ### 271 ############################################################################### 272 273 # Verify that important design docs have ToC entries. 274 check-docs-toc: 275 @./docs/presubmit.sh 276 .PHONY: check-docs-toc 277 278 ############################################################################### 279 ### Docker image ### 280 ############################################################################### 281 282 # On Linux, you may need to run `DOCKER_BUILDKIT=1 make build-docker` for this 283 # to work. 284 build-docker: 285 docker build \ 286 --label=cometbft \ 287 --tag="cometbft/cometbft" \ 288 -f DOCKER/Dockerfile . 289 .PHONY: build-docker 290 291 ############################################################################### 292 ### Local testnet using docker ### 293 ############################################################################### 294 295 # Build linux binary on other platforms 296 build-linux: 297 GOOS=linux GOARCH=amd64 $(MAKE) build 298 .PHONY: build-linux 299 300 build-docker-localnode: 301 @cd networks/local && make 302 .PHONY: build-docker-localnode 303 304 # Runs `make build COMETBFT_BUILD_OPTIONS=cleveldb` from within an Amazon 305 # Linux (v2)-based Docker build container in order to build an Amazon 306 # Linux-compatible binary. Produces a compatible binary at ./build/cometbft 307 build_c-amazonlinux: 308 $(MAKE) -C ./DOCKER build_amazonlinux_buildimage 309 docker run --rm -it -v `pwd`:/cometbft cometbft/cometbft:build_c-amazonlinux 310 .PHONY: build_c-amazonlinux 311 312 # Run a 4-node testnet locally 313 localnet-start: localnet-stop build-docker-localnode 314 @if ! [ -f build/node0/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/cometbft:Z cometbft/localnode testnet --config /etc/cometbft/config-template.toml --o . --starting-ip-address 192.167.10.2; fi 315 docker-compose up 316 .PHONY: localnet-start 317 318 # Stop testnet 319 localnet-stop: 320 docker-compose down 321 .PHONY: localnet-stop 322 323 # Build hooks for dredd, to skip or add information on some steps 324 build-contract-tests-hooks: 325 ifeq ($(OS),Windows_NT) 326 go build -mod=readonly $(BUILD_FLAGS) -o build/contract_tests.exe ./cmd/contract_tests 327 else 328 go build -mod=readonly $(BUILD_FLAGS) -o build/contract_tests ./cmd/contract_tests 329 endif 330 .PHONY: build-contract-tests-hooks 331 332 # Run a nodejs tool to test endpoints against a localnet 333 # The command takes care of starting and stopping the network 334 # prerequisits: build-contract-tests-hooks build-linux 335 # the two build commands were not added to let this command run from generic containers or machines. 336 # The binaries should be built beforehand 337 contract-tests: 338 dredd 339 .PHONY: contract-tests