You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
3.3 KiB

9 years ago
7 years ago
7 years ago
7 years ago
  1. GOTOOLS = \
  2. github.com/mitchellh/gox \
  3. github.com/Masterminds/glide \
  4. github.com/tcnksm/ghr \
  5. gopkg.in/alecthomas/gometalinter.v2
  6. GOTOOLS_CHECK = gox glide ghr gometalinter.v2
  7. PACKAGES=$(shell go list ./... | grep -v '/vendor/')
  8. BUILD_TAGS?=tendermint
  9. TMHOME = $${TMHOME:-$$HOME/.tendermint}
  10. BUILD_FLAGS = -ldflags "-X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse --short HEAD`"
  11. all: check build test install metalinter
  12. check: check_tools get_vendor_deps
  13. ########################################
  14. ### Build
  15. build:
  16. go build $(BUILD_FLAGS) -o build/tendermint ./cmd/tendermint/
  17. build_race:
  18. go build -race $(BUILD_FLAGS) -o build/tendermint ./cmd/tendermint
  19. # dist builds binaries for all platforms and packages them for distribution
  20. dist:
  21. @BUILD_TAGS='$(BUILD_TAGS)' sh -c "'$(CURDIR)/scripts/dist.sh'"
  22. install:
  23. go install $(BUILD_FLAGS) ./cmd/tendermint
  24. ########################################
  25. ### Tools & dependencies
  26. check_tools:
  27. @# https://stackoverflow.com/a/25668869
  28. @echo "Found tools: $(foreach tool,$(GOTOOLS_CHECK),\
  29. $(if $(shell which $(tool)),$(tool),$(error "No $(tool) in PATH")))"
  30. get_tools:
  31. @echo "--> Installing tools"
  32. go get -u -v $(GOTOOLS)
  33. @gometalinter.v2 --install
  34. update_tools:
  35. @echo "--> Updating tools"
  36. @go get -u $(GOTOOLS)
  37. get_vendor_deps:
  38. @rm -rf vendor/
  39. @echo "--> Running glide install"
  40. @glide install
  41. draw_deps:
  42. @# requires brew install graphviz or apt-get install graphviz
  43. go get github.com/RobotsAndPencils/goviz
  44. @goviz -i github.com/tendermint/tendermint/cmd/tendermint -d 3 | dot -Tpng -o dependency-graph.png
  45. ########################################
  46. ### Testing
  47. test:
  48. @echo "--> Running go test"
  49. @go test $(PACKAGES)
  50. test_race:
  51. @echo "--> Running go test --race"
  52. @go test -v -race $(PACKAGES)
  53. test_integrations:
  54. @bash ./test/test.sh
  55. test_release:
  56. @go test -tags release $(PACKAGES)
  57. test100:
  58. @for i in {1..100}; do make test; done
  59. vagrant_test:
  60. vagrant up
  61. vagrant ssh -c 'make install'
  62. vagrant ssh -c 'make test_race'
  63. vagrant ssh -c 'make test_integrations'
  64. ########################################
  65. ### Formatting, linting, and vetting
  66. fmt:
  67. @go fmt ./...
  68. metalinter:
  69. @echo "--> Running linter"
  70. gometalinter.v2 --vendor --deadline=600s --disable-all \
  71. --enable=deadcode \
  72. --enable=gosimple \
  73. --enable=misspell \
  74. --enable=safesql \
  75. ./...
  76. #--enable=gas \
  77. #--enable=maligned \
  78. #--enable=dupl \
  79. #--enable=errcheck \
  80. #--enable=goconst \
  81. #--enable=gocyclo \
  82. #--enable=goimports \
  83. #--enable=golint \ <== comments on anything exported
  84. #--enable=gotype \
  85. #--enable=ineffassign \
  86. #--enable=interfacer \
  87. #--enable=megacheck \
  88. #--enable=staticcheck \
  89. #--enable=structcheck \
  90. #--enable=unconvert \
  91. #--enable=unparam \
  92. #--enable=unused \
  93. #--enable=varcheck \
  94. #--enable=vet \
  95. #--enable=vetshadow \
  96. metalinter_all:
  97. @echo "--> Running linter (all)"
  98. gometalinter.v2 --vendor --deadline=600s --enable-all --disable=lll ./...
  99. # To avoid unintended conflicts with file names, always add to .PHONY
  100. # unless there is a reason not to.
  101. # https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
  102. .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