github.com/tendermint/tmlibs@v0.9.0/Makefile (about) 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 7 GOTOOLS_CHECK = dep gometalinter.v2 protoc protoc-gen-go 8 INCLUDE = -I=. -I=${GOPATH}/src 9 10 all: check get_vendor_deps protoc grpc_dbserver build test install metalinter 11 12 check: check_tools 13 14 ######################################## 15 ### Build 16 17 protoc: 18 ## If you get the following error, 19 ## "error while loading shared libraries: libprotobuf.so.14: cannot open shared object file: No such file or directory" 20 ## See https://stackoverflow.com/a/25518702 21 protoc $(INCLUDE) --go_out=plugins=grpc:. common/*.proto 22 @echo "--> adding nolint declarations to protobuf generated files" 23 @awk '/package common/ { print "//nolint: gas"; print; next }1' common/types.pb.go > common/types.pb.go.new 24 @mv common/types.pb.go.new common/types.pb.go 25 26 build: 27 # Nothing to build! 28 29 install: 30 # Nothing to install! 31 32 33 ######################################## 34 ### Tools & dependencies 35 36 check_tools: 37 @# https://stackoverflow.com/a/25668869 38 @echo "Found tools: $(foreach tool,$(GOTOOLS_CHECK),\ 39 $(if $(shell which $(tool)),$(tool),$(error "No $(tool) in PATH")))" 40 41 get_tools: 42 @echo "--> Installing tools" 43 go get -u -v $(GOTOOLS) 44 # @gometalinter.v2 --install 45 46 get_protoc: 47 @# https://github.com/google/protobuf/releases 48 curl -L https://github.com/google/protobuf/releases/download/v3.4.1/protobuf-cpp-3.4.1.tar.gz | tar xvz && \ 49 cd protobuf-3.4.1 && \ 50 DIST_LANG=cpp ./configure && \ 51 make && \ 52 make install && \ 53 cd .. && \ 54 rm -rf protobuf-3.4.1 55 56 update_tools: 57 @echo "--> Updating tools" 58 @go get -u $(GOTOOLS) 59 60 get_vendor_deps: 61 @rm -rf vendor/ 62 @echo "--> Running dep ensure" 63 @dep ensure 64 65 66 ######################################## 67 ### Testing 68 69 gen_certs: clean_certs 70 ## Generating certificates for TLS testing... 71 certstrap init --common-name "tendermint.com" --passphrase "" 72 certstrap request-cert -ip "::" --passphrase "" 73 certstrap sign "::" --CA "tendermint.com" --passphrase "" 74 mv out/::.crt out/::.key db/remotedb 75 76 clean_certs: 77 ## Cleaning TLS testing certificates... 78 rm -rf out 79 rm -f db/remotedb/::.crt db/remotedb/::.key 80 81 test: gen_certs 82 GOCACHE=off go test -tags gcc $(shell go list ./... | grep -v vendor) 83 make clean_certs 84 85 test100: 86 @for i in {1..100}; do make test; done 87 88 89 ######################################## 90 ### Formatting, linting, and vetting 91 92 fmt: 93 @go fmt ./... 94 95 metalinter: 96 @echo "==> Running linter" 97 gometalinter.v2 --vendor --deadline=600s --disable-all \ 98 --enable=deadcode \ 99 --enable=goconst \ 100 --enable=goimports \ 101 --enable=gosimple \ 102 --enable=ineffassign \ 103 --enable=megacheck \ 104 --enable=misspell \ 105 --enable=staticcheck \ 106 --enable=safesql \ 107 --enable=structcheck \ 108 --enable=unconvert \ 109 --enable=unused \ 110 --enable=varcheck \ 111 --enable=vetshadow \ 112 ./... 113 114 #--enable=maligned \ 115 #--enable=gas \ 116 #--enable=aligncheck \ 117 #--enable=dupl \ 118 #--enable=errcheck \ 119 #--enable=gocyclo \ 120 #--enable=golint \ <== comments on anything exported 121 #--enable=gotype \ 122 #--enable=interfacer \ 123 #--enable=unparam \ 124 #--enable=vet \ 125 126 metalinter_all: 127 protoc $(INCLUDE) --lint_out=. types/*.proto 128 gometalinter.v2 --vendor --deadline=600s --enable-all --disable=lll ./... 129 130 131 # To avoid unintended conflicts with file names, always add to .PHONY 132 # unless there is a reason not to. 133 # https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html 134 .PHONY: check protoc build check_tools get_tools get_protoc update_tools get_vendor_deps test fmt metalinter metalinter_all gen_certs clean_certs 135 136 grpc_dbserver: 137 protoc -I db/remotedb/proto/ db/remotedb/proto/defs.proto --go_out=plugins=grpc:db/remotedb/proto