Make basecoin a root project

This commit is contained in:
Jae Kwon 2018-01-20 22:03:33 -08:00
parent 561da6353f
commit b9455e9620
11 changed files with 438 additions and 0 deletions

10
examples/basecoin/.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
*.swp
*.swo
vendor
build
### Vagrant ###
.vagrant/
*.box
*.log
vagrant

View File

@ -0,0 +1,41 @@
PACKAGES=$(shell go list ./... | grep -v '/vendor/' | grep -v '_attic')
BUILD_FLAGS = -ldflags "-X github.com/cosmos/cosmos-sdk/examples/basecoin/version.GitCommit=`git rev-parse --short HEAD`"
all: check_tools get_vendor_deps build test
########################################
### Build
build:
go build $(BUILD_FLAGS) -o build/basecoin ./cmd/...
########################################
### 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
########################################
### Testing
test:
@go test $(PACKAGES)
benchmark:
@go test -bench=. $(PACKAGES)
# 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 check_tools get_tools get_vendor_deps test benchmark

152
examples/basecoin/glide.lock generated Normal file
View File

@ -0,0 +1,152 @@
hash: 80794a3459988a7eb794baf7688c71dad4f6c26653d7b707ac0ada93f21e0776
updated: 2018-01-20T22:01:39.658469011-08:00
imports:
- name: github.com/btcsuite/btcd
version: 2e60448ffcc6bf78332d1fe590260095f554dd78
subpackages:
- btcec
- name: github.com/cosmos/cosmos-sdk
version: 633eaa87b38d9c5b0e938fe6b4f1dfd016247e76
subpackages:
- baseapp
- store
- types
- x/auth
- x/bank
- name: github.com/davecgh/go-spew
version: 04cdfd42973bb9c8589fd6a731800cf222fde1a9
subpackages:
- spew
- name: github.com/go-kit/kit
version: e2b298466b32c7cd5579a9b9b07e968fc9d9452c
subpackages:
- log
- log/level
- log/term
- name: github.com/go-logfmt/logfmt
version: 390ab7935ee28ec6b286364bba9b4dd6410cb3d5
- name: github.com/go-stack/stack
version: 817915b46b97fd7bb80e8ab6b69f01a53ac3eebf
- name: github.com/gogo/protobuf
version: 342cbe0a04158f6dcb03ca0079991a51a4248c02
subpackages:
- gogoproto
- jsonpb
- proto
- protoc-gen-gogo/descriptor
- sortkeys
- types
- name: github.com/golang/protobuf
version: 1e59b77b52bf8e4b449a57e6f79f21226d571845
subpackages:
- proto
- ptypes
- ptypes/any
- ptypes/duration
- ptypes/timestamp
- name: github.com/golang/snappy
version: 553a641470496b2327abcac10b36396bd98e45c9
- name: github.com/jmhodges/levigo
version: c42d9e0ca023e2198120196f842701bb4c55d7b9
- name: github.com/kr/logfmt
version: b84e30acd515aadc4b783ad4ff83aff3299bdfe0
- name: github.com/pkg/errors
version: 645ef00459ed84a119197bfb8d8205042c6df63d
- name: github.com/rigelrozanski/common
version: f691f115798593d783b9999b1263c2f4ffecc439
- name: github.com/syndtr/goleveldb
version: b89cc31ef7977104127d34c1bd31ebd1a9db2199
subpackages:
- leveldb
- leveldb/cache
- leveldb/comparer
- leveldb/errors
- leveldb/filter
- leveldb/iterator
- leveldb/journal
- leveldb/memdb
- leveldb/opt
- leveldb/storage
- leveldb/table
- leveldb/util
- name: github.com/tendermint/abci
version: 4243954d8d940f9ee0646a83d48ea7a1a907529e
subpackages:
- server
- types
- name: github.com/tendermint/ed25519
version: d8387025d2b9d158cf4efb07e7ebf814bcce2057
subpackages:
- edwards25519
- extra25519
- name: github.com/tendermint/go-crypto
version: 32741be2126500d600cede1e2016bbbe2754cb46
subpackages:
- keys
- name: github.com/tendermint/go-wire
version: 90af61ec85415e05c7777cd50ff93ba40d34b1e8
subpackages:
- data
- name: github.com/tendermint/iavl
version: 1dfe265ab4b491418e88e1da6577a8ad594fc989
- name: github.com/tendermint/tmlibs
version: 7a52d47a1676a9fe61d07fde0a48a733cce564c6
subpackages:
- cli
- cli/flags
- common
- db
- events
- log
- logger
- merkle
- name: golang.org/x/crypto
version: edd5e9b0879d13ee6970a50153d85b8fec9f7686
subpackages:
- nacl/secretbox
- openpgp/armor
- openpgp/errors
- poly1305
- ripemd160
- salsa20/salsa
- name: golang.org/x/net
version: 5ccada7d0a7ba9aeb5d3aca8d3501b4c2a509fec
subpackages:
- context
- http2
- http2/hpack
- idna
- internal/timeseries
- lex/httplex
- trace
- name: golang.org/x/text
version: c01e4764d870b77f8abe5096ee19ad20d80e8075
subpackages:
- secure/bidirule
- transform
- unicode/bidi
- unicode/norm
- name: google.golang.org/genproto
version: a8101f21cf983e773d0c1133ebc5424792003214
subpackages:
- googleapis/rpc/status
- name: google.golang.org/grpc
version: 401e0e00e4bb830a10496d64cd95e068c5bf50de
subpackages:
- balancer
- codes
- connectivity
- credentials
- grpclb/grpc_lb_v1/messages
- grpclog
- internal
- keepalive
- metadata
- naming
- peer
- resolver
- stats
- status
- tap
- transport
testImports: []

View File

@ -0,0 +1,4 @@
package: github.com/cosmos/cosmos-sdk/examples/basecoin
import:
- package: github.com/cosmos/cosmos-sdk
version: sdk2

1
examples/basecoin/tools/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
bin/*

View File

@ -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

18
examples/basecoin/tools/glide.lock generated Normal file
View File

@ -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: []

View File

@ -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

View File

@ -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()
}

View File

@ -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() {}