Fix dependency of devtools Makefile and clean code. (#4223)

1. `make tools` will not updated `clog` when `clog/main.go` was changed,
   except `${GOBIN}/clog` or `tools-stamp` was deleted. `gosum` has the
   same problem.
2. $(GOBIN)/gosum was just like magic number.
This commit is contained in:
Frank Yang 2019-04-29 22:47:43 +08:00 committed by Alessio Treglia
parent 3a1ee0839e
commit f9718b0eb4
1 changed files with 16 additions and 9 deletions

View File

@ -41,29 +41,36 @@ mkfile_dir := $(shell cd $(shell dirname $(mkfile_path)); pwd)
### ###
# tools # tools
### ###
GOLANGCI_LINT = $(GOBIN)/golangci-lint
STATIK = $(GOBIN)/statik
GOIMPORTS = $(GOBIN)/goimports
GOSUM = $(GOBIN)/gosum
CLOG = $(GOBIN)/clog
all: tools all: tools
tools: tools-stamp tools: tools-stamp
tools-stamp: $(GOBIN)/golangci-lint $(GOBIN)/statik $(GOBIN)/goimports $(GOBIN)/gosum $(GOBIN)/clog tools-stamp: $(GOLANGCI_LINT) $(STATIK) $(GOIMPORTS) $(GOSUM) $(CLOG)
touch $@ touch $@
$(GOBIN)/golangci-lint: $(mkfile_dir)/install-golangci-lint.sh $(GOBIN)/gosum $(GOLANGCI_LINT): $(mkfile_dir)/install-golangci-lint.sh $(GOSUM)
bash $(mkfile_dir)/install-golangci-lint.sh $(GOBIN) $(GOLANGCI_LINT_VERSION) $(GOLANGCI_LINT_HASHSUM) bash $(mkfile_dir)/install-golangci-lint.sh $(GOBIN) $(GOLANGCI_LINT_VERSION) $(GOLANGCI_LINT_HASHSUM)
$(GOBIN)/statik: $(STATIK):
$(call go_install,rakyll,statik,v0.1.5) $(call go_install,rakyll,statik,v0.1.5)
$(GOBIN)/goimports: $(GOIMPORTS):
go get golang.org/x/tools/cmd/goimports@v0.0.0-20190114222345-bf090417da8b go get golang.org/x/tools/cmd/goimports@v0.0.0-20190114222345-bf090417da8b
$(GOBIN)/gosum: $(GOSUM): ./contrib/devtools/gosum/main.go
go install -mod=readonly github.com/cosmos/cosmos-sdk/contrib/devtools/gosum/ go install -mod=readonly ./$(<D)/
$(GOBIN)/clog: $(CLOG): ./contrib/devtools/clog/main.go
go install -mod=readonly github.com/cosmos/cosmos-sdk/contrib/devtools/clog/ go install -mod=readonly ./$(<D)/
tools-clean: tools-clean:
cd $(GOBIN) && rm -f golangci-lint statik goimports gosum clog rm -f $(GOLANGCI_LINT) $(STATIK) $(GOIMPORTS) $(GOSUM) $(CLOG)
rm -f tools-stamp rm -f tools-stamp
.PHONY: all tools tools-clean .PHONY: all tools tools-clean