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.

138 lines
3.7 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. GOTOOLS = \
  2. github.com/golang/dep/cmd/dep \
  3. github.com/gogo/protobuf/protoc-gen-gogo \
  4. github.com/gogo/protobuf/gogoproto \
  5. github.com/square/certstrap
  6. # github.com/alecthomas/gometalinter.v2 \
  7. GOTOOLS_CHECK = dep gometalinter.v2 protoc protoc-gen-gogo
  8. INCLUDE = -I=. -I=${GOPATH}/src -I=${GOPATH}/src/github.com/gogo/protobuf/protobuf
  9. all: check get_vendor_deps protoc grpc_dbserver build test install metalinter
  10. check: check_tools
  11. ########################################
  12. ### Build
  13. protoc:
  14. ## If you get the following error,
  15. ## "error while loading shared libraries: libprotobuf.so.14: cannot open shared object file: No such file or directory"
  16. ## See https://stackoverflow.com/a/25518702
  17. protoc $(INCLUDE) --gogo_out=plugins=grpc:. common/*.proto
  18. @echo "--> adding nolint declarations to protobuf generated files"
  19. @awk '/package common/ { print "//nolint: gas"; print; next }1' common/types.pb.go > common/types.pb.go.new
  20. @mv common/types.pb.go.new common/types.pb.go
  21. build:
  22. # Nothing to build!
  23. install:
  24. # Nothing to install!
  25. ########################################
  26. ### Tools & dependencies
  27. check_tools:
  28. @# https://stackoverflow.com/a/25668869
  29. @echo "Found tools: $(foreach tool,$(GOTOOLS_CHECK),\
  30. $(if $(shell which $(tool)),$(tool),$(error "No $(tool) in PATH")))"
  31. get_tools:
  32. @echo "--> Installing tools"
  33. go get -u -v $(GOTOOLS)
  34. # @gometalinter.v2 --install
  35. get_protoc:
  36. @# https://github.com/google/protobuf/releases
  37. curl -L https://github.com/google/protobuf/releases/download/v3.4.1/protobuf-cpp-3.4.1.tar.gz | tar xvz && \
  38. cd protobuf-3.4.1 && \
  39. DIST_LANG=cpp ./configure && \
  40. make && \
  41. make install && \
  42. cd .. && \
  43. rm -rf protobuf-3.4.1
  44. update_tools:
  45. @echo "--> Updating tools"
  46. @go get -u $(GOTOOLS)
  47. get_vendor_deps:
  48. @rm -rf vendor/
  49. @echo "--> Running dep ensure"
  50. @dep ensure
  51. ########################################
  52. ### Testing
  53. gen_certs: clean_certs
  54. ## Generating certificates for TLS testing...
  55. certstrap init --common-name "tendermint.com" --passphrase ""
  56. certstrap request-cert -ip "::" --passphrase ""
  57. certstrap sign "::" --CA "tendermint.com" --passphrase ""
  58. mv out/::.crt out/::.key remotedb
  59. clean_certs:
  60. ## Cleaning TLS testing certificates...
  61. rm -rf out
  62. rm -f remotedb/::.crt remotedb/::.key
  63. test: gen_certs
  64. go test -tags gcc $(shell go list ./... | grep -v vendor)
  65. make clean_certs
  66. test100:
  67. @for i in {1..100}; do make test; done
  68. ########################################
  69. ### Formatting, linting, and vetting
  70. fmt:
  71. @go fmt ./...
  72. metalinter:
  73. @echo "==> Running linter"
  74. gometalinter.v2 --vendor --deadline=600s --disable-all \
  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=maligned \
  91. #--enable=gas \
  92. #--enable=aligncheck \
  93. #--enable=dupl \
  94. #--enable=errcheck \
  95. #--enable=gocyclo \
  96. #--enable=golint \ <== comments on anything exported
  97. #--enable=gotype \
  98. #--enable=interfacer \
  99. #--enable=unparam \
  100. #--enable=vet \
  101. metalinter_all:
  102. protoc $(INCLUDE) --lint_out=. types/*.proto
  103. gometalinter.v2 --vendor --deadline=600s --enable-all --disable=lll ./...
  104. # To avoid unintended conflicts with file names, always add to .PHONY
  105. # unless there is a reason not to.
  106. # https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
  107. .PHONY: check protoc build check_tools get_tools get_protoc update_tools get_vendor_deps test fmt metalinter metalinter_all gen_certs clean_certs
  108. grpc_dbserver:
  109. protoc -I proto/ proto/defs.proto --go_out=plugins=grpc:proto