blob: 1cac341c4674e875fd8fc2df61fe7db8fca5071a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# Makefile for 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: $(COMPONENTS)
$(foreach component, $(COMPONENTS), $(eval $(call BUILD_RULE,$(component))))
pre-build:
pre-submit: lint test vet
lint:
@$(GOPATH)/bin/golint -set_exit_status `go list ./... | grep -v 'vendor'`
vet:
@go vet `go list ./... | grep -v 'vendor'`
test:
@for pkg in `go list ./... | grep -v 'vendor'`; do \
if ! go test $$pkg; then \
echo 'Some test failed, abort'; \
exit 1; \
fi; \
done
|