tendermint/Makefile

144 lines
3.8 KiB
Makefile
Raw Normal View History

GOTOOLS = \
github.com/golang/dep/cmd/dep \
2018-01-18 21:11:23 -08:00
# gopkg.in/alecthomas/gometalinter.v2
PACKAGES=$(shell go list ./... | grep -v '/vendor/')
BUILD_TAGS?=tendermint
BUILD_FLAGS = -ldflags "-X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse --short=8 HEAD`"
2018-01-18 21:11:23 -08:00
all: check build test install
2015-07-13 11:49:09 -07:00
check: check_tools ensure_deps
2017-12-23 02:23:05 -08:00
########################################
### Build
2014-12-28 16:26:53 -08:00
build:
go build $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' -o build/tendermint ./cmd/tendermint/
build_race:
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
# 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:
@# https://stackoverflow.com/a/25668869
@echo "Found tools: $(foreach tool,$(notdir $(GOTOOLS)),\
$(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-18 21:11:23 -08:00
# @gometalinter.v2 --install
2017-12-23 02:23:05 -08:00
update_tools:
@echo "--> Updating tools"
@go get -u $(GOTOOLS)
#Run this from CI
2017-12-23 02:23:05 -08:00
get_vendor_deps:
@rm -rf vendor/
@echo "--> Running dep"
@dep ensure -vendor-only
#Run this locally.
ensure_deps:
@rm -rf vendor/
@echo "--> Running dep"
2018-02-27 05:20:56 -08:00
@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
get_deps_bin_size:
@# Copy of build recipe with additional flags to perform binary size analysis
$(eval $(shell go build -work -a $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' -o build/tendermint ./cmd/tendermint/ 2>&1))
@find $(WORK) -type f -name "*.a" | xargs -I{} du -hxs "{}" | sort -rh | sed -e s:${WORK}/::g > deps_bin_size.log
@echo "Results can be found here: $(CURDIR)/deps_bin_size.log"
2017-12-23 02:23:05 -08:00
########################################
### Testing
test:
@echo "--> Running go test"
@go test $(PACKAGES)
test_race:
@echo "--> Running go test --race"
@go test -v -race $(PACKAGES)
2014-12-28 16:26:53 -08:00
test_integrations:
@bash ./test/test.sh
2016-07-23 09:48:30 -07:00
2017-12-04 15:37:32 -08:00
test_release:
@go test -tags release $(PACKAGES)
test100:
@for i in {1..100}; do make test; done
2016-04-29 15:32:50 -07:00
vagrant_test:
vagrant up
vagrant ssh -c 'make install'
vagrant ssh -c 'make test_race'
vagrant ssh -c 'make test_integrations'
2017-12-23 02:23:05 -08:00
########################################
### Formatting, linting, and vetting
2017-12-23 02:23:05 -08:00
fmt:
@go fmt ./...
2017-12-23 02:23:05 -08:00
metalinter:
@echo "--> Running linter"
gometalinter.v2 --vendor --deadline=600s --disable-all \
--enable=deadcode \
--enable=gosimple \
--enable=misspell \
--enable=safesql \
./...
#--enable=gas \
2017-10-26 16:24:18 -07:00
#--enable=maligned \
#--enable=dupl \
2017-10-14 11:38:47 -07:00
#--enable=errcheck \
#--enable=goconst \
#--enable=gocyclo \
2017-10-03 15:49:20 -07:00
#--enable=goimports \
#--enable=golint \ <== comments on anything exported
2017-10-03 16:11:55 -07:00
#--enable=gotype \
2017-10-28 08:07:59 -07:00
#--enable=ineffassign \
#--enable=interfacer \
#--enable=megacheck \
#--enable=staticcheck \
2017-11-09 10:59:35 -08:00
#--enable=structcheck \
#--enable=unconvert \
#--enable=unparam \
#--enable=unused \
2017-11-09 10:59:35 -08:00
#--enable=varcheck \
#--enable=vet \
#--enable=vetshadow \
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 get_deps_bin_size test test_race test_integrations test_release test100 vagrant_test fmt metalinter metalinter_all