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.

121 lines
3.1 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
  1. GOTOOLS = \
  2. github.com/Masterminds/glide \
  3. github.com/gogo/protobuf/protoc-gen-gogo \
  4. github.com/gogo/protobuf/gogoproto
  5. # github.com/alecthomas/gometalinter.v2 \
  6. GOTOOLS_CHECK = glide gometalinter.v2 protoc protoc-gen-gogo
  7. INCLUDE = -I=. -I=${GOPATH}/src -I=${GOPATH}/src/github.com/gogo/protobuf/protobuf
  8. all: check get_vendor_deps protoc 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) --gogo_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 glide install"
  49. @glide install
  50. ########################################
  51. ### Testing
  52. test:
  53. go test -tags gcc `glide novendor`
  54. test100:
  55. @for i in {1..100}; do make test; done
  56. ########################################
  57. ### Formatting, linting, and vetting
  58. fmt:
  59. @go fmt ./...
  60. metalinter:
  61. @echo "==> Running linter"
  62. gometalinter.v2 --vendor --deadline=600s --disable-all \
  63. --enable=deadcode \
  64. --enable=goconst \
  65. --enable=goimports \
  66. --enable=gosimple \
  67. --enable=ineffassign \
  68. --enable=megacheck \
  69. --enable=misspell \
  70. --enable=staticcheck \
  71. --enable=safesql \
  72. --enable=structcheck \
  73. --enable=unconvert \
  74. --enable=unused \
  75. --enable=varcheck \
  76. --enable=vetshadow \
  77. ./...
  78. #--enable=maligned \
  79. #--enable=gas \
  80. #--enable=aligncheck \
  81. #--enable=dupl \
  82. #--enable=errcheck \
  83. #--enable=gocyclo \
  84. #--enable=golint \ <== comments on anything exported
  85. #--enable=gotype \
  86. #--enable=interfacer \
  87. #--enable=unparam \
  88. #--enable=vet \
  89. metalinter_all:
  90. protoc $(INCLUDE) --lint_out=. types/*.proto
  91. gometalinter.v2 --vendor --deadline=600s --enable-all --disable=lll ./...
  92. # To avoid unintended conflicts with file names, always add to .PHONY
  93. # unless there is a reason not to.
  94. # https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
  95. .PHONY: check protoc build check_tools get_tools get_protoc update_tools get_vendor_deps test fmt metalinter metalinter_all