github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/tendermint/Makefile (about) 1 PACKAGES=$(shell go list ./...) 2 OUTPUT?=build/tendermint 3 4 BUILD_TAGS?=tendermint 5 LD_FLAGS = -X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse --short=8 HEAD` 6 BUILD_FLAGS = -mod=readonly -ldflags "$(LD_FLAGS)" 7 HTTPS_GIT := https://github.com/FiboChain/tendermint.git 8 DOCKER_BUF := docker run -v $(shell pwd):/workspace --workdir /workspace bufbuild/buf 9 CGO_ENABLED ?= 0 10 11 # handle nostrip 12 ifeq (,$(findstring nostrip,$(TENDERMINT_BUILD_OPTIONS))) 13 BUILD_FLAGS += -trimpath 14 LD_FLAGS += -s -w 15 endif 16 17 # handle race 18 ifeq (race,$(findstring race,$(TENDERMINT_BUILD_OPTIONS))) 19 CGO_ENABLED=1 20 BUILD_FLAGS += -race 21 endif 22 23 # handle cleveldb 24 ifeq (cleveldb,$(findstring cleveldb,$(TENDERMINT_BUILD_OPTIONS))) 25 CGO_ENABLED=1 26 BUILD_TAGS += cleveldb 27 endif 28 29 # allow users to pass additional flags via the conventional LDFLAGS variable 30 LD_FLAGS += $(LDFLAGS) 31 32 all: check build test install 33 .PHONY: all 34 35 # The below include contains the tools. 36 include tools.mk 37 include tests.mk 38 39 ############################################################################### 40 ### Build Tendermint ### 41 ############################################################################### 42 43 build: 44 CGO_ENABLED=$(CGO_ENABLED) go build $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' -o $(OUTPUT) ./cmd/tendermint/ 45 .PHONY: build 46 47 install: 48 CGO_ENABLED=$(CGO_ENABLED) go install $(BUILD_FLAGS) -tags $(BUILD_TAGS) ./cmd/tendermint 49 .PHONY: install 50 51 ############################################################################### 52 ### Protobuf ### 53 ############################################################################### 54 55 proto-all: proto-gen proto-lint proto-check-breaking 56 .PHONY: proto-all 57 58 proto-gen: 59 ## If you get the following error, 60 ## "error while loading shared libraries: libprotobuf.so.14: cannot open shared object file: No such file or directory" 61 ## See https://stackoverflow.com/a/25518702 62 ## Note the $< here is substituted for the %.proto 63 ## Note the $@ here is substituted for the %.pb.go 64 @sh scripts/protocgen.sh 65 .PHONY: proto-gen 66 67 proto-gen-docker: 68 @echo "Generating Protobuf files" 69 @docker run -v $(shell pwd):/workspace --workdir /workspace tendermintdev/docker-build-proto sh ./scripts/protocgen.sh 70 .PHONY: proto-gen-docker 71 72 proto-lint: 73 @$(DOCKER_BUF) lint --error-format=json 74 .PHONY: proto-lint 75 76 proto-check-breaking: 77 78 @$(DOCKER_BUF) breaking --against .git#branch=main 79 .PHONY: proto-check-breaking 80 81 proto-check-breaking-ci: 82 @$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=main 83 84 .PHONY: proto-check-breaking-ci 85 86 ############################################################################### 87 ### Build ABCI ### 88 ############################################################################### 89 90 build_abci: 91 @go build -mod=readonly -i ./abci/cmd/... 92 .PHONY: build_abci 93 94 install_abci: 95 @go install -mod=readonly ./abci/cmd/... 96 .PHONY: install_abci 97 98 ############################################################################### 99 ### Distribution ### 100 ############################################################################### 101 102 # dist builds binaries for all platforms and packages them for distribution 103 # TODO add abci to these scripts 104 dist: 105 @BUILD_TAGS=$(BUILD_TAGS) sh -c "'$(CURDIR)/scripts/dist.sh'" 106 .PHONY: dist 107 108 go-mod-cache: go.sum 109 @echo "--> Download go modules to local cache" 110 @go mod download 111 .PHONY: go-mod-cache 112 113 go.sum: go.mod 114 @echo "--> Ensure dependencies have not been modified" 115 @go mod verify 116 @go mod tidy 117 118 draw_deps: 119 @# requires brew install graphviz or apt-get install graphviz 120 go get github.com/RobotsAndPencils/goviz 121 @goviz -i github.com/tendermint/tendermint/cmd/tendermint -d 3 | dot -Tpng -o dependency-graph.png 122 .PHONY: draw_deps 123 124 get_deps_bin_size: 125 @# Copy of build recipe with additional flags to perform binary size analysis 126 $(eval $(shell go build -work -a $(BUILD_FLAGS) -tags $(BUILD_TAGS) -o $(OUTPUT) ./cmd/tendermint/ 2>&1)) 127 @find $(WORK) -type f -name "*.a" | xargs -I{} du -hxs "{}" | sort -rh | sed -e s:${WORK}/::g > deps_bin_size.log 128 @echo "Results can be found here: $(CURDIR)/deps_bin_size.log" 129 .PHONY: get_deps_bin_size 130 131 ############################################################################### 132 ### Libs ### 133 ############################################################################### 134 135 # generates certificates for TLS testing in remotedb and RPC server 136 gen_certs: clean_certs 137 certstrap init --common-name "tendermint.com" --passphrase "" 138 certstrap request-cert --common-name "server" -ip "127.0.0.1" --passphrase "" 139 certstrap sign "server" --CA "tendermint.com" --passphrase "" 140 mv out/server.crt rpc/jsonrpc/server/test.crt 141 mv out/server.key rpc/jsonrpc/server/test.key 142 rm -rf out 143 .PHONY: gen_certs 144 145 # deletes generated certificates 146 clean_certs: 147 rm -f rpc/jsonrpc/server/test.crt 148 rm -f rpc/jsonrpc/server/test.key 149 .PHONY: clean_certs 150 151 ############################################################################### 152 ### Formatting, linting, and vetting ### 153 ############################################################################### 154 155 format: 156 find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs gofmt -w -s 157 find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs goimports -w -local github.com/tendermint/tendermint 158 .PHONY: format 159 160 lint: 161 @echo "--> Running linter" 162 @golangci-lint run 163 .PHONY: lint 164 165 DESTINATION = ./index.html.md 166 167 ############################################################################### 168 ### Documentation ### 169 ############################################################################### 170 171 build-docs: 172 cd docs && \ 173 while read p; do \ 174 (git checkout $${p} && npm install && VUEPRESS_BASE="/$${p}/" npm run build) ; \ 175 mkdir -p ~/output/$${p} ; \ 176 cp -r .vuepress/dist/* ~/output/$${p}/ ; \ 177 cp ~/output/$${p}/index.html ~/output ; \ 178 done < versions ; 179 .PHONY: build-docs 180 181 sync-docs: 182 cd ~/output && \ 183 echo "role_arn = ${DEPLOYMENT_ROLE_ARN}" >> /root/.aws/config ; \ 184 echo "CI job = ${CIRCLE_BUILD_URL}" >> version.html ; \ 185 aws s3 sync . s3://${WEBSITE_BUCKET} --profile terraform --delete ; \ 186 aws cloudfront create-invalidation --distribution-id ${CF_DISTRIBUTION_ID} --profile terraform --path "/*" ; 187 .PHONY: sync-docs 188 189 ############################################################################### 190 ### Docker image ### 191 ############################################################################### 192 193 build-docker: 194 cp $(OUTPUT) DOCKER/tendermint 195 docker build --label=tendermint --tag="tendermint/tendermint" DOCKER 196 rm -rf DOCKER/tendermint 197 .PHONY: build-docker 198 199 ############################################################################### 200 ### Local testnet using docker ### 201 ############################################################################### 202 203 # Build linux binary on other platforms 204 build-linux: tools 205 GOOS=linux GOARCH=amd64 $(MAKE) build 206 .PHONY: build-linux 207 208 build-docker-localnode: 209 @cd networks/local && make 210 .PHONY: build-docker-localnode 211 212 # Runs `make build TENDERMINT_BUILD_OPTIONS=cleveldb` from within an Amazon 213 # Linux (v2)-based Docker build container in order to build an Amazon 214 # Linux-compatible binary. Produces a compatible binary at ./build/tendermint 215 build_c-amazonlinux: 216 $(MAKE) -C ./DOCKER build_amazonlinux_buildimage 217 docker run --rm -it -v `pwd`:/tendermint tendermint/tendermint:build_c-amazonlinux 218 .PHONY: build_c-amazonlinux 219 220 # Run a 4-node testnet locally 221 localnet-start: localnet-stop build-docker-localnode 222 @if ! [ -f build/node0/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/tendermint:Z tendermint/localnode testnet --config /etc/tendermint/config-template.toml --v 4 --o . --populate-persistent-peers --starting-ip-address 192.167.10.2; fi 223 docker-compose up 224 .PHONY: localnet-start 225 226 # Stop testnet 227 localnet-stop: 228 docker-compose down 229 .PHONY: localnet-stop 230 231 # Build hooks for dredd, to skip or add information on some steps 232 build-contract-tests-hooks: 233 ifeq ($(OS),Windows_NT) 234 go build -mod=readonly $(BUILD_FLAGS) -o build/contract_tests.exe ./cmd/contract_tests 235 else 236 go build -mod=readonly $(BUILD_FLAGS) -o build/contract_tests ./cmd/contract_tests 237 endif 238 .PHONY: build-contract-tests-hooks 239 240 # Run a nodejs tool to test endpoints against a localnet 241 # The command takes care of starting and stopping the network 242 # prerequisits: build-contract-tests-hooks build-linux 243 # the two build commands were not added to let this command run from generic containers or machines. 244 # The binaries should be built beforehand 245 contract-tests: 246 dredd 247 .PHONY: contract-tests