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.

162 lines
4.5 KiB

7 years ago
8 years ago
7 years ago
7 years ago
9 years ago
9 years ago
7 years ago
7 years ago
8 years ago
7 years ago
7 years ago
  1. GOTOOLS = \
  2. github.com/mitchellh/gox \
  3. github.com/Masterminds/glide \
  4. gopkg.in/alecthomas/gometalinter.v2 \
  5. github.com/gogo/protobuf/protoc-gen-gogo \
  6. github.com/gogo/protobuf/gogoproto
  7. GOTOOLS_CHECK = gox glide gometalinter.v2 protoc protoc-gen-gogo
  8. PACKAGES=$(shell go list ./... | grep -v '/vendor/')
  9. INCLUDE = -I=. -I=${GOPATH}/src -I=${GOPATH}/src/github.com/gogo/protobuf/protobuf
  10. all: check get_vendor_deps protoc build test install metalinter
  11. check: check_tools
  12. ########################################
  13. ### Build
  14. protoc:
  15. ## If you get the following error,
  16. ## "error while loading shared libraries: libprotobuf.so.14: cannot open shared object file: No such file or directory"
  17. ## See https://stackoverflow.com/a/25518702
  18. protoc $(INCLUDE) --gogo_out=plugins=grpc:. types/*.proto
  19. @echo "--> adding nolint declarations to protobuf generated files"
  20. @awk '/package types/ { print "//nolint: gas"; print; next }1' types/types.pb.go > types/types.pb.go.new
  21. @mv types/types.pb.go.new types/types.pb.go
  22. build:
  23. @go build -i ./cmd/...
  24. dist:
  25. @bash scripts/dist.sh
  26. @bash scripts/publish.sh
  27. install:
  28. @go install ./cmd/...
  29. ########################################
  30. ### Tools & dependencies
  31. check_tools:
  32. @# https://stackoverflow.com/a/25668869
  33. @echo "Found tools: $(foreach tool,$(GOTOOLS_CHECK),\
  34. $(if $(shell which $(tool)),$(tool),$(error "No $(tool) in PATH")))"
  35. get_tools:
  36. @echo "--> Installing tools"
  37. go get -u -v $(GOTOOLS)
  38. @gometalinter.v2 --install
  39. get_protoc:
  40. @# https://github.com/google/protobuf/releases
  41. curl -L https://github.com/google/protobuf/releases/download/v3.4.1/protobuf-cpp-3.4.1.tar.gz | tar xvz && \
  42. cd protobuf-3.4.1 && \
  43. DIST_LANG=cpp ./configure && \
  44. make && \
  45. make install && \
  46. cd .. && \
  47. rm -rf protobuf-3.4.1
  48. update_tools:
  49. @echo "--> Updating tools"
  50. @go get -u $(GOTOOLS)
  51. get_vendor_deps:
  52. @rm -rf vendor/
  53. @echo "--> Running glide install"
  54. @glide install
  55. ########################################
  56. ### Testing
  57. test:
  58. @find . -path ./vendor -prune -o -name "*.sock" -exec rm {} \;
  59. @echo "==> Running go test"
  60. @go test $(PACKAGES)
  61. test_race:
  62. @find . -path ./vendor -prune -o -name "*.sock" -exec rm {} \;
  63. @echo "==> Running go test --race"
  64. @go test -v -race $(PACKAGES)
  65. test_integrations:
  66. @bash test.sh
  67. ########################################
  68. ### Formatting, linting, and vetting
  69. fmt:
  70. @go fmt ./...
  71. metalinter:
  72. @echo "==> Running linter"
  73. gometalinter.v2 --vendor --deadline=600s --disable-all \
  74. --enable=maligned \
  75. --enable=deadcode \
  76. --enable=goconst \
  77. --enable=goimports \
  78. --enable=gosimple \
  79. --enable=ineffassign \
  80. --enable=megacheck \
  81. --enable=misspell \
  82. --enable=staticcheck \
  83. --enable=safesql \
  84. --enable=structcheck \
  85. --enable=unconvert \
  86. --enable=unused \
  87. --enable=varcheck \
  88. --enable=vetshadow \
  89. ./...
  90. #--enable=gas \
  91. #--enable=dupl \
  92. #--enable=errcheck \
  93. #--enable=gocyclo \
  94. #--enable=golint \ <== comments on anything exported
  95. #--enable=gotype \
  96. #--enable=interfacer \
  97. #--enable=unparam \
  98. #--enable=vet \
  99. metalinter_all:
  100. protoc $(INCLUDE) --lint_out=. types/*.proto
  101. gometalinter.v2 --vendor --deadline=600s --enable-all --disable=lll ./...
  102. ########################################
  103. ### Docker
  104. DEVDOC_SAVE = docker commit `docker ps -a -n 1 -q` devdoc:local
  105. docker_build:
  106. docker build -t "tendermint/abci-dev" -f Dockerfile.develop .
  107. docker_run:
  108. docker run -it -v "$(CURDIR):/go/src/github.com/tendermint/abci" -w "/go/src/github.com/tendermint/abci" "tendermint/abci-dev" /bin/bash
  109. docker_run_rm:
  110. docker run -it --rm -v "$(CURDIR):/go/src/github.com/tendermint/abci" -w "/go/src/github.com/tendermint/abci" "tendermint/abci-dev" /bin/bash
  111. devdoc_init:
  112. docker run -it -v "$(CURDIR):/go/src/github.com/tendermint/abci" -w "/go/src/github.com/tendermint/abci" tendermint/devdoc echo
  113. # TODO make this safer
  114. $(call DEVDOC_SAVE)
  115. devdoc:
  116. docker run -it -v "$(CURDIR):/go/src/github.com/tendermint/abci" -w "/go/src/github.com/tendermint/abci" devdoc:local bash
  117. devdoc_save:
  118. # TODO make this safer
  119. $(call DEVDOC_SAVE)
  120. devdoc_clean:
  121. docker rmi $$(docker images -f "dangling=true" -q)
  122. # To avoid unintended conflicts with file names, always add to .PHONY
  123. # unless there is a reason not to.
  124. # https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
  125. .PHONY: check protoc build dist install check_tools get_tools get_protoc update_tools get_vendor_deps test test_race test_integrations fmt metalinter metalinter_all docker_build docker_run docker_run_rm devdoc_init devdoc devdoc_save devdoc_clean