Skip to content

Commit

Permalink
Cross-compiling get_tools Makefile added
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-szabo committed Nov 8, 2018
1 parent 02327e1 commit 74549fa
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 52 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ check_tools:

update_tools:
@echo "--> Updating tools to correct version"
./scripts/get_tools.sh
$(MAKE) -C scripts get_tools

update_dev_tools:
@echo "--> Downloading linters (this may take awhile)"
Expand All @@ -116,7 +116,7 @@ update_dev_tools:

get_tools:
@echo "--> Installing tools"
./scripts/get_tools.sh
$(MAKE) -C scripts get_tools

get_dev_tools:
@echo "--> Downloading linters (this may take awhile)"
Expand Down
2 changes: 1 addition & 1 deletion PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ IMPROVEMENTS

* Gaia
- #2637 [x/gov] Switched inactive and active proposal queues to an iterator based queue
- #2672 [Makefile] Updated for better Windows compatibility and ledger support logic
- #2672 [Makefile] Updated for better Windows compatibility and ledger support logic, get_tools was rewritten as a cross-compatible Makefile.

* SDK
- \#2573 [x/distribution] add accum invariance
Expand Down
54 changes: 54 additions & 0 deletions scripts/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
###
# Find OS and Go environment
# GO contains the Go binary
# FS contains the OS file separator
###
ifeq ($(OS),Windows_NT)
GO := $(shell where go.exe 2> NUL)
FS := \\
else
GO := $(shell command -v go 2> /dev/null)
FS := /
endif

ifeq ($(GO),)
$(error could not find go. Is it in PATH? $(GO))
endif

GOPATH ?= $(shell $(GO) env GOPATH)
GITHUBDIR := $(GOPATH)$(FS)src$(FS)github.com

###
# Functions
###

go_get = $(if $(findstring Windows_NT,$(OS)),\
IF NOT EXIST $(GITHUBDIR)$(FS)$(1)$(FS) ( mkdir $(GITHUBDIR)$(FS)$(1) ) else (cd .) &\
IF NOT EXIST $(GITHUBDIR)$(FS)$(1)$(FS)$(2)$(FS) ( cd $(GITHUBDIR)$(FS)$(1) && git clone https://github.com/$(1)/$(2) ) else (cd .) &\
,\
mkdir -p $(GITHUBDIR)$(FS)$(1) &&\
(test ! -d $(GITHUBDIR)$(FS)$(1)$(FS)$(2) && cd $(GITHUBDIR)$(FS)$(1) && git clone https://github.com/$(1)/$(2)) || true &&\
)\
cd $(GITHUBDIR)$(FS)$(1)$(FS)$(2) && git fetch origin && git checkout -q $(3)

go_install = $(call go_get,$(1),$(2),$(3)) && cd $(GITHUBDIR)$(FS)$(1)$(FS)$(2) && $(GO) install

###
# get_tools
###
all: get_tools
get_tools: dep gometalinter statik

dep:
$(call go_get,golang,dep,22125cfaa6ddc71e145b1535d4b7ee9744fefff2)
cd $(GITHUBDIR)$(FS)golang$(FS)dep$(FS)cmd$(FS)dep && $(GO) install

#v2.0.11
gometalinter:
$(call go_install,alecthomas,gometalinter,17a7ffa42374937bfecabfb8d2efbd4db0c26741)

statik:
$(call go_install,rakyll,statik,v0.1.5)

.PHONY: all get_tools dep gometalinter statik

49 changes: 0 additions & 49 deletions scripts/get_tools.sh

This file was deleted.

0 comments on commit 74549fa

Please sign in to comment.