2018-01-05 22:35:57 -08:00
|
|
|
GOTOOLS = \
|
2018-02-27 03:59:50 -08:00
|
|
|
github.com/golang/dep/cmd/dep \
|
2018-01-08 16:41:23 -06:00
|
|
|
github.com/tendermint/glide \
|
2018-01-19 00:11:23 -05:00
|
|
|
# gopkg.in/alecthomas/gometalinter.v2
|
2018-01-05 22:35:57 -08:00
|
|
|
PACKAGES=$(shell go list ./... | grep -v '/vendor/')
|
|
|
|
BUILD_TAGS?=tendermint
|
2018-01-08 16:41:23 -06:00
|
|
|
BUILD_FLAGS = -ldflags "-X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse --short=8 HEAD`"
|
2017-12-04 17:35:42 -06:00
|
|
|
|
2018-01-19 00:11:23 -05:00
|
|
|
all: check build test install
|
2015-07-13 11:49:09 -07:00
|
|
|
|
2018-02-27 03:59:50 -08:00
|
|
|
check: check_tools ensure_deps
|
2017-12-23 02:23:05 -08:00
|
|
|
|
|
|
|
|
|
|
|
########################################
|
|
|
|
### Build
|
2014-12-28 16:26:53 -08:00
|
|
|
|
2017-01-04 00:32:39 +04:00
|
|
|
build:
|
2018-01-08 16:41:23 -06:00
|
|
|
go build $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' -o build/tendermint ./cmd/tendermint/
|
2015-04-21 19:51:23 -07:00
|
|
|
|
2017-01-04 00:32:39 +04:00
|
|
|
build_race:
|
2018-01-08 16:41:23 -06:00
|
|
|
go build -race $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' -o build/tendermint ./cmd/tendermint
|
|
|
|
|
|
|
|
install:
|
|
|
|
go install $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' ./cmd/tendermint
|
|
|
|
|
|
|
|
########################################
|
|
|
|
### Distribution
|
2014-12-28 17:10:03 -08:00
|
|
|
|
2017-01-23 13:45:14 +04:00
|
|
|
# dist builds binaries for all platforms and packages them for distribution
|
|
|
|
dist:
|
|
|
|
@BUILD_TAGS='$(BUILD_TAGS)' sh -c "'$(CURDIR)/scripts/dist.sh'"
|
|
|
|
|
2017-12-23 02:23:05 -08:00
|
|
|
########################################
|
|
|
|
### Tools & dependencies
|
|
|
|
|
|
|
|
check_tools:
|
2018-01-05 22:35:57 -08:00
|
|
|
@# https://stackoverflow.com/a/25668869
|
2018-01-08 16:41:23 -06:00
|
|
|
@echo "Found tools: $(foreach tool,$(notdir $(GOTOOLS)),\
|
2018-01-05 22:35:57 -08:00
|
|
|
$(if $(shell which $(tool)),$(tool),$(error "No $(tool) in PATH")))"
|
2017-12-23 02:23:05 -08:00
|
|
|
|
|
|
|
get_tools:
|
|
|
|
@echo "--> Installing tools"
|
|
|
|
go get -u -v $(GOTOOLS)
|
2018-01-19 00:11:23 -05:00
|
|
|
# @gometalinter.v2 --install
|
2017-12-23 02:23:05 -08:00
|
|
|
|
|
|
|
update_tools:
|
|
|
|
@echo "--> Updating tools"
|
|
|
|
@go get -u $(GOTOOLS)
|
|
|
|
|
2018-02-27 03:59:50 -08:00
|
|
|
#Run this from CI
|
2017-12-23 02:23:05 -08:00
|
|
|
get_vendor_deps:
|
|
|
|
@rm -rf vendor/
|
2018-02-27 03:59:50 -08:00
|
|
|
@echo "--> Running dep"
|
|
|
|
@dep ensure -vendor-only
|
|
|
|
|
|
|
|
|
|
|
|
#Run this locally.
|
|
|
|
ensure_deps:
|
|
|
|
@rm -rf vendor/
|
|
|
|
@echo "--> Running dep"
|
|
|
|
@dep ensure
|
2017-12-23 02:23:05 -08:00
|
|
|
|
|
|
|
draw_deps:
|
|
|
|
@# requires brew install graphviz or apt-get install graphviz
|
|
|
|
go get github.com/RobotsAndPencils/goviz
|
|
|
|
@goviz -i github.com/tendermint/tendermint/cmd/tendermint -d 3 | dot -Tpng -o dependency-graph.png
|
|
|
|
|
|
|
|
|
|
|
|
########################################
|
|
|
|
### Testing
|
|
|
|
|
2017-01-30 12:02:24 +04:00
|
|
|
test:
|
2017-01-22 18:03:20 +04:00
|
|
|
@echo "--> Running go test"
|
2017-02-22 20:01:32 +01:00
|
|
|
@go test $(PACKAGES)
|
2017-01-04 00:32:39 +04:00
|
|
|
|
2017-01-30 12:02:24 +04:00
|
|
|
test_race:
|
2017-01-22 18:03:20 +04:00
|
|
|
@echo "--> Running go test --race"
|
2017-02-22 20:01:32 +01:00
|
|
|
@go test -v -race $(PACKAGES)
|
2014-12-28 16:26:53 -08:00
|
|
|
|
2017-01-04 00:32:39 +04:00
|
|
|
test_integrations:
|
2017-01-22 18:03:20 +04:00
|
|
|
@bash ./test/test.sh
|
2016-07-23 12:48:30 -04:00
|
|
|
|
2017-12-04 17:37:32 -06:00
|
|
|
test_release:
|
2017-10-25 19:20:33 -07:00
|
|
|
@go test -tags release $(PACKAGES)
|
|
|
|
|
2017-01-30 12:02:24 +04:00
|
|
|
test100:
|
2017-01-22 18:03:20 +04:00
|
|
|
@for i in {1..100}; do make test; done
|
2016-04-29 15:32:50 -07:00
|
|
|
|
2017-12-08 18:36:58 +01:00
|
|
|
vagrant_test:
|
|
|
|
vagrant up
|
|
|
|
vagrant ssh -c 'make install'
|
|
|
|
vagrant ssh -c 'make test_race'
|
|
|
|
vagrant ssh -c 'make test_integrations'
|
|
|
|
|
2017-02-08 19:28:25 +01:00
|
|
|
|
2017-12-23 02:23:05 -08:00
|
|
|
########################################
|
2017-05-30 13:27:31 -04:00
|
|
|
### Formatting, linting, and vetting
|
|
|
|
|
2017-12-23 02:23:05 -08:00
|
|
|
fmt:
|
|
|
|
@go fmt ./...
|
2017-02-08 19:28:25 +01:00
|
|
|
|
2017-12-23 02:23:05 -08:00
|
|
|
metalinter:
|
|
|
|
@echo "--> Running linter"
|
2017-12-11 23:05:22 -06:00
|
|
|
gometalinter.v2 --vendor --deadline=600s --disable-all \
|
2017-09-21 14:13:13 -04:00
|
|
|
--enable=deadcode \
|
2017-12-10 17:44:22 +00:00
|
|
|
--enable=gosimple \
|
2017-09-21 14:13:13 -04:00
|
|
|
--enable=misspell \
|
|
|
|
--enable=safesql \
|
|
|
|
./...
|
2017-12-10 17:44:22 +00:00
|
|
|
#--enable=gas \
|
2017-10-26 19:24:18 -04:00
|
|
|
#--enable=maligned \
|
2017-09-21 14:13:13 -04:00
|
|
|
#--enable=dupl \
|
2017-10-14 14:38:47 -04:00
|
|
|
#--enable=errcheck \
|
2017-09-21 14:13:13 -04:00
|
|
|
#--enable=goconst \
|
|
|
|
#--enable=gocyclo \
|
2017-10-03 18:49:20 -04:00
|
|
|
#--enable=goimports \
|
2017-09-21 14:13:13 -04:00
|
|
|
#--enable=golint \ <== comments on anything exported
|
2017-10-03 19:11:55 -04:00
|
|
|
#--enable=gotype \
|
2017-10-28 11:07:59 -04:00
|
|
|
#--enable=ineffassign \
|
2017-09-21 14:13:13 -04:00
|
|
|
#--enable=interfacer \
|
|
|
|
#--enable=megacheck \
|
|
|
|
#--enable=staticcheck \
|
2017-11-09 13:59:35 -05:00
|
|
|
#--enable=structcheck \
|
2017-09-21 14:13:13 -04:00
|
|
|
#--enable=unconvert \
|
|
|
|
#--enable=unparam \
|
|
|
|
#--enable=unused \
|
2017-11-09 13:59:35 -05:00
|
|
|
#--enable=varcheck \
|
2017-09-21 14:13:13 -04:00
|
|
|
#--enable=vet \
|
|
|
|
#--enable=vetshadow \
|
2017-09-21 13:54:34 -04:00
|
|
|
|
2017-12-23 02:23:05 -08:00
|
|
|
metalinter_all:
|
|
|
|
@echo "--> Running linter (all)"
|
|
|
|
gometalinter.v2 --vendor --deadline=600s --enable-all --disable=lll ./...
|
|
|
|
|
|
|
|
|
|
|
|
# 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: check build build_race dist install check_tools get_tools update_tools get_vendor_deps draw_deps test test_race test_integrations test_release test100 vagrant_test fmt metalinter metalinter_all
|