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.

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