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.

137 lines
3.6 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
7 years ago
  1. GOTOOLS = \
  2. github.com/golang/dep/cmd/dep \
  3. github.com/golang/protobuf/protoc-gen-go \
  4. github.com/square/certstrap
  5. # github.com/alecthomas/gometalinter.v2 \
  6. GOTOOLS_CHECK = dep gometalinter.v2 protoc protoc-gen-go
  7. INCLUDE = -I=. -I=${GOPATH}/src
  8. all: check get_vendor_deps protoc grpc_dbserver build test install metalinter
  9. check: check_tools
  10. ########################################
  11. ### Build
  12. protoc:
  13. ## If you get the following error,
  14. ## "error while loading shared libraries: libprotobuf.so.14: cannot open shared object file: No such file or directory"
  15. ## See https://stackoverflow.com/a/25518702
  16. protoc $(INCLUDE) --go_out=plugins=grpc:. common/*.proto
  17. @echo "--> adding nolint declarations to protobuf generated files"
  18. @awk '/package common/ { print "//nolint: gas"; print; next }1' common/types.pb.go > common/types.pb.go.new
  19. @mv common/types.pb.go.new common/types.pb.go
  20. build:
  21. # Nothing to build!
  22. install:
  23. # Nothing to install!
  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. get_protoc:
  35. @# https://github.com/google/protobuf/releases
  36. curl -L https://github.com/google/protobuf/releases/download/v3.4.1/protobuf-cpp-3.4.1.tar.gz | tar xvz && \
  37. cd protobuf-3.4.1 && \
  38. DIST_LANG=cpp ./configure && \
  39. make && \
  40. make install && \
  41. cd .. && \
  42. rm -rf protobuf-3.4.1
  43. update_tools:
  44. @echo "--> Updating tools"
  45. @go get -u $(GOTOOLS)
  46. get_vendor_deps:
  47. @rm -rf vendor/
  48. @echo "--> Running dep ensure"
  49. @dep ensure
  50. ########################################
  51. ### Testing
  52. gen_certs: clean_certs
  53. ## Generating certificates for TLS testing...
  54. certstrap init --common-name "tendermint.com" --passphrase ""
  55. certstrap request-cert -ip "::" --passphrase ""
  56. certstrap sign "::" --CA "tendermint.com" --passphrase ""
  57. mv out/::.crt out/::.key db/remotedb
  58. clean_certs:
  59. ## Cleaning TLS testing certificates...
  60. rm -rf out
  61. rm -f db/remotedb/::.crt db/remotedb/::.key
  62. test: gen_certs
  63. GOCACHE=off go test -tags gcc $(shell go list ./... | grep -v vendor)
  64. make clean_certs
  65. test100:
  66. @for i in {1..100}; do make test; done
  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=deadcode \
  75. --enable=goconst \
  76. --enable=goimports \
  77. --enable=gosimple \
  78. --enable=ineffassign \
  79. --enable=megacheck \
  80. --enable=misspell \
  81. --enable=staticcheck \
  82. --enable=safesql \
  83. --enable=structcheck \
  84. --enable=unconvert \
  85. --enable=unused \
  86. --enable=varcheck \
  87. --enable=vetshadow \
  88. ./...
  89. #--enable=maligned \
  90. #--enable=gas \
  91. #--enable=aligncheck \
  92. #--enable=dupl \
  93. #--enable=errcheck \
  94. #--enable=gocyclo \
  95. #--enable=golint \ <== comments on anything exported
  96. #--enable=gotype \
  97. #--enable=interfacer \
  98. #--enable=unparam \
  99. #--enable=vet \
  100. metalinter_all:
  101. protoc $(INCLUDE) --lint_out=. types/*.proto
  102. gometalinter.v2 --vendor --deadline=600s --enable-all --disable=lll ./...
  103. # To avoid unintended conflicts with file names, always add to .PHONY
  104. # unless there is a reason not to.
  105. # https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
  106. .PHONY: check protoc build check_tools get_tools get_protoc update_tools get_vendor_deps test fmt metalinter metalinter_all gen_certs clean_certs
  107. grpc_dbserver:
  108. protoc -I db/remotedb/proto/ db/remotedb/proto/defs.proto --go_out=plugins=grpc:db/remotedb/proto