tendermint/Makefile

138 lines
3.6 KiB
Makefile
Raw Normal View History

2017-04-25 14:48:10 -07:00
GOTOOLS = \
2018-02-27 04:01:49 -08:00
github.com/golang/dep/cmd/dep \
2018-05-23 21:10:35 -07:00
github.com/golang/protobuf/protoc-gen-go \
2018-05-07 14:16:06 -07:00
github.com/square/certstrap
2018-01-02 07:59:43 -08:00
# github.com/alecthomas/gometalinter.v2 \
2018-05-23 21:10:35 -07:00
GOTOOLS_CHECK = dep gometalinter.v2 protoc protoc-gen-go
INCLUDE = -I=. -I=${GOPATH}/src
2018-05-07 13:12:26 -07:00
all: check get_vendor_deps protoc grpc_dbserver build test install metalinter
2017-04-25 14:48:10 -07:00
2017-12-25 22:41:40 -08:00
check: check_tools
2017-05-05 10:52:01 -07:00
2017-12-25 22:41:40 -08:00
########################################
### Build
protoc:
## If you get the following error,
## "error while loading shared libraries: libprotobuf.so.14: cannot open shared object file: No such file or directory"
## See https://stackoverflow.com/a/25518702
2018-05-23 21:10:35 -07:00
protoc $(INCLUDE) --go_out=plugins=grpc:. common/*.proto
@echo "--> adding nolint declarations to protobuf generated files"
@awk '/package common/ { print "//nolint: gas"; print; next }1' common/types.pb.go > common/types.pb.go.new
@mv common/types.pb.go.new common/types.pb.go
2017-12-25 22:41:40 -08:00
build:
# Nothing to build!
install:
# Nothing to install!
########################################
### Tools & dependencies
check_tools:
@# https://stackoverflow.com/a/25668869
@echo "Found tools: $(foreach tool,$(GOTOOLS_CHECK),\
$(if $(shell which $(tool)),$(tool),$(error "No $(tool) in PATH")))"
get_tools:
@echo "--> Installing tools"
go get -u -v $(GOTOOLS)
2018-01-02 07:59:43 -08:00
# @gometalinter.v2 --install
2017-12-25 22:41:40 -08:00
get_protoc:
@# https://github.com/google/protobuf/releases
curl -L https://github.com/google/protobuf/releases/download/v3.4.1/protobuf-cpp-3.4.1.tar.gz | tar xvz && \
cd protobuf-3.4.1 && \
DIST_LANG=cpp ./configure && \
make && \
make install && \
cd .. && \
rm -rf protobuf-3.4.1
2017-12-25 22:41:40 -08:00
update_tools:
@echo "--> Updating tools"
@go get -u $(GOTOOLS)
2017-04-25 14:48:10 -07:00
2017-12-25 22:41:40 -08:00
get_vendor_deps:
2017-04-25 14:48:10 -07:00
@rm -rf vendor/
2018-02-27 04:01:49 -08:00
@echo "--> Running dep ensure"
@dep ensure
2017-04-25 14:48:10 -07:00
2017-12-25 22:41:40 -08:00
########################################
### Testing
2018-05-07 14:16:06 -07:00
gen_certs: clean_certs
## Generating certificates for TLS testing...
certstrap init --common-name "tendermint.com" --passphrase ""
certstrap request-cert -ip "::" --passphrase ""
certstrap sign "::" --CA "tendermint.com" --passphrase ""
mv out/::.crt out/::.key db/remotedb
2018-05-07 14:16:06 -07:00
clean_certs:
## Cleaning TLS testing certificates...
rm -rf out
rm -f db/remotedb/::.crt db/remotedb/::.key
2018-05-07 14:16:06 -07:00
test: gen_certs
2018-02-27 04:01:49 -08:00
go test -tags gcc $(shell go list ./... | grep -v vendor)
2018-05-07 14:16:06 -07:00
make clean_certs
2017-12-25 22:41:40 -08:00
test100:
@for i in {1..100}; do make test; done
2017-12-25 22:41:40 -08:00
########################################
### Formatting, linting, and vetting
fmt:
@go fmt ./...
metalinter:
@echo "==> Running linter"
gometalinter.v2 --vendor --deadline=600s --disable-all \
--enable=deadcode \
--enable=goconst \
2017-12-25 22:41:40 -08:00
--enable=goimports \
--enable=gosimple \
--enable=ineffassign \
--enable=megacheck \
--enable=misspell \
--enable=staticcheck \
--enable=safesql \
--enable=structcheck \
--enable=unconvert \
--enable=unused \
--enable=varcheck \
--enable=vetshadow \
./...
2018-01-02 07:48:36 -08:00
#--enable=maligned \
2017-12-25 22:41:40 -08:00
#--enable=gas \
#--enable=aligncheck \
#--enable=dupl \
#--enable=errcheck \
#--enable=gocyclo \
#--enable=golint \ <== comments on anything exported
2017-10-03 09:18:21 -07:00
#--enable=gotype \
2017-12-25 22:41:40 -08:00
#--enable=interfacer \
#--enable=unparam \
2017-12-25 22:41:40 -08:00
#--enable=vet \
metalinter_all:
protoc $(INCLUDE) --lint_out=. types/*.proto
gometalinter.v2 --vendor --deadline=600s --enable-all --disable=lll ./...
# To avoid unintended conflicts with file names, always add to .PHONY
# unless there is a reason not to.
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
2018-05-07 14:16:06 -07:00
.PHONY: check protoc build check_tools get_tools get_protoc update_tools get_vendor_deps test fmt metalinter metalinter_all gen_certs clean_certs
grpc_dbserver:
protoc -I db/remotedb/proto/ db/remotedb/proto/defs.proto --go_out=plugins=grpc:db/remotedb/proto