aboutsummaryrefslogtreecommitdiffstats
path: root/GNUmakefile
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-07-20 09:52:52 +0800
committermissionliao <38416648+missionliao@users.noreply.github.com>2018-07-20 09:52:52 +0800
commitdfa19fc2b4e38097334f4a30e159f9bcd92909c0 (patch)
tree718524746a0871a07a4a68dea43481e6ac841b39 /GNUmakefile
parent46a84bff9ac419853550f7c17b13fb8633e507c9 (diff)
downloaddexon-consensus-dfa19fc2b4e38097334f4a30e159f9bcd92909c0.tar
dexon-consensus-dfa19fc2b4e38097334f4a30e159f9bcd92909c0.tar.gz
dexon-consensus-dfa19fc2b4e38097334f4a30e159f9bcd92909c0.tar.bz2
dexon-consensus-dfa19fc2b4e38097334f4a30e159f9bcd92909c0.tar.lz
dexon-consensus-dfa19fc2b4e38097334f4a30e159f9bcd92909c0.tar.xz
dexon-consensus-dfa19fc2b4e38097334f4a30e159f9bcd92909c0.tar.zst
dexon-consensus-dfa19fc2b4e38097334f4a30e159f9bcd92909c0.zip
Implement simulation on a real network (#5)
simulation: implement simulation on a real network
Diffstat (limited to 'GNUmakefile')
-rw-r--r--GNUmakefile51
1 files changed, 45 insertions, 6 deletions
diff --git a/GNUmakefile b/GNUmakefile
index eb0d93b..1cac341 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -1,17 +1,56 @@
-# Makefile for DEXON consensus core
+# Makefile for DEXON Consensus Core
-DEXON_CONSENSUS_CORE=github.com/dexon-foundation/dexon-consensus-core
+GOPATH = $(CURDIR)/../../../../
+ifndef BINDIR
+BINDIR := $(CURDIR)/build
+else
+BINDIR := $(abspath $(BINDIR))
+endif
+PROJECT_ROOT=github.com/dexon-foundation/dexon-consensus-core
+BUILDER_REPO = cobinhooddev/ci-base-alpine
+
+ifeq ($(DOCKER),true)
+GO_LDFLAGS += -linkmode external -extldflags \"-static\"
+endif
+
+V ?= 0
+AT_LOCAL_GO = $(AT_LOCAL_GO_$(V))
+AT_LOCAL_GO_0 = @echo " HOST GO "$1;
+AT_LOCAL_GO_1 =
+AT_DOCKER_GO = $(AT_DOCKER_GO_$(V))
+AT_DOCKER_GO_0 = @echo " DOCKER GO "$1;
+AT_DOCKER_GO_1 =
+
+define BUILD_RULE
+$1: pre-build
+ifeq ($(DOCKER),true)
+ $(AT_DOCKER_GO)docker run --rm \
+ -v "$(GOPATH)":/go:z \
+ -v $(BINDIR):/artifacts:z \
+ -e "GOPATH=/go" \
+ -w /go/src/$(PROJECT_ROOT) \
+ $(BUILDER_REPO):latest sh -c "\
+ go build -o /artifacts/$1 $(PROJECT_ROOT)/cmd/$1"
+else
+ @mkdir -p $(BINDIR)
+ $(AT_LOCAL_GO)go install -ldflags '$(GO_LDFLAGS)' $(PROJECT_ROOT)/cmd/$1
+ @install -c $(GOPATH)/bin/$1 $(BINDIR)
+endif
+endef
+
+COMPONENTS = \
+ dexcon-simulation \
+ dexcon-simulation-peer-server
.PHONY: clean default
default: all
-all: dexcon-simulation
+all: $(COMPONENTS)
-pre-submit: lint
+$(foreach component, $(COMPONENTS), $(eval $(call BUILD_RULE,$(component))))
-dexcon-simulation:
- go install $(DEXON_CONSENSUS_CORE)/cmd/dexcon-simulation
+pre-build:
pre-submit: lint test vet