diff --git a/Makefile b/Makefile index 4dbaf99a7..a38058e16 100644 --- a/Makefile +++ b/Makefile @@ -5,30 +5,47 @@ GOBIN = build/bin GO ?= latest statusgo: - build/env.sh go build -i -o $(GOBIN)/statusgo -v $(shell build/flags.sh) ./cmd/status + build/env.sh go build -i -o $(GOBIN)/statusgo -v $(shell build/testnet-flags.sh) ./cmd/status @echo "status go compilation done." @echo "Run \"build/bin/statusgo\" to view available commands" statusgo-cross: statusgo-android statusgo-ios - @echo "Full cross compilation done:" + @echo "Full cross compilation done." @ls -ld $(GOBIN)/statusgo-* statusgo-android: xgo - build/env.sh $(GOBIN)/xgo --image farazdagi/xgo --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=android-16/aar -v $(shell build/flags.sh) ./cmd/status - @echo "Android cross compilation done:" + build/env.sh $(GOBIN)/xgo --image farazdagi/xgo --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=android-16/aar -v $(shell build/testnet-flags.sh) ./cmd/status + @echo "Android cross compilation done." statusgo-ios: xgo - build/env.sh $(GOBIN)/xgo --image farazdagi/xgo --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=ios-9.3/framework -v $(shell build/flags.sh) ./cmd/status - @echo "iOS framework cross compilation done:" + build/env.sh $(GOBIN)/xgo --image farazdagi/xgo --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=ios-9.3/framework -v $(shell build/testnet-flags.sh) ./cmd/status + @echo "iOS framework cross compilation done." statusgo-ios-simulator: xgo - build/env.sh $(GOBIN)/xgo --image farazdagi/xgo-ios-simulator --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=ios-9.3/framework -v $(shell build/flags.sh) ./cmd/status - @echo "iOS framework cross compilation done:" + build/env.sh $(GOBIN)/xgo --image farazdagi/xgo-ios-simulator --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=ios-9.3/framework -v $(shell build/testnet-flags.sh) ./cmd/status + @echo "iOS framework cross compilation done." xgo: build/env.sh docker pull farazdagi/xgo build/env.sh go get github.com/karalabe/xgo +statusgo-mainnet: + build/env.sh go build -i -o $(GOBIN)/statusgo -v $(shell build/mainnet-flags.sh) ./cmd/status + @echo "status go compilation done (mainnet)." + @echo "Run \"build/bin/statusgo\" to view available commands" + +statusgo-android-mainnet: xgo + build/env.sh $(GOBIN)/xgo --image farazdagi/xgo --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=android-16/aar -v $(shell build/mainnet-flags.sh) ./cmd/status + @echo "Android cross compilation done (mainnet)." + +statusgo-ios-mainnet: xgo + build/env.sh $(GOBIN)/xgo --image farazdagi/xgo --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=ios-9.3/framework -v $(shell build/mainnet-flags.sh) ./cmd/status + @echo "iOS framework cross compilation done (mainnet)." + +statusgo-ios-simulator-mainnet: xgo + build/env.sh $(GOBIN)/xgo --image farazdagi/xgo-ios-simulator --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=ios-9.3/framework -v $(shell build/mainnet-flags.sh) ./cmd/status + @echo "iOS framework cross compilation done (mainnet)." + ci: build/env.sh go test -v -cover ./geth build/env.sh go test -v -cover ./jail diff --git a/build/mainnet-flags.sh b/build/mainnet-flags.sh new file mode 100755 index 000000000..b078b9fb7 --- /dev/null +++ b/build/mainnet-flags.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 github.com/status-im/status-go/geth.UseTestnet=false -X main.buildStamp=`date -u '+%Y-%m-%d.%H:%M:%S'` -X main.gitCommit=$(git rev-parse HEAD)'"; +fi diff --git a/build/flags.sh b/build/testnet-flags.sh similarity index 55% rename from build/flags.sh rename to build/testnet-flags.sh index b3d294fcf..2b04db662 100755 --- a/build/flags.sh +++ b/build/testnet-flags.sh @@ -9,5 +9,5 @@ fi # set gitCommit when running from a Git checkout. if [ -f ".git/HEAD" ]; then - echo "-ldflags '-X main.buildStamp=`date -u '+%Y-%m-%d.%H:%M:%S'` -X main.gitCommit=$(git rev-parse HEAD)'" + echo "-ldflags '-X github.com/status-im/status-go/geth.UseTestnet=true -X main.buildStamp=`date -u '+%Y-%m-%d.%H:%M:%S'` -X main.gitCommit=$(git rev-parse HEAD)'"; fi diff --git a/cmd/status/main.go b/cmd/status/main.go index 12dacd759..4dbc5a116 100644 --- a/cmd/status/main.go +++ b/cmd/status/main.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "github.com/status-im/status-go/geth" ) var ( @@ -22,5 +23,10 @@ func main() { if gitCommit != "" { verString += "-" + gitCommit[:8] } - fmt.Printf("Status\nGit Commit: %s\nBuild Time: %s\nVersion: %s\n", gitCommit, buildStamp, verString) + netVersion := "mainnet" + if geth.UseTestnet == "true" { + netVersion = "testnet" + } + fmt.Printf("Status\nGit Commit: %s\nBuild Time: %s\nVersion: %s\nNetwork: %s\n", + gitCommit, buildStamp, verString, netVersion) } diff --git a/geth/node.go b/geth/node.go index 19bdd4faa..2016a9f61 100644 --- a/geth/node.go +++ b/geth/node.go @@ -71,6 +71,7 @@ type NodeManager struct { } var ( + UseTestnet = "true" // can be overridden via -ldflags '-X geth.UseTestnet' nodeManagerInstance *NodeManager createOnce sync.Once ) @@ -110,7 +111,9 @@ func (m *NodeManager) MakeNode(datadir string, rpcport int) *node.Node { set.Bool("lightkdf", true, "Reduce key-derivation RAM & CPU usage at some expense of KDF strength") set.Bool("shh", true, "whisper") set.Bool("light", true, "disable eth") - set.Bool("testnet", true, "light test network") + if UseTestnet == "true" { + set.Bool("testnet", true, "light test network") + } set.Bool("rpc", true, "enable rpc") set.String("rpcaddr", "localhost", "host for RPC") set.Int("rpcport", rpcport, "rpc port") diff --git a/geth/node_test.go b/geth/node_test.go index 5ef437994..6ddcc5c58 100644 --- a/geth/node_test.go +++ b/geth/node_test.go @@ -2,9 +2,9 @@ package geth_test import ( "os" + "path/filepath" "testing" "time" - "path/filepath" "github.com/status-im/status-go/geth" )