Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R4R: add deps tools, add update_vendor_deps #283

Merged
merged 3 commits into from
Sep 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ node_modules/
package.json
yarn.lock
client/lcd/statik/statik.go
dependency-graph.png
53 changes: 34 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,44 @@ all: get_vendor_deps install
COMMIT_HASH := $(shell git rev-parse --short HEAD)
BUILD_FLAGS = -ldflags "-X github.com/irisnet/irishub/version.GitCommit=${COMMIT_HASH}"

DEP = github.com/golang/dep/cmd/dep
STATIK = github.com/rakyll/statik
DEP_CHECK := $(shell command -v dep 2> /dev/null)
STATIK_CHECK := $(shell command -v statik 2> /dev/null)
########################################
### Tools & dependencies

check_tools:
cd deps_tools && $(MAKE) check_tools

check_dev_tools:
cd deps_tools && $(MAKE) check_dev_tools

update_tools:
cd deps_tools && $(MAKE) update_tools

update_dev_tools:
cd deps_tools && $(MAKE) update_dev_tools

get_tools:
ifdef DEP_CHECK
@echo "Dep is already installed. Run 'make update_tools' to update."
else
@echo "Installing dep"
go get -v $(DEP)
endif
ifdef STATIK_CHECK
@echo "Statik is already installed. Run 'make update_tools' to update."
else
@echo "Installing statik"
go version
go get -v $(STATIK)
endif
cd deps_tools && $(MAKE) get_tools

update_irislcd_swagger_docs:
@statik -src=client/lcd/swaggerui -dest=client/lcd
get_dev_tools:
cd deps_tools && $(MAKE) get_dev_tools

get_vendor_deps:
@rm -rf vendor/
@echo "--> Running dep ensure"
@dep ensure -v

draw_deps:
@# requires brew install graphviz or apt-get install graphviz
go get github.com/RobotsAndPencils/goviz
@goviz -i github.com/irisnet/irishub/cmd/iris -d 2 | dot -Tpng -o dependency-graph.png

########################################
### Generate swagger docs for irislcd
update_irislcd_swagger_docs:
@statik -src=client/lcd/swaggerui -dest=client/lcd

########################################
### Compile and Install
install: update_irislcd_swagger_docs
go install $(BUILD_FLAGS) ./cmd/iris
go install $(BUILD_FLAGS) ./cmd/iriscli
Expand All @@ -44,6 +54,11 @@ build_linux: update_irislcd_swagger_docs
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o build/iriscli ./cmd/iriscli && \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o build/irislcd ./cmd/irislcd

build_windows: update_irislcd_swagger_docs
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o build/iris.exe ./cmd/iris && \
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o build/iriscli.exe ./cmd/iriscli && \
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o build/irislcd.exe ./cmd/irislcd

build_cur: update_irislcd_swagger_docs
go build -o build/iris ./cmd/iris && \
go build -o build/iriscli ./cmd/iriscli && \
Expand Down
170 changes: 170 additions & 0 deletions deps_tools/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
all: get_tools


########################################
### DEP

DEP = github.com/golang/dep/cmd/dep
GOLINT = github.com/tendermint/lint/golint
GOMETALINTER = gopkg.in/alecthomas/gometalinter.v2
UNCONVERT = github.com/mdempsky/unconvert
INEFFASSIGN = github.com/gordonklaus/ineffassign
MISSPELL = github.com/client9/misspell/cmd/misspell
ERRCHECK = github.com/kisielk/errcheck
UNPARAM = mvdan.cc/unparam
STATIK = github.com/rakyll/statik

DEP_CHECK := $(shell command -v dep 2> /dev/null)
GOLINT_CHECK := $(shell command -v golint 2> /dev/null)
GOMETALINTER_CHECK := $(shell command -v gometalinter.v2 2> /dev/null)
UNCONVERT_CHECK := $(shell command -v unconvert 2> /dev/null)
INEFFASSIGN_CHECK := $(shell command -v ineffassign 2> /dev/null)
MISSPELL_CHECK := $(shell command -v misspell 2> /dev/null)
ERRCHECK_CHECK := $(shell command -v errcheck 2> /dev/null)
UNPARAM_CHECK := $(shell command -v unparam 2> /dev/null)
STATIK_CHECK := $(shell command -v statik 2> /dev/null)


