Vendor tools into tools/* (#331)
* Add tools dir * Update Makefile to call tools/Makefile * Add cmd/basecoind to make make pass
This commit is contained in:
@@ -5,3 +5,5 @@ vendor
|
||||
merkleeyes.db
|
||||
build
|
||||
docs/guide/*.sh
|
||||
tools/bin/*
|
||||
examples/build/*
|
||||
|
||||
@@ -1,41 +1,49 @@
|
||||
GOTOOLS = github.com/mitchellh/gox \
|
||||
github.com/Masterminds/glide \
|
||||
github.com/rigelrozanski/shelldown/cmd/shelldown
|
||||
TUTORIALS=$(shell find docs/guide -name "*md" -type f)
|
||||
PACKAGES=$(shell go list ./... | grep -v '/vendor/' | grep -v '_attic')
|
||||
BUILD_FLAGS = -ldflags "-X github.com/cosmos/cosmos-sdk/version.GitCommit=`git rev-parse --short HEAD`"
|
||||
|
||||
EXAMPLES := dummy basecoin
|
||||
all: check_tools get_vendor_deps build test install
|
||||
|
||||
INSTALL_EXAMPLES := $(addprefix install_,${EXAMPLES})
|
||||
TEST_EXAMPLES := $(addprefix testex_,${EXAMPLES})
|
||||
########################################
|
||||
### Build
|
||||
|
||||
LINKER_FLAGS:="-X github.com/cosmos/cosmos-sdk/client/commands.CommitHash=`git rev-parse --short HEAD`"
|
||||
|
||||
all: get_vendor_deps install test
|
||||
|
||||
$(INSTALL_EXAMPLES): install_%:
|
||||
cd ./examples/$* && go install
|
||||
|
||||
$(TEST_EXAMPLES): testex_%:
|
||||
cd ./examples/$* && make test_cli
|
||||
|
||||
install: $(INSTALL_EXAMPLES)
|
||||
build:
|
||||
go build $(BUILD_FLAGS) -o build/basecoin ./examples/basecoin/cmd/...
|
||||
|
||||
dist:
|
||||
@bash publish/dist.sh
|
||||
@bash publish/publish.sh
|
||||
|
||||
benchmark:
|
||||
@go test -bench=. ./modules/...
|
||||
|
||||
########################################
|
||||
### Tools & dependencies
|
||||
|
||||
check_tools:
|
||||
cd tools && $(MAKE) check
|
||||
|
||||
get_tools:
|
||||
cd tools && $(MAKE)
|
||||
|
||||
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
|
||||
|
||||
TUTORIALS=$(shell find docs/guide -name "*md" -type f)
|
||||
|
||||
#test: test_unit test_cli test_tutorial
|
||||
test: test_unit # test_cli
|
||||
|
||||
test_unit:
|
||||
@go test `glide novendor | grep -v _attic`
|
||||
|
||||
test_cli: $(TEST_EXAMPLES)
|
||||
# sudo apt-get install jq
|
||||
# wget "https://raw.githubusercontent.com/kward/shunit2/master/source/2.1/src/shunit2"
|
||||
@go test $(PACKAGES)
|
||||
|
||||
test_tutorial:
|
||||
@shelldown ${TUTORIALS}
|
||||
@@ -43,26 +51,35 @@ test_tutorial:
|
||||
bash $$script ; \
|
||||
done
|
||||
|
||||
get_vendor_deps: get_tools
|
||||
@glide install
|
||||
benchmark:
|
||||
@go test -bench=. $(PACKAGES)
|
||||
|
||||
build-docker:
|
||||
@docker run -it --rm -v "$(PWD):/go/src/github.com/tendermint/basecoin" -w \
|
||||
"/go/src/github.com/tendermint/basecoin" -e "CGO_ENABLED=0" golang:alpine go build ./cmd/basecoin
|
||||
@docker build -t "tendermint/basecoin" .
|
||||
|
||||
get_tools:
|
||||
@go get $(GOTOOLS)
|
||||
########################################
|
||||
### Devdoc
|
||||
|
||||
clean:
|
||||
# maybe cleaning up cache and vendor is overkill, but sometimes
|
||||
# you don't get the most recent versions with lots of branches, changes, rebases...
|
||||
@rm -rf ~/.glide/cache/src/https-github.com-tendermint-*
|
||||
@rm -rf ./vendor
|
||||
@rm -f $GOPATH/bin/{basecoin,basecli,counter,countercli}
|
||||
DEVDOC_SAVE = docker commit `docker ps -a -n 1 -q` devdoc:local
|
||||
|
||||
# when your repo is getting a little stale... just make fresh
|
||||
fresh: clean get_vendor_deps install
|
||||
@if [ "$(git status -s)" ]; then echo; echo "Warning: uncommited changes"; git status -s; fi
|
||||
devdoc_init:
|
||||
docker run -it -v "$(CURDIR):/go/src/github.com/cosmos/cosmos-sdk" -w "/go/src/github.com/cosmos/cosmos-sdk" tendermint/devdoc echo
|
||||
# TODO make this safer
|
||||
$(call DEVDOC_SAVE)
|
||||
|
||||
.PHONY: all build install test test_cli test_unit test_store get_vendor_deps build-docker clean fresh benchmark
|
||||
devdoc:
|
||||
docker run -it -v "$(CURDIR):/go/src/github.com/cosmos/cosmos-sdk" -w "/go/src/github.com/cosmos/cosmos-sdk" devdoc:local bash
|
||||
|
||||
devdoc_save:
|
||||
# TODO make this safer
|
||||
$(call DEVDOC_SAVE)
|
||||
|
||||
devdoc_clean:
|
||||
docker rmi -f $$(docker images -f "dangling=true" -q)
|
||||
|
||||
devdoc_update:
|
||||
docker pull tendermint/devdoc
|
||||
|
||||
|
||||
# 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: build dist check_tools get_tools get_vendor_deps draw_deps test test_unit test_tutorial benchmark devdoc_init devdoc devdoc_save devdoc_update
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("TODO: move examples/basecoin/main.go here and refactor")
|
||||
}
|
||||
Generated
+12
-10
@@ -1,8 +1,8 @@
|
||||
hash: a48b72c21e7e4eaf17cf54ae0ab8104c15a9b230adc3f33318fe5c068dd94996
|
||||
updated: 2018-01-14T22:42:37.763378242-05:00
|
||||
updated: 2018-01-16T11:19:24.354963539-08:00
|
||||
imports:
|
||||
- name: github.com/btcsuite/btcd
|
||||
version: c7588cbf7690cd9f047a28efa2dcd8f2435a4e5e
|
||||
version: 2e60448ffcc6bf78332d1fe590260095f554dd78
|
||||
subpackages:
|
||||
- btcec
|
||||
- name: github.com/davecgh/go-spew
|
||||
@@ -31,7 +31,7 @@ imports:
|
||||
- sortkeys
|
||||
- types
|
||||
- name: github.com/golang/protobuf
|
||||
version: 1643683e1b54a9e88ad26d98f81400c8c9d9f4f9
|
||||
version: 1e59b77b52bf8e4b449a57e6f79f21226d571845
|
||||
subpackages:
|
||||
- proto
|
||||
- ptypes
|
||||
@@ -41,7 +41,7 @@ imports:
|
||||
- name: github.com/golang/snappy
|
||||
version: 553a641470496b2327abcac10b36396bd98e45c9
|
||||
- name: github.com/gorilla/websocket
|
||||
version: ea4d1f681babbce9545c9c5f3d5194a789c89f5b
|
||||
version: 292fd08b2560ad524ee37396253d71570339a821
|
||||
- name: github.com/jmhodges/levigo
|
||||
version: c42d9e0ca023e2198120196f842701bb4c55d7b9
|
||||
- name: github.com/kr/logfmt
|
||||
@@ -49,7 +49,9 @@ imports:
|
||||
- name: github.com/pkg/errors
|
||||
version: 645ef00459ed84a119197bfb8d8205042c6df63d
|
||||
- name: github.com/rcrowley/go-metrics
|
||||
version: 1f30fe9094a513ce4c700b9a54458bbb0c96996c
|
||||
version: e181e095bae94582363434144c61a9653aff6e50
|
||||
- name: github.com/rigelrozanski/common
|
||||
version: f691f115798593d783b9999b1263c2f4ffecc439
|
||||
- name: github.com/spf13/cobra
|
||||
version: 7b2c5ac9fc04fc5efafb60700713d4fa609b777b
|
||||
- name: github.com/spf13/pflag
|
||||
@@ -80,7 +82,7 @@ imports:
|
||||
- server
|
||||
- types
|
||||
- name: github.com/tendermint/ed25519
|
||||
version: 1f52c6f8b8a5c7908aff4497c186af344b428925
|
||||
version: d8387025d2b9d158cf4efb07e7ebf814bcce2057
|
||||
subpackages:
|
||||
- edwards25519
|
||||
- extra25519
|
||||
@@ -102,7 +104,7 @@ imports:
|
||||
- certifiers/files
|
||||
- proofs
|
||||
- name: github.com/tendermint/tendermint
|
||||
version: 81ecbd4e5f82fbd2f657571e3154c68240080127
|
||||
version: b8d9f30ea6196e280ff3a4b879f3281c4e727c4d
|
||||
subpackages:
|
||||
- config
|
||||
- consensus/types
|
||||
@@ -117,7 +119,7 @@ imports:
|
||||
- state
|
||||
- types
|
||||
- name: github.com/tendermint/tmlibs
|
||||
version: f2bc5432c31974bb3f5b1a80a53c38e37d481b8d
|
||||
version: 7a52d47a1676a9fe61d07fde0a48a733cce564c6
|
||||
subpackages:
|
||||
- cli
|
||||
- cli/flags
|
||||
@@ -142,7 +144,7 @@ imports:
|
||||
- ripemd160
|
||||
- salsa20/salsa
|
||||
- name: golang.org/x/net
|
||||
version: cd69bc3fc700721b709c3a59e16e24c67b58f6ff
|
||||
version: 5ccada7d0a7ba9aeb5d3aca8d3501b4c2a509fec
|
||||
subpackages:
|
||||
- context
|
||||
- http2
|
||||
@@ -159,7 +161,7 @@ imports:
|
||||
- unicode/bidi
|
||||
- unicode/norm
|
||||
- name: google.golang.org/genproto
|
||||
version: f676e0f3ac6395ff1a529ae59a6670878a8371a6
|
||||
version: a8101f21cf983e773d0c1133ebc5424792003214
|
||||
subpackages:
|
||||
- googleapis/rpc/status
|
||||
- name: google.golang.org/grpc
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
all: install_glide check get_vendor_deps install
|
||||
|
||||
|
||||
########################################
|
||||
### Glide
|
||||
|
||||
GLIDE = github.com/tendermint/glide
|
||||
GLIDE_CHECK := $(shell command -v glide 2> /dev/null)
|
||||
|
||||
check:
|
||||
ifndef GLIDE_CHECK
|
||||
@echo "No glide in path. Install with 'make install_glide'."
|
||||
else
|
||||
@echo "Found glide in path."
|
||||
endif
|
||||
|
||||
install_glide:
|
||||
ifdef GLIDE_CHECK
|
||||
@echo "Glide is already installed. Run 'make update_glide' to update."
|
||||
else
|
||||
@echo "$(ansi_grn)Installing glide$(ansi_end)"
|
||||
go get -v $(GLIDE)
|
||||
endif
|
||||
|
||||
update_glide:
|
||||
@echo "$(ansi_grn)Updating glide$(ansi_end)"
|
||||
go get -u -v $(GLIDE)
|
||||
|
||||
|
||||
########################################
|
||||
### Install tools
|
||||
|
||||
|
||||
get_vendor_deps: check
|
||||
@rm -rf vendor/
|
||||
@echo "--> Running glide install"
|
||||
@glide install
|
||||
|
||||
install: get_vendor_deps
|
||||
@echo "$(ansi_grn)Installing tools$(ansi_end)"
|
||||
@echo "$(ansi_yel)Install go-vendorinstall$(ansi_end)"
|
||||
go build -o bin/go-vendorinstall go-vendorinstall/*.go
|
||||
|
||||
@echo "$(ansi_yel)Install gometalinter.v2$(ansi_end)"
|
||||
GOBIN=$(CURDIR)/bin ./bin/go-vendorinstall gopkg.in/alecthomas/gometalinter.v2
|
||||
|
||||
@echo "$(ansi_yel)Install shelldown$(ansi_end)"
|
||||
GOBIN=$(CURDIR)/bin ./bin/go-vendorinstall github.com/rigelrozanski/shelldown/cmd/shelldown
|
||||
|
||||
@echo "$(ansi_grn)Done installing tools$(ansi_end)"
|
||||
|
||||
|
||||
########################################
|
||||
# ANSI colors
|
||||
|
||||
ansi_red=\033[0;31m
|
||||
ansi_grn=\033[0;32m
|
||||
ansi_yel=\033[0;33m
|
||||
ansi_end=\033[0m
|
||||
|
||||
|
||||
# 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 install_glide update_glide get_vendor_deps install
|
||||
Generated
+18
@@ -0,0 +1,18 @@
|
||||
hash: a163b1c4806024cfc9062db75a0abed285ec40461243e59af0e147db2c4bf0ce
|
||||
updated: 2018-01-15T19:02:49.834182027-08:00
|
||||
imports:
|
||||
- name: github.com/inconshreveable/mousetrap
|
||||
version: 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75
|
||||
- name: github.com/rigelrozanski/common
|
||||
version: f691f115798593d783b9999b1263c2f4ffecc439
|
||||
- name: github.com/rigelrozanski/shelldown
|
||||
version: 2e18b6eb9bf428aa524e71433296e0b7c73ae0a3
|
||||
subpackages:
|
||||
- cmd/shelldown
|
||||
- name: github.com/spf13/cobra
|
||||
version: 7b2c5ac9fc04fc5efafb60700713d4fa609b777b
|
||||
- name: github.com/spf13/pflag
|
||||
version: 97afa5e7ca8a08a383cb259e06636b5e2cc7897f
|
||||
- name: gopkg.in/alecthomas/gometalinter.v2
|
||||
version: 88d47c66988c5a5cb3945925da47c883800a94df
|
||||
testImports: []
|
||||
@@ -0,0 +1,6 @@
|
||||
package: github.com/cosmos/cosmos-sdk/tools
|
||||
import:
|
||||
- package: github.com/rigelrozanski/shelldown
|
||||
subpackages:
|
||||
- cmd/shelldown
|
||||
- package: gopkg.in/alecthomas/gometalinter.v2
|
||||
@@ -0,0 +1,129 @@
|
||||
// https://raw.githubusercontent.com/roboll/go-vendorinstall/a3e9f0a5d5861b3bb16b93200b2c359c9846b3c5/main.go
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
source = flag.String("source", "vendor", "source directory")
|
||||
target = flag.String("target", "", "target directory (defaults to $GOBIN, if not set $GOPATH/bin)")
|
||||
commands = flag.String("commands", "", "comma separated list of commands to execute after go install in temporary environment")
|
||||
quiet = flag.Bool("quiet", false, "disable output")
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
packages := flag.Args()
|
||||
if len(packages) < 1 {
|
||||
fail(errors.New("no packages: specify a package"))
|
||||
}
|
||||
|
||||
gopath, err := ioutil.TempDir("", "go-vendorinstall-gopath")
|
||||
if err != nil {
|
||||
fail(err)
|
||||
}
|
||||
print(fmt.Sprintf("gopath: %s", gopath))
|
||||
defer func() {
|
||||
if err := os.RemoveAll(gopath); err != nil {
|
||||
fail(err)
|
||||
}
|
||||
}()
|
||||
|
||||
if len(*target) == 0 {
|
||||
if gobin := os.Getenv("GOBIN"); len(gobin) > 0 {
|
||||
target = &gobin
|
||||
} else {
|
||||
bin := fmt.Sprintf("%s/bin", os.Getenv("GOPATH"))
|
||||
target = &bin
|
||||
}
|
||||
}
|
||||
|
||||
gobin, err := filepath.Abs(*target)
|
||||
if err != nil {
|
||||
fail(err)
|
||||
}
|
||||
print(fmt.Sprintf("gobin: %s", gobin))
|
||||
|
||||
if err := link(gopath, *source); err != nil {
|
||||
fail(err)
|
||||
}
|
||||
|
||||
oldpath := os.Getenv("PATH")
|
||||
path := fmt.Sprintf("%s%s%s", gobin, string(os.PathListSeparator), os.Getenv("PATH"))
|
||||
os.Setenv("PATH", fmt.Sprintf("%s%s%s", gobin, string(os.PathListSeparator), os.Getenv("PATH")))
|
||||
defer os.Setenv("PATH", oldpath)
|
||||
|
||||
env := []string{fmt.Sprintf("PATH=%s", path), fmt.Sprintf("GOPATH=%s", gopath), fmt.Sprintf("GOBIN=%s", gobin)}
|
||||
args := append([]string{"install"}, packages...)
|
||||
if out, err := doexec("go", gopath, args, env); err != nil {
|
||||
print(string(out))
|
||||
fail(err)
|
||||
}
|
||||
|
||||
if len(*commands) > 0 {
|
||||
for _, cmd := range strings.Split(*commands, ",") {
|
||||
split := strings.Split(cmd, " ")
|
||||
if out, err := doexec(split[0], gopath, split[1:], env); err != nil {
|
||||
print(string(out))
|
||||
fail(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func print(msg string) {
|
||||
if !*quiet {
|
||||
fmt.Println(msg)
|
||||
}
|
||||
}
|
||||
|
||||
func fail(err error) {
|
||||
fmt.Printf("error: %s", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func link(gopath, source string) error {
|
||||
srcdir, err := filepath.Abs(source)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
linkto := filepath.Join(gopath, "src")
|
||||
if err := os.MkdirAll(linkto, 0777); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
files, err := ioutil.ReadDir(srcdir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, file := range files {
|
||||
real := filepath.Join(srcdir, file.Name())
|
||||
link := filepath.Join(linkto, file.Name())
|
||||
if err := os.Symlink(real, link); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func doexec(bin, dir string, args []string, env []string) ([]byte, error) {
|
||||
print(fmt.Sprintf("%s %s", bin, strings.Join(args, " ")))
|
||||
cmd := exec.Command(bin, args...)
|
||||
cmd.Env = env
|
||||
cmd.Dir = dir
|
||||
|
||||
return cmd.CombinedOutput()
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
// Include dependencies here so glide picks them up
|
||||
// and installs sub-dependencies.
|
||||
|
||||
// TODO: Ideally this gets auto-imported on glide update.
|
||||
// Any way to make that happen?
|
||||
_ "github.com/rigelrozanski/common"
|
||||
)
|
||||
|
||||
func main() {}
|
||||
Reference in New Issue
Block a user