aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-04-29 19:43:38 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-04-29 19:43:38 +0800
commitbac4440e1751fd3b71f8271260d1c8af236d2cec (patch)
tree7244f37c5c6120ecfb2afd996495bbb4a4810d7e
parent32373e3837c5fc3def8050d6de8be34946a3fd75 (diff)
parentaa03e53ca8d55e74e562f5f56d90e4fd2579fb4e (diff)
downloaddexon-bac4440e1751fd3b71f8271260d1c8af236d2cec.tar
dexon-bac4440e1751fd3b71f8271260d1c8af236d2cec.tar.gz
dexon-bac4440e1751fd3b71f8271260d1c8af236d2cec.tar.bz2
dexon-bac4440e1751fd3b71f8271260d1c8af236d2cec.tar.lz
dexon-bac4440e1751fd3b71f8271260d1c8af236d2cec.tar.xz
dexon-bac4440e1751fd3b71f8271260d1c8af236d2cec.tar.zst
dexon-bac4440e1751fd3b71f8271260d1c8af236d2cec.zip
Merge pull request #822 from fjl/makefile-improvements
Makefile improvements
-rw-r--r--.gitignore4
-rw-r--r--.travis.yml7
-rw-r--r--Makefile20
-rw-r--r--README.md59
-rwxr-xr-xbuild/env.sh6
-rwxr-xr-xbuild/ldflags.sh13
-rwxr-xr-xbuild/test-global-coverage.sh26
-rw-r--r--cmd/geth/main.go41
-rw-r--r--cmd/mist/main.go12
-rwxr-xr-xgocoverage.sh31
10 files changed, 121 insertions, 98 deletions
diff --git a/.gitignore b/.gitignore
index a90cb225b..241c26a55 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,3 +30,7 @@ deploy/osx/Mist\ Installer.dmg
/build/_workspace/
/build/bin/
+# travis
+profile.tmp
+profile.cov
+
diff --git a/.travis.yml b/.travis.yml
index d6954e0cb..b0f295fb6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,13 +4,12 @@ go:
before_install:
- sudo add-apt-repository ppa:beineri/opt-qt541 -y
- sudo apt-get update -qq
- - sudo apt-get install -yqq libgmp3-dev libreadline6-dev qt54quickcontrols qt54webengine
+ - sudo apt-get install -yqq libgmp3-dev qt54quickcontrols qt54webengine
install:
# - go get code.google.com/p/go.tools/cmd/goimports
# - go get github.com/golang/lint/golint
# - go get golang.org/x/tools/cmd/vet
- - go get golang.org/x/tools/cmd/cover
- - go get github.com/mattn/goveralls
+ - go get golang.org/x/tools/cmd/cover github.com/mattn/goveralls
before_script:
# - gofmt -l -w .
# - goimports -l -w .
@@ -18,7 +17,7 @@ before_script:
# - go vet ./...
# - go test -race ./...
script:
- - ./gocoverage.sh
+ - make travis-test-with-coverage
after_success:
- if [ "$COVERALLS_TOKEN" ]; then goveralls -coverprofile=profile.cov -service=travis-ci -repotoken $COVERALLS_TOKEN; fi
env:
diff --git a/Makefile b/Makefile
index 1fdc36f98..03e3bf4c6 100644
--- a/Makefile
+++ b/Makefile
@@ -1,22 +1,28 @@
# This Makefile is meant to be used by people that do not usually work
# with Go source code. If you know what GOPATH is then you probably
# don't need to bother with make.
-#
-# Note that there is no way to run the tests or do anything other than
-# building the binaries. This is by design.
-.PHONY: geth mist clean
+.PHONY: geth mist all test travis-test-with-coverage clean
GOBIN = build/bin
geth:
- build/env.sh go install -v github.com/ethereum/go-ethereum/cmd/geth
+ build/env.sh go install -v $(shell build/ldflags.sh) ./cmd/geth
@echo "Done building."
@echo "Run \"$(GOBIN)/geth\" to launch geth."
mist:
- build/env.sh go install -v github.com/ethereum/go-ethereum/cmd/mist
+ build/env.sh go install -v $(shell build/ldflags.sh) ./cmd/mist
@echo "Done building."
@echo "Run \"$(GOBIN)/mist --asset_path=cmd/mist/assets\" to launch mist."
+all:
+ build/env.sh go install -v $(shell build/ldflags.sh) ./...
+
+test: all
+ build/env.sh go test ./...
+
+travis-test-with-coverage: all
+ build/env.sh build/test-global-coverage.sh
+
clean:
- rm -fr build/_workspace/pkg/ $(GOBIN)/*
+ rm -fr build/_workspace/pkg/ Godeps/_workspace/pkg $(GOBIN)/*
diff --git a/README.md b/README.md
index 6fcf29b88..21b42e445 100644
--- a/README.md
+++ b/README.md
@@ -12,38 +12,6 @@ master | [![Build+Status](https://build.ethdev.com/buildstatusimage?builder=L
[![Stories in Progress](https://badge.waffle.io/ethereum/go-ethereum.svg?label=in%20progress&title=In Progress)](http://waffle.io/ethereum/go-ethereum)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ethereum/go-ethereum?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
-
-Build
-=====
-
-Mist (GUI):
-
-`go get github.com/ethereum/go-ethereum/cmd/mist`
-
-Geth (CLI):
-
-`go get github.com/ethereum/go-ethereum/cmd/geth`
-
-As of POC-8, go-ethereum uses [Godep](https://github.com/tools/godep) to manage dependencies. Assuming you have [your environment all set up](https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum), switch to the go-ethereum repository root folder, and build/install the executable you need:
-
-Mist (GUI):
-
-```
-godep go build -v ./cmd/mist
-```
-
-Geth (CLI):
-
-```
-godep go build -v ./cmd/geth
-```
-
-Instead of `build`, you can use `install` which will also install the resulting binary.
-
-For prerequisites and detailed build instructions please see the [Wiki](https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum)
-
-If you intend to develop on go-ethereum, check the [Developers' Guide](https://github.com/ethereum/go-ethereum/wiki/Developers'-Guide)
-
Automated (dev) builds
======================
@@ -54,6 +22,19 @@ Automated (dev) builds
[utopic](https://build.ethdev.com/builds/Linux%20Go%20develop%20deb%20i386-utopic/latest/)
* [Windows 64-bit](https://build.ethdev.com/builds/Windows%20Go%20develop%20branch/Geth-Win64-latest.7z)
+Building the source
+===================
+
+For prerequisites and detailed build instructions please read the
+[Installation Instructions](https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum)
+on the wiki.
+
+Building geth requires two external dependencies, Go and GMP.
+You can install them using your favourite package manager.
+Once the dependencies are installed, run
+
+ make geth
+
Executables
===========
@@ -68,18 +49,16 @@ Go Ethereum comes with several wrappers/executables found in
* `evm` is a generic Ethereum Virtual Machine: `evm -code 60ff60ff -gas
10000 -price 0 -dump`. See `-h` for a detailed description.
* `disasm` disassembles EVM code: `echo "6001" | disasm`
-* `rlpdump` converts a rlp stream to `interface{}`.
+* `rlpdump` prints RLP structures
Command line options
-============================
+====================
Both `mist` and `geth` can be configured via command line options, environment variables and config files.
To get the options available:
-```
-geth -help
-```
+ geth --help
For further details on options, see the [wiki](https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options)
@@ -92,6 +71,6 @@ are ignored (use gofmt!). If you send pull requests make absolute sure that you
commit on the `develop` branch and that you do not merge to master.
Commits that are directly based on master are simply ignored.
-See [Developers' Guide](https://github.com/ethereum/go-ethereum/wiki/Developers'-Guide) for more details on configuring your environment, testing, and dependency management.
-
-TEST
+See [Developers' Guide](https://github.com/ethereum/go-ethereum/wiki/Developers'-Guide)
+for more details on configuring your environment, testing, and
+dependency management.
diff --git a/build/env.sh b/build/env.sh
index b28ad6259..04401a3e1 100755
--- a/build/env.sh
+++ b/build/env.sh
@@ -24,5 +24,9 @@ GOPATH="$ethdir/go-ethereum/Godeps/_workspace:$workspace"
GOBIN="$PWD/build/bin"
export GOPATH GOBIN
+# Run the command inside the workspace.
+cd "$ethdir/go-ethereum"
+PWD="$ethdir/go-ethereum"
+
# Launch the arguments with the configured environment.
-exec $@
+exec "$@"
diff --git a/build/ldflags.sh b/build/ldflags.sh
new file mode 100755
index 000000000..9e17ca498
--- /dev/null
+++ b/build/ldflags.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+set -e
+
+if [ ! -f "build/env.sh" ]; then
+ echo "$0 must be run from the root of the repository."
+ exit 2
+fi
+
+# set gitCommit when running from a Git checkout.
+if [ -f ".git/HEAD" ]; then
+ echo "-ldflags '-X main.gitCommit $(git rev-parse HEAD)'"
+fi
diff --git a/build/test-global-coverage.sh b/build/test-global-coverage.sh
new file mode 100755
index 000000000..417c829f4
--- /dev/null
+++ b/build/test-global-coverage.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# This script runs all package tests and merges the resulting coverage
+# profiles. Coverage is accounted per package under test.
+
+set -e
+
+if [ ! -f "build/env.sh" ]; then
+ echo "$0 must be run from the root of the repository."
+ exit 2
+fi
+
+echo "mode: count" > profile.cov
+
+for pkg in $(go list ./...); do
+ # drop the namespace prefix.
+ dir=${pkg##github.com/ethereum/go-ethereum/}
+
+ if [[ $dir != "tests/vm" ]]; then
+ go test -covermode=count -coverprofile=$dir/profile.tmp $pkg
+ fi
+ if [[ -f $dir/profile.tmp ]]; then
+ tail -n +2 $dir/profile.tmp >> profile.cov
+ rm $dir/profile.tmp
+ fi
+done
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index 6ffc3c4a0..bec47efbb 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -50,9 +50,20 @@ const (
Version = "0.9.12"
)
-var app = utils.NewApp(Version, "the go-ethereum command line interface")
+var (
+ gitCommit string // set via linker flag
+ nodeNameVersion string
+ app *cli.App
+)
func init() {
+ if gitCommit == "" {
+ nodeNameVersion = Version
+ } else {
+ nodeNameVersion = Version + "-" + gitCommit[:8]
+ }
+
+ app = utils.NewApp(Version, "the go-ethereum command line interface")
app.Action = run
app.HideVersion = true // we have a command to print the version
app.Commands = []cli.Command{
@@ -278,7 +289,7 @@ func main() {
func run(ctx *cli.Context) {
utils.HandleInterrupt()
- cfg := utils.MakeEthConfig(ClientIdentifier, Version, ctx)
+ cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx)
ethereum, err := eth.New(cfg)
if err != nil {
utils.Fatalf("%v", err)
@@ -290,7 +301,7 @@ func run(ctx *cli.Context) {
}
func console(ctx *cli.Context) {
- cfg := utils.MakeEthConfig(ClientIdentifier, Version, ctx)
+ cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx)
ethereum, err := eth.New(cfg)
if err != nil {
utils.Fatalf("%v", err)
@@ -305,7 +316,7 @@ func console(ctx *cli.Context) {
}
func execJSFiles(ctx *cli.Context) {
- cfg := utils.MakeEthConfig(ClientIdentifier, Version, ctx)
+ cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx)
ethereum, err := eth.New(cfg)
if err != nil {
utils.Fatalf("%v", err)
@@ -487,7 +498,7 @@ func exportchain(ctx *cli.Context) {
utils.Fatalf("This command requires an argument.")
}
- cfg := utils.MakeEthConfig(ClientIdentifier, Version, ctx)
+ cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx)
cfg.SkipBcVersionCheck = true
ethereum, err := eth.New(cfg)
@@ -589,15 +600,17 @@ func makedag(ctx *cli.Context) {
}
func version(c *cli.Context) {
- fmt.Printf(`%v
-Version: %v
-Protocol Version: %d
-Network Id: %d
-GO: %s
-OS: %s
-GOPATH=%s
-GOROOT=%s
-`, ClientIdentifier, Version, c.GlobalInt(utils.ProtocolVersionFlag.Name), c.GlobalInt(utils.NetworkIdFlag.Name), runtime.Version(), runtime.GOOS, os.Getenv("GOPATH"), runtime.GOROOT())
+ fmt.Println(ClientIdentifier)
+ fmt.Println("Version:", Version)
+ if gitCommit != "" {
+ fmt.Println("Git Commit:", gitCommit)
+ }
+ fmt.Println("Protocol Version:", c.GlobalInt(utils.ProtocolVersionFlag.Name))
+ fmt.Println("Network Id:", c.GlobalInt(utils.NetworkIdFlag.Name))
+ fmt.Println("Go Version:", runtime.Version())
+ fmt.Println("OS:", runtime.GOOS)
+ fmt.Printf("GOPATH=%s\n", os.Getenv("GOPATH"))
+ fmt.Printf("GOROOT=%s\n", runtime.GOROOT())
}
// hashish returns true for strings that look like hashes.
diff --git a/cmd/mist/main.go b/cmd/mist/main.go
index 6780cfb3a..1030d6ada 100644
--- a/cmd/mist/main.go
+++ b/cmd/mist/main.go
@@ -41,6 +41,9 @@ const (
)
var (
+ gitCommit string // set via linker flag
+ nodeNameVersion string
+
app = utils.NewApp(Version, "the ether browser")
assetPathFlag = cli.StringFlag{
Name: "asset_path",
@@ -55,6 +58,11 @@ func init() {
if len(rpcCorsFlag.Value) == 0 {
rpcCorsFlag.Value = "http://localhost"
}
+ if gitCommit == "" {
+ nodeNameVersion = Version
+ } else {
+ nodeNameVersion = Version + "-" + gitCommit[:8]
+ }
app.Action = run
app.Flags = []cli.Flag{
@@ -74,6 +82,7 @@ func init() {
utils.RPCPortFlag,
utils.JSpathFlag,
utils.ProtocolVersionFlag,
+ utils.BlockchainVersionFlag,
utils.NetworkIdFlag,
}
}
@@ -106,7 +115,8 @@ func run(ctx *cli.Context) {
tstart := time.Now()
// TODO: show qml popup instead of exiting if initialization fails.
- cfg := utils.MakeEthConfig(ClientIdentifier, Version, ctx)
+ cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx)
+ cfg.Shh = true
ethereum, err := eth.New(cfg)
if err != nil {
utils.Fatalf("%v", err)
diff --git a/gocoverage.sh b/gocoverage.sh
deleted file mode 100755
index 5479d8d3b..000000000
--- a/gocoverage.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/bash
-
-set -e
-
-# Add godep workspace to GOPATH. We do it manually instead of using
-# 'godep go test' or 'godep restore' so godep doesn't need to be installed.
-GOPATH="$PWD/Godeps/_workspace:$GOPATH"
-
-# Install packages before testing. Not doing this would cause
-# 'go test' to recompile all package dependencies before testing each package.
-go install ./...
-
-# Run test coverage on each subdirectories and merge the coverage profile.
-echo "mode: count" > profile.cov
-
-# Standard go tooling behavior is to ignore dirs with leading underscors
-for dir in $(find . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -type d);
-do
-if ls $dir/*.go &> /dev/null; then
- # echo $dir
- if [[ $dir != "./tests/vm" && $dir != "." ]]
- then
- go test -covermode=count -coverprofile=$dir/profile.tmp $dir
- fi
- if [ -f $dir/profile.tmp ]
- then
- cat $dir/profile.tmp | tail -n +2 >> profile.cov
- rm $dir/profile.tmp
- fi
-fi
-done