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