2018-07-25 13:47:00 -07:00
|
|
|
PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation')
|
|
|
|
PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')
|
2018-09-19 09:03:04 -07:00
|
|
|
VERSION := $(shell git describe --tags --long | sed 's/v\(.*\)/\1/')
|
2018-07-13 19:17:53 -07:00
|
|
|
BUILD_TAGS = netgo ledger
|
2018-09-19 09:03:04 -07:00
|
|
|
BUILD_FLAGS = -tags "${BUILD_TAGS}" -ldflags "-X github.com/cosmos/cosmos-sdk/version.Version=${VERSION}"
|
2018-07-13 19:17:53 -07:00
|
|
|
GCC := $(shell command -v gcc 2> /dev/null)
|
|
|
|
LEDGER_ENABLED ?= true
|
2018-08-14 01:39:27 -07:00
|
|
|
UNAME_S := $(shell uname -s)
|
2018-07-16 12:48:16 -07:00
|
|
|
all: get_tools get_vendor_deps install install_examples install_cosmos-sdk-cli test_lint test
|
2017-10-23 13:22:30 -07:00
|
|
|
|
2018-01-17 17:00:48 -08:00
|
|
|
########################################
|
|
|
|
### CI
|
|
|
|
|
2018-05-02 20:07:05 -07:00
|
|
|
ci: get_tools get_vendor_deps install test_cover test_lint test
|
2018-01-17 17:00:48 -08:00
|
|
|
|
2018-01-16 11:23:32 -08:00
|
|
|
########################################
|
2018-07-13 19:17:53 -07:00
|
|
|
### Build/Install
|
|
|
|
|
2018-08-16 11:23:57 -07:00
|
|
|
check-ledger:
|
2018-07-13 19:17:53 -07:00
|
|
|
ifeq ($(LEDGER_ENABLED),true)
|
2018-08-14 01:39:27 -07:00
|
|
|
ifeq ($(UNAME_S),OpenBSD)
|
|
|
|
$(info "OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988)")
|
2018-08-21 05:22:41 -07:00
|
|
|
TMP_BUILD_TAGS := $(BUILD_TAGS)
|
|
|
|
BUILD_TAGS = $(filter-out ledger, $(TMP_BUILD_TAGS))
|
2018-08-14 01:39:27 -07:00
|
|
|
else
|
|
|
|
ifndef GCC
|
|
|
|
$(error "gcc not installed for ledger support, please install or set LEDGER_ENABLED to false in the Makefile")
|
|
|
|
endif
|
|
|
|
endif
|
2018-07-13 19:17:53 -07:00
|
|
|
else
|
2018-08-21 05:22:41 -07:00
|
|
|
TMP_BUILD_TAGS := $(BUILD_TAGS)
|
|
|
|
BUILD_TAGS = $(filter-out ledger, $(TMP_BUILD_TAGS))
|
2018-07-13 19:17:53 -07:00
|
|
|
endif
|
2017-08-30 11:22:17 -07:00
|
|
|
|
2018-09-13 04:56:23 -07:00
|
|
|
build: check-ledger update_gaia_lite_docs
|
2018-04-05 02:39:43 -07:00
|
|
|
ifeq ($(OS),Windows_NT)
|
2018-04-07 08:11:47 -07:00
|
|
|
go build $(BUILD_FLAGS) -o build/gaiad.exe ./cmd/gaia/cmd/gaiad
|
|
|
|
go build $(BUILD_FLAGS) -o build/gaiacli.exe ./cmd/gaia/cmd/gaiacli
|
2018-04-05 02:39:43 -07:00
|
|
|
else
|
2018-04-07 08:11:47 -07:00
|
|
|
go build $(BUILD_FLAGS) -o build/gaiad ./cmd/gaia/cmd/gaiad
|
|
|
|
go build $(BUILD_FLAGS) -o build/gaiacli ./cmd/gaia/cmd/gaiacli
|
2018-04-05 02:39:43 -07:00
|
|
|
endif
|
|
|
|
|
2018-07-13 19:17:53 -07:00
|
|
|
build-linux:
|
|
|
|
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build
|
|
|
|
|
2018-09-13 04:56:23 -07:00
|
|
|
update_gaia_lite_docs:
|
2018-10-03 23:34:39 -07:00
|
|
|
@statik -src=client/lcd/swagger-ui -dest=client/lcd -f
|
2018-09-13 04:56:23 -07:00
|
|
|
|
2018-07-16 11:45:56 -07:00
|
|
|
build_cosmos-sdk-cli:
|
|
|
|
ifeq ($(OS),Windows_NT)
|
2018-07-17 12:18:55 -07:00
|
|
|
go build $(BUILD_FLAGS) -o build/cosmos-sdk-cli.exe ./cmd/cosmos-sdk-cli
|
2018-07-16 11:45:56 -07:00
|
|
|
else
|
2018-07-17 12:18:55 -07:00
|
|
|
go build $(BUILD_FLAGS) -o build/cosmos-sdk-cli ./cmd/cosmos-sdk-cli
|
2018-07-16 11:45:56 -07:00
|
|
|
endif
|
|
|
|
|
2018-04-05 02:39:43 -07:00
|
|
|
build_examples:
|
2018-03-26 02:44:13 -07:00
|
|
|
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
|
2018-03-30 11:13:22 -07:00
|
|
|
go build $(BUILD_FLAGS) -o build/democoind.exe ./examples/democoin/cmd/democoind
|
|
|
|
go build $(BUILD_FLAGS) -o build/democli.exe ./examples/democoin/cmd/democli
|
2018-03-26 02:44:13 -07:00
|
|
|
else
|
2018-02-22 06:33:34 -08:00
|
|
|
go build $(BUILD_FLAGS) -o build/basecoind ./examples/basecoin/cmd/basecoind
|
|
|
|
go build $(BUILD_FLAGS) -o build/basecli ./examples/basecoin/cmd/basecli
|
2018-03-30 11:13:22 -07:00
|
|
|
go build $(BUILD_FLAGS) -o build/democoind ./examples/democoin/cmd/democoind
|
|
|
|
go build $(BUILD_FLAGS) -o build/democli ./examples/democoin/cmd/democli
|
2018-03-26 02:44:13 -07:00
|
|
|
endif
|
2017-08-17 15:40:28 -07:00
|
|
|
|
2018-09-13 04:56:23 -07:00
|
|
|
install: check-ledger update_gaia_lite_docs
|
2018-04-06 22:12:00 -07:00
|
|
|
go install $(BUILD_FLAGS) ./cmd/gaia/cmd/gaiad
|
|
|
|
go install $(BUILD_FLAGS) ./cmd/gaia/cmd/gaiacli
|
2018-04-05 02:39:43 -07:00
|
|
|
|
2018-06-22 11:01:44 -07:00
|
|
|
install_examples:
|
2018-03-31 09:13:34 -07:00
|
|
|
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
|
|
|
|
|
2018-07-16 11:45:56 -07:00
|
|
|
install_cosmos-sdk-cli:
|
2018-07-17 12:18:55 -07:00
|
|
|
go install $(BUILD_FLAGS) ./cmd/cosmos-sdk-cli
|
2018-07-16 11:45:56 -07:00
|
|
|
|
2018-06-12 22:17:11 -07:00
|
|
|
install_debug:
|
|
|
|
go install $(BUILD_FLAGS) ./cmd/gaia/cmd/gaiadebug
|
|
|
|
|
2018-01-16 11:23:32 -08:00
|
|
|
dist:
|
|
|
|
@bash publish/dist.sh
|
|
|
|
@bash publish/publish.sh
|
2017-01-28 09:29:32 -08:00
|
|
|
|
2018-01-16 11:23:32 -08:00
|
|
|
########################################
|
|
|
|
### Tools & dependencies
|
2017-08-30 11:42:24 -07:00
|
|
|
|
2018-01-16 11:23:32 -08:00
|
|
|
check_tools:
|
2018-03-02 03:15:47 -08:00
|
|
|
cd tools && $(MAKE) check_tools
|
2016-02-05 23:16:33 -08:00
|
|
|
|
2018-07-18 01:20:24 -07:00
|
|
|
check_dev_tools:
|
|
|
|
cd tools && $(MAKE) check_dev_tools
|
|
|
|
|
2018-02-03 03:32:13 -08:00
|
|
|
update_tools:
|
2018-03-02 03:15:47 -08:00
|
|
|
cd tools && $(MAKE) update_tools
|
2018-02-03 03:32:13 -08:00
|
|
|
|
2018-07-18 01:20:24 -07:00
|
|
|
update_dev_tools:
|
|
|
|
cd tools && $(MAKE) update_dev_tools
|
|
|
|
|
2018-07-20 15:12:21 -07:00
|
|
|
get_tools:
|
|
|
|
cd tools && $(MAKE) get_tools
|
|
|
|
|
2018-07-18 01:20:24 -07:00
|
|
|
get_dev_tools:
|
|
|
|
cd tools && $(MAKE) get_dev_tools
|
2018-01-16 11:23:32 -08:00
|
|
|
|
|
|
|
get_vendor_deps:
|
2018-08-28 09:53:56 -07:00
|
|
|
@echo "--> Generating vendor directory via dep ensure"
|
|
|
|
@rm -rf .vendor-new
|
|
|
|
@dep ensure -v -vendor-only
|
|
|
|
|
|
|
|
update_vendor_deps:
|
2018-02-25 06:30:24 -08:00
|
|
|
@echo "--> Running dep ensure"
|
2018-08-14 01:35:08 -07:00
|
|
|
@rm -rf .vendor-new
|
2018-03-02 03:15:47 -08:00
|
|
|
@dep ensure -v
|
2018-01-16 11:23:32 -08:00
|
|
|
|
|
|
|
draw_deps:
|
|
|
|
@# requires brew install graphviz or apt-get install graphviz
|
|
|
|
go get github.com/RobotsAndPencils/goviz
|
2018-06-01 22:50:41 -07:00
|
|
|
@goviz -i github.com/cosmos/cosmos-sdk/cmd/gaia/cmd/gaiad -d 2 | dot -Tpng -o dependency-graph.png
|
2017-06-01 20:51:35 -07:00
|
|
|
|
2018-01-16 11:23:32 -08:00
|
|
|
|
2018-01-20 15:03:35 -08:00
|
|
|
########################################
|
|
|
|
### Documentation
|
|
|
|
|
|
|
|
godocs:
|
|
|
|
@echo "--> Wait a few seconds and visit http://localhost:6060/pkg/github.com/cosmos/cosmos-sdk/types"
|
|
|
|
godoc -http=:6060
|
|
|
|
|
|
|
|
|
2018-01-16 11:23:32 -08:00
|
|
|
########################################
|
|
|
|
### Testing
|
|
|
|
|
2018-05-07 15:44:03 -07:00
|
|
|
test: test_unit
|
2017-06-15 08:16:00 -07:00
|
|
|
|
2018-06-22 11:01:44 -07:00
|
|
|
test_cli:
|
2018-07-25 13:47:00 -07:00
|
|
|
@go test -count 1 -p 1 `go list github.com/cosmos/cosmos-sdk/cmd/gaia/cli_test` -tags=cli_test
|
2018-02-20 13:13:27 -08:00
|
|
|
|
2018-08-22 10:17:15 -07:00
|
|
|
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
|
|
|
|
|
2017-06-15 12:11:47 -07:00
|
|
|
test_unit:
|
2018-09-19 09:03:04 -07:00
|
|
|
@VERSION=$(VERSION) go test $(PACKAGES_NOSIMULATION)
|
2017-01-11 21:07:56 -08:00
|
|
|
|
2018-06-11 18:12:37 -07:00
|
|
|
test_race:
|
2018-09-19 09:03:04 -07:00
|
|
|
@VERSION=$(VERSION) go test -race $(PACKAGES_NOSIMULATION)
|
2018-06-11 18:12:37 -07:00
|
|
|
|
2018-08-16 08:36:15 -07:00
|
|
|
test_sim_modules:
|
|
|
|
@echo "Running individual module simulations..."
|
|
|
|
@go test $(PACKAGES_SIMTEST)
|
|
|
|
|
2018-08-17 07:19:33 -07:00
|
|
|
test_sim_gaia_nondeterminism:
|
|
|
|
@echo "Running nondeterminism test..."
|
|
|
|
@go test ./cmd/gaia/app -run TestAppStateDeterminism -SimulationEnabled=true -v -timeout 10m
|
|
|
|
|
2018-08-16 08:36:15 -07:00
|
|
|
test_sim_gaia_fast:
|
2018-08-17 07:19:33 -07:00
|
|
|
@echo "Running quick Gaia simulation. This may take several minutes..."
|
2018-09-12 21:53:55 -07:00
|
|
|
@go test ./cmd/gaia/app -run TestFullGaiaSimulation -SimulationEnabled=true -SimulationNumBlocks=400 -SimulationBlockSize=200 -SimulationCommit=true -v -timeout 24h
|
2018-08-16 08:36:15 -07:00
|
|
|
|
2018-09-26 08:04:42 -07:00
|
|
|
test_sim_gaia_full:
|
|
|
|
@echo "Running full multi-seed Gaia simulation. This may take awhile!"
|
|
|
|
@sh scripts/multisim.sh
|
2018-07-11 10:43:25 -07:00
|
|
|
|
2018-09-01 19:04:44 -07:00
|
|
|
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
|
2018-07-11 10:43:25 -07:00
|
|
|
|
2018-01-17 17:00:48 -08:00
|
|
|
test_cover:
|
2018-09-19 09:03:04 -07:00
|
|
|
@export VERSION=$(VERSION); bash tests/test_cover.sh
|
2018-01-17 17:00:48 -08:00
|
|
|
|
2018-04-27 12:20:12 -07:00
|
|
|
test_lint:
|
2018-09-02 07:44:32 -07:00
|
|
|
gometalinter.v2 --config=tools/gometalinter.json ./...
|
2018-10-03 23:34:39 -07:00
|
|
|
!(gometalinter.v2 --exclude /usr/lib/go/src/ --exclude client/lcd/statik/statik.go --disable-all --enable='errcheck' --vendor ./... | grep -v "client/")
|
2018-06-27 17:32:06 -07:00
|
|
|
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s
|
2018-07-14 14:48:41 -07:00
|
|
|
dep status >> /dev/null
|
|
|
|
!(grep -n branch Gopkg.toml)
|
2018-04-27 12:20:12 -07:00
|
|
|
|
2018-06-29 00:37:16 -07:00
|
|
|
format:
|
2018-10-03 23:34:39 -07:00
|
|
|
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs gofmt -w -s
|
|
|
|
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs misspell -w
|
2018-06-29 00:37:16 -07:00
|
|
|
|
2018-01-16 11:23:32 -08:00
|
|
|
benchmark:
|
2018-07-25 13:47:00 -07:00
|
|
|
@go test -bench=. $(PACKAGES_NOSIMULATION)
|
2017-01-28 09:29:32 -08:00
|
|
|
|
2017-03-14 00:25:42 -07:00
|
|
|
|
2018-01-16 11:23:32 -08:00
|
|
|
########################################
|
|
|
|
### 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)
|
2017-06-02 09:06:48 -07:00
|
|
|
|
2018-01-16 11:23:32 -08:00
|
|
|
devdoc_update:
|
|
|
|
docker pull tendermint/devdoc
|
2017-03-14 00:25:42 -07:00
|
|
|
|
2017-06-19 05:16:38 -07:00
|
|
|
|
2018-05-23 09:38:01 -07:00
|
|
|
########################################
|
2018-06-05 12:17:04 -07:00
|
|
|
### Local validator nodes using docker and docker-compose
|
2018-05-23 09:38:01 -07:00
|
|
|
|
2018-06-05 12:17:04 -07:00
|
|
|
build-docker-gaiadnode:
|
|
|
|
$(MAKE) -C networks/local
|
|
|
|
|
|
|
|
# Run a 4-node testnet locally
|
|
|
|
localnet-start: localnet-stop
|
2018-08-21 20:28:16 -07:00
|
|
|
@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
|
2018-08-16 11:23:57 -07:00
|
|
|
docker-compose up -d
|
2018-06-05 12:17:04 -07:00
|
|
|
|
|
|
|
# Stop testnet
|
|
|
|
localnet-stop:
|
|
|
|
docker-compose down
|
|
|
|
|
2018-01-16 11:23:32 -08:00
|
|
|
# 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
|
2018-07-16 11:45:56 -07:00
|
|
|
.PHONY: build build_cosmos-sdk-cli build_examples install install_examples install_cosmos-sdk-cli install_debug dist \
|
2018-07-20 15:12:21 -07:00
|
|
|
check_tools check_dev_tools get_tools get_dev_tools get_vendor_deps draw_deps test test_cli test_unit \
|
2018-07-13 19:17:53 -07:00
|
|
|
test_cover test_lint benchmark devdoc_init devdoc devdoc_save devdoc_update \
|
2018-07-23 21:27:39 -07:00
|
|
|
build-linux build-docker-gaiadnode localnet-start localnet-stop \
|
2018-08-20 08:06:18 -07:00
|
|
|
format check-ledger test_sim_gaia_nondeterminism test_sim_modules test_sim_gaia_fast test_sim_gaia_slow update_tools update_dev_tools
|