245 lines
8.5 KiB
Makefile
245 lines
8.5 KiB
Makefile
PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation')
|
|
PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')
|
|
COMMIT_HASH := $(shell git rev-parse --short HEAD)
|
|
BUILD_TAGS = netgo ledger
|
|
BUILD_FLAGS = -tags "${BUILD_TAGS}" -ldflags "-X github.com/cosmos/cosmos-sdk/version.GitCommit=${COMMIT_HASH}"
|
|
GCC := $(shell command -v gcc 2> /dev/null)
|
|
LEDGER_ENABLED ?= true
|
|
UNAME_S := $(shell uname -s)
|
|
all: get_tools get_vendor_deps install install_examples install_cosmos-sdk-cli test_lint test
|
|
|
|
########################################
|
|
### CI
|
|
|
|
ci: get_tools get_vendor_deps install test_cover test_lint test
|
|
|
|
########################################
|
|
### Build/Install
|
|
|
|
check-ledger:
|
|
ifeq ($(LEDGER_ENABLED),true)
|
|
ifeq ($(UNAME_S),OpenBSD)
|
|
$(info "OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988)")
|
|
TMP_BUILD_TAGS := $(BUILD_TAGS)
|
|
BUILD_TAGS = $(filter-out ledger, $(TMP_BUILD_TAGS))
|
|
else
|
|
ifndef GCC
|
|
$(error "gcc not installed for ledger support, please install or set LEDGER_ENABLED to false in the Makefile")
|
|
endif
|
|
endif
|
|
else
|
|
TMP_BUILD_TAGS := $(BUILD_TAGS)
|
|
BUILD_TAGS = $(filter-out ledger, $(TMP_BUILD_TAGS))
|
|
endif
|
|
|
|
build: check-ledger update_gaia_lite_docs
|
|
ifeq ($(OS),Windows_NT)
|
|
go build $(BUILD_FLAGS) -o build/gaiad.exe ./cmd/gaia/cmd/gaiad
|
|
go build $(BUILD_FLAGS) -o build/gaiacli.exe ./cmd/gaia/cmd/gaiacli
|
|
else
|
|
go build $(BUILD_FLAGS) -o build/gaiad ./cmd/gaia/cmd/gaiad
|
|
go build $(BUILD_FLAGS) -o build/gaiacli ./cmd/gaia/cmd/gaiacli
|
|
endif
|
|
|
|
build-linux:
|
|
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build
|
|
|
|
update_gaia_lite_docs:
|
|
@statik -src=client/lcd/swaggerui -dest=client/lcd
|
|
|
|
build_cosmos-sdk-cli:
|
|
ifeq ($(OS),Windows_NT)
|
|
go build $(BUILD_FLAGS) -o build/cosmos-sdk-cli.exe ./cmd/cosmos-sdk-cli
|
|
else
|
|
go build $(BUILD_FLAGS) -o build/cosmos-sdk-cli ./cmd/cosmos-sdk-cli
|
|
endif
|
|
|
|
build_examples:
|
|
ifeq ($(OS),Windows_NT)
|
|
go build $(BUILD_FLAGS) -o build/basecoind.exe ./examples/basecoin/cmd/basecoind
|
|
go build $(BUILD_FLAGS) -o build/basecli.exe ./examples/basecoin/cmd/basecli
|
|
go build $(BUILD_FLAGS) -o build/democoind.exe ./examples/democoin/cmd/democoind
|
|
go build $(BUILD_FLAGS) -o build/democli.exe ./examples/democoin/cmd/democli
|
|
else
|
|
go build $(BUILD_FLAGS) -o build/basecoind ./examples/basecoin/cmd/basecoind
|
|
go build $(BUILD_FLAGS) -o build/basecli ./examples/basecoin/cmd/basecli
|
|
go build $(BUILD_FLAGS) -o build/democoind ./examples/democoin/cmd/democoind
|
|
go build $(BUILD_FLAGS) -o build/democli ./examples/democoin/cmd/democli
|
|
endif
|
|
|
|
install: check-ledger update_gaia_lite_docs
|
|
go install $(BUILD_FLAGS) ./cmd/gaia/cmd/gaiad
|
|
go install $(BUILD_FLAGS) ./cmd/gaia/cmd/gaiacli
|
|
|
|
install_examples:
|
|
go install $(BUILD_FLAGS) ./examples/basecoin/cmd/basecoind
|
|
go install $(BUILD_FLAGS) ./examples/basecoin/cmd/basecli
|
|
go install $(BUILD_FLAGS) ./examples/democoin/cmd/democoind
|
|
go install $(BUILD_FLAGS) ./examples/democoin/cmd/democli
|
|
|
|
install_cosmos-sdk-cli:
|
|
go install $(BUILD_FLAGS) ./cmd/cosmos-sdk-cli
|
|
|
|
install_debug:
|
|
go install $(BUILD_FLAGS) ./cmd/gaia/cmd/gaiadebug
|
|
|
|
dist:
|
|
@bash publish/dist.sh
|
|
@bash publish/publish.sh
|
|
|
|
########################################
|
|
### Tools & dependencies
|
|
|
|
check_tools:
|
|
cd tools && $(MAKE) check_tools
|
|
|
|
check_dev_tools:
|
|
cd tools && $(MAKE) check_dev_tools
|
|
|
|
update_tools:
|
|
cd tools && $(MAKE) update_tools
|
|
|
|
update_dev_tools:
|
|
cd tools && $(MAKE) update_dev_tools
|
|
|
|
get_tools:
|
|
cd tools && $(MAKE) get_tools
|
|
|
|
get_dev_tools:
|
|
cd tools && $(MAKE) get_dev_tools
|
|
|
|
get_vendor_deps:
|
|
@echo "--> Generating vendor directory via dep ensure"
|
|
@rm -rf .vendor-new
|
|
@dep ensure -v -vendor-only
|
|
|
|
update_vendor_deps:
|
|
@echo "--> Running dep ensure"
|
|
@rm -rf .vendor-new
|
|
@dep ensure -v
|
|
|
|
draw_deps:
|
|
@# requires brew install graphviz or apt-get install graphviz
|
|
go get github.com/RobotsAndPencils/goviz
|
|
@goviz -i github.com/cosmos/cosmos-sdk/cmd/gaia/cmd/gaiad -d 2 | dot -Tpng -o dependency-graph.png
|
|
|
|
|
|
########################################
|
|
### Documentation
|
|
|
|
godocs:
|
|
@echo "--> Wait a few seconds and visit http://localhost:6060/pkg/github.com/cosmos/cosmos-sdk/types"
|
|
godoc -http=:6060
|
|
|
|
|
|
########################################
|
|
### Testing
|
|
|
|
test: test_unit
|
|
|
|
test_cli:
|
|
@go test -count 1 -p 1 `go list github.com/cosmos/cosmos-sdk/cmd/gaia/cli_test` -tags=cli_test
|
|
|
|
test_examples:
|
|
@go test -count 1 -p 1 `go list github.com/cosmos/cosmos-sdk/examples/basecoin/cli_test` -tags=cli_test
|
|
@go test -count 1 -p 1 `go list github.com/cosmos/cosmos-sdk/examples/democoin/cli_test` -tags=cli_test
|
|
|
|
test_unit:
|
|
@go test $(PACKAGES_NOSIMULATION)
|
|
|
|
test_race:
|
|
@go test -race $(PACKAGES_NOSIMULATION)
|
|
|
|
test_sim_modules:
|
|
@echo "Running individual module simulations..."
|
|
@go test $(PACKAGES_SIMTEST)
|
|
|
|
test_sim_gaia_nondeterminism:
|
|
@echo "Running nondeterminism test..."
|
|
@go test ./cmd/gaia/app -run TestAppStateDeterminism -SimulationEnabled=true -v -timeout 10m
|
|
|
|
test_sim_gaia_fast:
|
|
@echo "Running quick Gaia simulation. This may take several minutes..."
|
|
@go test ./cmd/gaia/app -run TestFullGaiaSimulation -SimulationEnabled=true -SimulationNumBlocks=400 -SimulationBlockSize=200 -SimulationCommit=true -v -timeout 24h
|
|
|
|
test_sim_gaia_slow:
|
|
@echo "Running full Gaia simulation. This may take awhile!"
|
|
@go test ./cmd/gaia/app -run TestFullGaiaSimulation -SimulationEnabled=true -SimulationNumBlocks=1000 -SimulationVerbose=true -SimulationCommit=true -v -timeout 24h
|
|
|
|
SIM_NUM_BLOCKS ?= 210
|
|
SIM_BLOCK_SIZE ?= 200
|
|
SIM_COMMIT ?= true
|
|
test_sim_gaia_benchmark:
|
|
@echo "Running Gaia benchmark for numBlocks=$(SIM_NUM_BLOCKS), blockSize=$(SIM_BLOCK_SIZE). This may take awhile!"
|
|
@go test -benchmem -run=^$$ github.com/cosmos/cosmos-sdk/cmd/gaia/app -bench ^BenchmarkFullGaiaSimulation$$ -SimulationEnabled=true -SimulationNumBlocks=$(SIM_NUM_BLOCKS) -SimulationBlockSize=$(SIM_BLOCK_SIZE) -SimulationCommit=$(SIM_COMMIT) -timeout 24h
|
|
|
|
test_sim_gaia_profile:
|
|
@echo "Running Gaia benchmark for numBlocks=$(SIM_NUM_BLOCKS), blockSize=$(SIM_BLOCK_SIZE). This may take awhile!"
|
|
@go test -benchmem -run=^$$ github.com/cosmos/cosmos-sdk/cmd/gaia/app -bench ^BenchmarkFullGaiaSimulation$$ -SimulationEnabled=true -SimulationNumBlocks=$(SIM_NUM_BLOCKS) -SimulationBlockSize=$(SIM_BLOCK_SIZE) -SimulationCommit=$(SIM_COMMIT) -timeout 24h -cpuprofile cpu.out -memprofile mem.out
|
|
|
|
test_cover:
|
|
@bash tests/test_cover.sh
|
|
|
|
test_lint:
|
|
gometalinter.v2 --config=tools/gometalinter.json ./...
|
|
!(gometalinter.v2 --disable-all --enable='errcheck' --vendor ./... | grep -v "client/")
|
|
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s
|
|
dep status >> /dev/null
|
|
!(grep -n branch Gopkg.toml)
|
|
|
|
format:
|
|
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -w -s
|
|
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs misspell -w
|
|
|
|
benchmark:
|
|
@go test -bench=. $(PACKAGES_NOSIMULATION)
|
|
|
|
|
|
########################################
|
|
### Devdoc
|
|
|
|
DEVDOC_SAVE = docker commit `docker ps -a -n 1 -q` devdoc:local
|
|
|
|
devdoc_init:
|
|
docker run -it -v "$(CURDIR):/go/src/github.com/cosmos/cosmos-sdk" -w "/go/src/github.com/cosmos/cosmos-sdk" tendermint/devdoc echo
|
|
# TODO make this safer
|
|
$(call DEVDOC_SAVE)
|
|
|
|
devdoc:
|
|
docker run -it -v "$(CURDIR):/go/src/github.com/cosmos/cosmos-sdk" -w "/go/src/github.com/cosmos/cosmos-sdk" devdoc:local bash
|
|
|
|
devdoc_save:
|
|
# TODO make this safer
|
|
$(call DEVDOC_SAVE)
|
|
|
|
devdoc_clean:
|
|
docker rmi -f $$(docker images -f "dangling=true" -q)
|
|
|
|
devdoc_update:
|
|
docker pull tendermint/devdoc
|
|
|
|
|
|
########################################
|
|
### Local validator nodes using docker and docker-compose
|
|
|
|
build-docker-gaiadnode:
|
|
$(MAKE) -C networks/local
|
|
|
|
# Run a 4-node testnet locally
|
|
localnet-start: localnet-stop
|
|
@if ! [ -f build/node0/gaiad/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/gaiad:Z tendermint/gaiadnode testnet --v 4 -o . --starting-ip-address 192.168.10.2 ; fi
|
|
docker-compose up -d
|
|
|
|
# Stop testnet
|
|
localnet-stop:
|
|
docker-compose down
|
|
|
|
# To avoid unintended conflicts with file names, always add to .PHONY
|
|
# unless there is a reason not to.
|
|
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
|
|
.PHONY: build build_cosmos-sdk-cli build_examples install install_examples install_cosmos-sdk-cli install_debug dist \
|
|
check_tools check_dev_tools get_tools get_dev_tools get_vendor_deps draw_deps test test_cli test_unit \
|
|
test_cover test_lint benchmark devdoc_init devdoc devdoc_save devdoc_update \
|
|
build-linux build-docker-gaiadnode localnet-start localnet-stop \
|
|
format check-ledger test_sim_gaia_nondeterminism test_sim_modules test_sim_gaia_fast test_sim_gaia_slow update_tools update_dev_tools
|