cosmos-sdk/Makefile

208 lines
6.6 KiB
Makefile
Raw Normal View History

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
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
########################################
### Build/Install
check-ledger:
ifeq ($(LEDGER_ENABLED),true)
ifndef GCC
$(error "gcc not installed for ledger support, please install or set LEDGER_ENABLED to false in the Makefile")
endif
else
TMP_BUILD_TAGS := $(BUILD_TAGS)
BUILD_TAGS = $(filter-out ledger, $(TMP_BUILD_TAGS))
endif
2017-08-30 11:22:17 -07:00
build: check-ledger
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
build-linux:
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build
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
2018-04-05 02:39:43 -07:00
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
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
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
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
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
install_cosmos-sdk-cli:
go install $(BUILD_FLAGS) ./cmd/cosmos-sdk-cli
2018-06-12 22:17:11 -07:00
install_debug:
go install $(BUILD_FLAGS) ./cmd/gaia/cmd/gaiadebug
dist:
@bash publish/dist.sh
@bash publish/publish.sh
2017-01-28 09:29:32 -08:00
########################################
### Tools & dependencies
check_tools:
2018-03-02 03:15:47 -08:00
cd tools && $(MAKE) check_tools
2016-02-05 23:16:33 -08:00
check_dev_tools:
cd tools && $(MAKE) check_dev_tools
update_tools:
2018-03-02 03:15:47 -08:00
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 "--> Running dep ensure"
2018-03-02 03:15:47 -08:00
@dep ensure -v
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-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
########################################
### Testing
test: test_unit
2017-06-15 08:16:00 -07:00
test_cli:
@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
2017-06-15 12:11:47 -07:00
test_unit:
@go test $(PACKAGES_NOSIMULATION)
2017-01-11 21:07:56 -08:00
test_race:
@go test -race $(PACKAGES_NOSIMULATION)
2018-07-11 10:43:25 -07:00
test_sim:
2018-07-17 22:37:38 -07:00
@echo "Running individual module simulations."
2018-07-17 16:27:51 -07:00
@go test $(PACKAGES_SIMTEST) -v
2018-07-18 00:54:41 -07:00
@echo "Running full Gaia simulation. This may take several minutes."
2018-07-18 23:40:46 -07:00
@echo "Pass the flag 'SimulationSeed' to run with a constant seed."
@echo "Pass the flag 'SimulationNumKeys' to run with the specified number of keys."
@echo "Pass the flag 'SimulationNumBlocks' to run with the specified number of blocks."
@echo "Pass the flag 'SimulationBlockSize' to run with the specified block size (operations per block)."
@go test ./cmd/gaia/app -run TestFullGaiaSimulation -SimulationEnabled=true -SimulationBlockSize=200 -v
2018-07-11 10:43:25 -07:00
2018-01-17 17:00:48 -08:00
test_cover:
2018-02-02 14:15:01 -08:00
@bash tests/test_cover.sh
2018-01-17 17:00:48 -08:00
2018-04-27 12:20:12 -07:00
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)
2018-04-27 12:20:12 -07:00
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)
2017-01-28 09:29: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)
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
# 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 update_tools update_dev_tools