Browse Source

Cleaned up makefile

pull/1001/head
Jae Kwon 7 years ago
parent
commit
d7ac6e516a
1 changed files with 60 additions and 41 deletions
  1. +60
    -41
      Makefile

+ 60
- 41
Makefile View File

@ -1,18 +1,21 @@
GOTOOLS = \ GOTOOLS = \
github.com/mitchellh/gox \
github.com/tcnksm/ghr \
gopkg.in/alecthomas/gometalinter.v2
github.com/mitchellh/gox \
github.com/Masterminds/glide \
github.com/tcnksm/ghr \
gopkg.in/alecthomas/gometalinter.v2
GOTOOLS_CHECK = gox glide ghr gometalinter.v2
PACKAGES=$(shell go list ./... | grep -v '/vendor/') PACKAGES=$(shell go list ./... | grep -v '/vendor/')
BUILD_TAGS?=tendermint BUILD_TAGS?=tendermint
TMHOME = $${TMHOME:-$$HOME/.tendermint} TMHOME = $${TMHOME:-$$HOME/.tendermint}
BUILD_FLAGS = -ldflags "-X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse --short HEAD`" BUILD_FLAGS = -ldflags "-X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse --short HEAD`"
all: get_vendor_deps install test
all: check build test install metalinter
install:
go install $(BUILD_FLAGS) ./cmd/tendermint
check: check_tools get_vendor_deps
########################################
### Build
build: build:
go build $(BUILD_FLAGS) -o build/tendermint ./cmd/tendermint/ go build $(BUILD_FLAGS) -o build/tendermint ./cmd/tendermint/
@ -24,9 +27,42 @@ build_race:
dist: dist:
@BUILD_TAGS='$(BUILD_TAGS)' sh -c "'$(CURDIR)/scripts/dist.sh'" @BUILD_TAGS='$(BUILD_TAGS)' sh -c "'$(CURDIR)/scripts/dist.sh'"
install:
go install $(BUILD_FLAGS) ./cmd/tendermint
########################################
### 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)
@gometalinter.v2 --install
update_tools:
@echo "--> Updating tools"
@go get -u $(GOTOOLS)
get_vendor_deps:
@rm -rf vendor/
@echo "--> Running glide install"
@glide install
draw_deps:
@# requires brew install graphviz or apt-get install graphviz
go get github.com/RobotsAndPencils/goviz
@goviz -i github.com/tendermint/tendermint/cmd/tendermint -d 3 | dot -Tpng -o dependency-graph.png
########################################
### Testing
test: test:
@echo "--> Running linter"
@make metalinter_test
@echo "--> Running go test" @echo "--> Running go test"
@go test $(PACKAGES) @go test $(PACKAGES)
@ -49,46 +85,21 @@ vagrant_test:
vagrant ssh -c 'make test_race' vagrant ssh -c 'make test_race'
vagrant ssh -c 'make test_integrations' vagrant ssh -c 'make test_integrations'
draw_deps:
# requires brew install graphviz or apt-get install graphviz
go get github.com/RobotsAndPencils/goviz
@goviz -i github.com/tendermint/tendermint/cmd/tendermint -d 3 | dot -Tpng -o dependency-graph.png
get_vendor_deps:
@hash glide 2>/dev/null || go get github.com/Masterminds/glide
@rm -rf vendor/
@echo "--> Running glide install"
@glide install
@make check_tools
update_vendor_deps:
@glide update
update_tools:
@echo "--> Updating tools"
@go get -u $(GOTOOLS)
check_tools:
which gox || make tools
tools:
@echo "--> Installing tools"
@go get $(GOTOOLS)
@gometalinter.v2 --install
########################################
### Formatting, linting, and vetting ### Formatting, linting, and vetting
metalinter:
gometalinter.v2 --vendor --deadline=600s --enable-all --disable=lll ./...
fmt:
@go fmt ./...
metalinter_test:
metalinter:
@echo "--> Running linter"
gometalinter.v2 --vendor --deadline=600s --disable-all \ gometalinter.v2 --vendor --deadline=600s --disable-all \
--enable=deadcode \ --enable=deadcode \
--enable=gosimple \ --enable=gosimple \
--enable=misspell \ --enable=misspell \
--enable=safesql \ --enable=safesql \
./... ./...
#--enable=gas \ #--enable=gas \
#--enable=maligned \ #--enable=maligned \
#--enable=dupl \ #--enable=dupl \
@ -110,4 +121,12 @@ metalinter_test:
#--enable=vet \ #--enable=vet \
#--enable=vetshadow \ #--enable=vetshadow \
.PHONY: install build build_race check_tools dist test test_race test_integrations test100 draw_deps get_vendor_deps update_vendor_deps update_tools tools test_release
metalinter_all:
@echo "--> Running linter (all)"
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
.PHONY: check build build_race dist install check_tools get_tools update_tools get_vendor_deps draw_deps test test_race test_integrations test_release test100 vagrant_test fmt metalinter metalinter_all

Loading…
Cancel
Save