gitlab.com/gpdionisio/tendermint@v0.34.19-dev2/Makefile (about)

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