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.

143 lines
3.8 KiB

7 years ago
9 years ago
7 years ago
7 years ago
7 years ago
  1. GOTOOLS = \
  2. github.com/golang/dep/cmd/dep \
  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 ensure_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. #Run this from CI
  36. get_vendor_deps:
  37. @rm -rf vendor/
  38. @echo "--> Running dep"
  39. @dep ensure -vendor-only
  40. #Run this locally.
  41. ensure_deps:
  42. @rm -rf vendor/
  43. @echo "--> Running dep"
  44. @dep ensure
  45. draw_deps:
  46. @# requires brew install graphviz or apt-get install graphviz
  47. go get github.com/RobotsAndPencils/goviz
  48. @goviz -i github.com/tendermint/tendermint/cmd/tendermint -d 3 | dot -Tpng -o dependency-graph.png
  49. get_deps_bin_size:
  50. @# Copy of build recipe with additional flags to perform binary size analysis
  51. $(eval $(shell go build -work -a $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' -o build/tendermint ./cmd/tendermint/ 2>&1))
  52. @find $(WORK) -type f -name "*.a" | xargs -I{} du -hxs "{}" | sort -rh | sed -e s:${WORK}/::g > deps_bin_size.log
  53. @echo "Results can be found here: $(CURDIR)/deps_bin_size.log"
  54. ########################################
  55. ### Testing
  56. test:
  57. @echo "--> Running go test"
  58. @go test $(PACKAGES)
  59. test_race:
  60. @echo "--> Running go test --race"
  61. @go test -v -race $(PACKAGES)
  62. test_integrations:
  63. @bash ./test/test.sh
  64. test_release:
  65. @go test -tags release $(PACKAGES)
  66. test100:
  67. @for i in {1..100}; do make test; done
  68. vagrant_test:
  69. vagrant up
  70. vagrant ssh -c 'make install'
  71. vagrant ssh -c 'make test_race'
  72. vagrant ssh -c 'make test_integrations'
  73. ########################################
  74. ### Formatting, linting, and vetting
  75. fmt:
  76. @go fmt ./...
  77. metalinter:
  78. @echo "--> Running linter"
  79. gometalinter.v2 --vendor --deadline=600s --disable-all \
  80. --enable=deadcode \
  81. --enable=gosimple \
  82. --enable=misspell \
  83. --enable=safesql \
  84. ./...
  85. #--enable=gas \
  86. #--enable=maligned \
  87. #--enable=dupl \
  88. #--enable=errcheck \
  89. #--enable=goconst \
  90. #--enable=gocyclo \
  91. #--enable=goimports \
  92. #--enable=golint \ <== comments on anything exported
  93. #--enable=gotype \
  94. #--enable=ineffassign \
  95. #--enable=interfacer \
  96. #--enable=megacheck \
  97. #--enable=staticcheck \
  98. #--enable=structcheck \
  99. #--enable=unconvert \
  100. #--enable=unparam \
  101. #--enable=unused \
  102. #--enable=varcheck \
  103. #--enable=vet \
  104. #--enable=vetshadow \
  105. metalinter_all:
  106. @echo "--> Running linter (all)"
  107. gometalinter.v2 --vendor --deadline=600s --enable-all --disable=lll ./...
  108. # To avoid unintended conflicts with file names, always add to .PHONY
  109. # unless there is a reason not to.
  110. # https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
  111. .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