check_tools:
ifndef DEP_CHECK
@echo "No dep in path. Install with 'make get_tools'."
else
@echo "Found dep in path."
endif
ifndef STATIK_CHECK
@echo "No statik in path. Install with 'make get_tools'."
else
@echo "Found statik in path."
endif

check_dev_tools:
$(MAKE) check_tools
ifndef GOLINT_CHECK
@echo "No golint in path. Install with 'make get_dev_tools'."
else
@echo "Found golint in path."
endif
ifndef GOMETALINTER_CHECK
@echo "No gometalinter in path. Install with 'make get_dev_tools'."
else
@echo "Found gometalinter in path."
endif
ifndef UNCONVERT_CHECK
@echo "No unconvert in path. Install with 'make get_dev_tools'."
else
@echo "Found unconvert in path."
endif
ifndef INEFFASSIGN_CHECK
@echo "No ineffassign in path. Install with 'make get_dev_tools'."
else
@echo "Found ineffassign in path."
endif
ifndef MISSPELL_CHECK
@echo "No misspell in path. Install with 'make get_dev_tools'."
else
@echo "Found misspell in path."
endif
ifndef ERRCHECK_CHECK
@echo "No errcheck in path. Install with 'make get_dev_tools'."
else
@echo "Found errcheck in path."
endif
ifndef UNPARAM_CHECK
@echo "No unparam in path. Install with 'make get_dev_tools'."
else
@echo "Found unparam in path."
endif

get_tools:
ifdef DEP_CHECK
@echo "Dep is already installed. Run 'make update_tools' to update."
else
@echo "Installing dep"
go get -v $(DEP)
endif
ifdef STATIK_CHECK
@echo "Statik is already installed. Run 'make update_tools' to update."
else
@echo "Installing statik"
go version
go get -v $(STATIK)
endif

get_dev_tools:
$(MAKE) get_tools
ifdef GOLINT_CHECK
@echo "Golint is already installed. Run 'make update_tools' to update."
else
@echo "Installing golint"
go get -v $(GOLINT)
endif
ifdef GOMETALINTER_CHECK
@echo "Gometalinter.v2 is already installed. Run 'make update_tools' to update."
else
@echo "Installing gometalinter.v2"
go get -v $(GOMETALINTER)
endif
ifdef UNCONVERT_CHECK
@echo "Unconvert is already installed. Run 'make update_tools' to update."
else
@echo "Installing unconvert"
go get -v $(UNCONVERT)
endif
ifdef INEFFASSIGN_CHECK
@echo "Ineffassign is already installed. Run 'make update_tools' to update."
else
@echo "Installing ineffassign"
go get -v $(INEFFASSIGN)
endif
ifdef MISSPELL_CHECK
@echo "misspell is already installed. Run 'make update_tools' to update."
else
@echo "Installing misspell"
go get -v $(MISSPELL)
endif
ifdef ERRCHECK_CHECK
@echo "errcheck is already installed. Run 'make update_tools' to update."
else
@echo "Installing errcheck"
go get -v $(ERRCHECK)
endif
ifdef UNPARAM_CHECK
@echo "unparam is already installed. Run 'make update_tools' to update."
else
@echo "Installing unparam"
go get -v $(UNPARAM)
endif
ifdef STATIK_CHECK
@echo "statik is already installed. Run 'make update_tools' to update."
else
@echo "Installing statik"
go get -v $(STATIK)
endif

update_tools:
@echo "Updating dep"
go get -u -v $(DEP)

update_dev_tools:
$(MAKE) update_tools
@echo "Updating tendermint/golint"
go get -u -v $(GOLINT)
@echo "Updating gometalinter.v2"
go get -u -v $(GOMETALINTER)
@echo "Updating unconvert"
go get -u -v $(UNCONVERT)
@echo "Updating ineffassign"
go get -u -v $(INEFFASSIGN)
@echo "Updating misspell"
go get -u -v $(MISSPELL)
@echo "Updating errcheck"
go get -u -v $(ERRCHECK)
@echo "Updating unparam"
go get -u -v $(UNPARAM)
@echo "Updating statik"
go get -u -v $(STATIK)

# 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_tools get_tools update_tools check_dev_tools get_dev_tools update_dev_tools