github.com/soomindae/tendermint@v0.0.5-0.20210528140126-84a0c70c8162/Makefile (about)

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