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.

130 lines
3.3 KiB

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