bitbucket.org/number571/tendermint@v0.8.14/Makefile (about)

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