github.com/franono/tendermint@v0.32.2-0.20200527150959-749313264ce9/Makefile (about) 1 PACKAGES=$(shell go list ./...) 2 OUTPUT?=build/tendermint 3 4 BUILD_TAGS?=tendermint 5 LD_FLAGS = -X github.com/franono/tendermint/version.GitCommit=`git rev-parse --short=8 HEAD` 6 BUILD_FLAGS = -mod=readonly -ldflags "$(LD_FLAGS)" 7 HTTPS_GIT := https://github.com/franono/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) check lint --error-format=json 74 .PHONY: proto-lint 75 76 proto-check-breaking: 77 @$(DOCKER_BUF) check breaking --against-input .git#branch=master 78 .PHONY: proto-check-breaking 79 80 proto-check-breaking-ci: 81 @$(DOCKER_BUF) check breaking --against-input $(HTTPS_GIT)#branch=master 82 .PHONY: proto-check-breaking-ci 83 84 ############################################################################### 85 ### Build ABCI ### 86 ############################################################################### 87 88 build_abci: 89 @go build -mod=readonly -i ./abci/cmd/... 90 .PHONY: build_abci 91 92 install_abci: 93 @go install -mod=readonly ./abci/cmd/... 94 .PHONY: install_abci 95 96 ############################################################################### 97 ### Distribution ### 98 ############################################################################### 99 100 # dist builds binaries for all platforms and packages them for distribution 101 # TODO add abci to these scripts 102 dist: 103 @BUILD_TAGS=$(BUILD_TAGS) sh -c "'$(CURDIR)/scripts/dist.sh'" 104 .PHONY: dist 105 106 go-mod-cache: go.sum 107 @echo "--> Download go modules to local cache" 108 @go mod download 109 .PHONY: go-mod-cache 110 111 go.sum: go.mod 112 @echo "--> Ensure dependencies have not been modified" 113 @go mod verify 114 @go mod tidy 115 116 draw_deps: 117 @# requires brew install graphviz or apt-get install graphviz 118 go get github.com/RobotsAndPencils/goviz 119 @goviz -i github.com/franono/tendermint/cmd/tendermint -d 3 | dot -Tpng -o dependency-graph.png 120 .PHONY: draw_deps 121 122 get_deps_bin_size: 123 @# Copy of build recipe with additional flags to perform binary size analysis 124 $(eval $(shell go build -work -a $(BUILD_FLAGS) -tags $(BUILD_TAGS) -o $(OUTPUT) ./cmd/tendermint/ 2>&1)) 125 @find $(WORK) -type f -name "*.a" | xargs -I{} du -hxs "{}" | sort -rh | sed -e s:${WORK}/::g > deps_bin_size.log 126 @echo "Results can be found here: $(CURDIR)/deps_bin_size.log" 127 .PHONY: get_deps_bin_size 128 129 ############################################################################### 130 ### Libs ### 131 ############################################################################### 132 133 # generates certificates for TLS testing in remotedb and RPC server 134 gen_certs: clean_certs 135 certstrap init --common-name "tendermint.com" --passphrase "" 136 certstrap request-cert --common-name "server" -ip "127.0.0.1" --passphrase "" 137 certstrap sign "server" --CA "tendermint.com" --passphrase "" 138 mv out/server.crt rpc/jsonrpc/server/test.crt 139 mv out/server.key rpc/jsonrpc/server/test.key 140 rm -rf out 141 .PHONY: gen_certs 142 143 # deletes generated certificates 144 clean_certs: 145 rm -f rpc/jsonrpc/server/test.crt 146 rm -f rpc/jsonrpc/server/test.key 147 .PHONY: clean_certs 148 149 ############################################################################### 150 ### Formatting, linting, and vetting ### 151 ############################################################################### 152 153 format: 154 find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs gofmt -w -s 155 find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs goimports -w -local github.com/franono/tendermint 156 .PHONY: format 157 158 lint: 159 @echo "--> Running linter" 160 @golangci-lint run 161 .PHONY: lint 162 163 DESTINATION = ./index.html.md 164 165 ############################################################################### 166 ### Documentation ### 167 ############################################################################### 168 169 build-docs: 170 cd docs && \ 171 while read p; do \ 172 (git checkout $${p} && npm install && VUEPRESS_BASE="/$${p}/" npm run build) ; \ 173 mkdir -p ~/output/$${p} ; \ 174 cp -r .vuepress/dist/* ~/output/$${p}/ ; \ 175 cp ~/output/$${p}/index.html ~/output ; \ 176 done < versions ; 177 .PHONY: build-docs 178 179 sync-docs: 180 cd ~/output && \ 181 echo "role_arn = ${DEPLOYMENT_ROLE_ARN}" >> /root/.aws/config ; \ 182 echo "CI job = ${CIRCLE_BUILD_URL}" >> version.html ; \ 183 aws s3 sync . s3://${WEBSITE_BUCKET} --profile terraform --delete ; \ 184 aws cloudfront create-invalidation --distribution-id ${CF_DISTRIBUTION_ID} --profile terraform --path "/*" ; 185 .PHONY: sync-docs 186 187 ############################################################################### 188 ### Docker image ### 189 ############################################################################### 190 191 build-docker: 192 cp $(OUTPUT) DOCKER/tendermint 193 docker build --label=tendermint --tag="franono/tendermint" DOCKER 194 rm -rf DOCKER/tendermint 195 .PHONY: build-docker 196 197 ############################################################################### 198 ### Local testnet using docker ### 199 ############################################################################### 200 201 # Build linux binary on other platforms 202 build-linux: tools 203 GOOS=linux GOARCH=amd64 $(MAKE) build 204 .PHONY: build-linux 205 206 build-docker-localnode: 207 @cd networks/local && make 208 .PHONY: build-docker-localnode 209 210 # Runs `make build TENDERMINT_BUILD_OPTIONS=cleveldb` from within an Amazon 211 # Linux (v2)-based Docker build container in order to build an Amazon 212 # Linux-compatible binary. Produces a compatible binary at ./build/tendermint 213 build_c-amazonlinux: 214 $(MAKE) -C ./DOCKER build_amazonlinux_buildimage 215 docker run --rm -it -v `pwd`:/tendermint franono/tendermint:build_c-amazonlinux 216 .PHONY: build_c-amazonlinux 217 218 # Run a 4-node testnet locally 219 localnet-start: localnet-stop build-docker-localnode 220 @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 221 docker-compose up 222 .PHONY: localnet-start 223 224 # Stop testnet 225 localnet-stop: 226 docker-compose down 227 .PHONY: localnet-stop 228 229 # Build hooks for dredd, to skip or add information on some steps 230 build-contract-tests-hooks: 231 ifeq ($(OS),Windows_NT) 232 go build -mod=readonly $(BUILD_FLAGS) -o build/contract_tests.exe ./cmd/contract_tests 233 else 234 go build -mod=readonly $(BUILD_FLAGS) -o build/contract_tests ./cmd/contract_tests 235 endif 236 .PHONY: build-contract-tests-hooks 237 238 # Run a nodejs tool to test endpoints against a localnet 239 # The command takes care of starting and stopping the network 240 # prerequisits: build-contract-tests-hooks build-linux 241 # the two build commands were not added to let this command run from generic containers or machines. 242 # The binaries should be built beforehand 243 contract-tests: 244 dredd 245 .PHONY: contract-tests