forked from devintegral/go-lachesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
94 lines (79 loc) · 2.52 KB
/
Makefile
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
BUILD_TAGS?=lachesis
export DOCKER?=docker
export GLIDE?=glide
export GO?=go
export GREP?=grep
export MOCKGEN?=mockgen
export PROTOC?=protoc
export RM?=rm
export SED?=sed
export SH?=sh
export TESTCOUNT?=1
export VERBOSE?=0
export XARGS?=xargs
ifeq ($(OS),Windows_NT)
export BROWSER?=start
endif
ifeq ($(shell uname -s),Darwin)
export BROWSER?=open
endif
export BROWSER?=sensible-browser
export CGO_ENABLED=0
SUBDIRS := src/.
TARGETS := build proto clean buildtests
SUBDIR_TARGETS := $(foreach t,$(TARGETS),$(addsuffix $t,$(SUBDIRS)))
VENDOR_LDFLAG := --ldflags "-X github.com/Fantom-foundation/go-lachesis/src/version.GitCommit=`git rev-parse HEAD`"
ifeq ($(OS),Windows_NT)
# EXTLDFLAGS := ""
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
# EXTLDFLAGS := ""
else
EXTLDFLAGS := --ldflags '-extldflags "-static"'
endif
endif
# vendor uses Glide to install all the Go dependencies in vendor/
vendor:
$(GLIDE) install
# install compiles and places the binary in GOPATH/bin
install:
$(GO) install \
$(EXTLDFLAGS) $(VENDOR_LDFLAG) \
./cmd/lachesis
$(GO) install \
$(EXTLDFLAGS) $(VENDOR_LDFLAG) \
./cmd/network
# build compiles and places the binary in /build
build:
$(GO) build \
$(VENDOR_LDFLAG) \
-o build/lachesis ./cmd/lachesis/main.go
$(GO) build \
$(VENDOR_LDFLAG) \
-o build/network ./cmd/network/
# dist builds binaries for all platforms and packages them for distribution
dist:
@BUILD_TAGS='$(BUILD_TAGS)' $(SH) -c "'$(CURDIR)/scripts/dist.sh'"
test: buildtests
$(GLIDE) novendor | $(GREP) -v -e "^\.$$" | CGO_ENABLED=1 $(XARGS) $(GO) test -run "Test.*" -count=$(TESTCOUNT) -v=$(VERBOSE) -tags test -race -timeout 600s
cover:
$(GLIDE) novendor | $(GREP) -v -e "^\.$$" | CGO_ENABLED=1 $(XARGS) $(GO) test -run "Test.*" -coverprofile=coverage.out -count=1 -tags test -race -timeout 600s || true
$(GO) tool cover -html=coverage.out -o coverage.html
$(BROWSER) coverage.html
coverage:
$(GLIDE) novendor | $(GREP) -v -e "^\.$$" | CGO_ENABLED=1 $(XARGS) $(GO) test -run "Test.*" -coverprofile=coverage.txt -covermode=atomic -count=1 -tags test -timeout 600s
# clean up and generate protobuf files
proto: clean
clean:
$(RM) -rf vendor glide.lock
.PHONY: $(TARGETS) $(SUBDIR_TARGETS) vendor install dist test cover buildtests
# static pattern rule, expands into:
# all clean : % : foo/.% bar/.%
$(TARGETS) : % : $(addsuffix %,$(SUBDIRS))
# here, for foo/.all:
# $(@D) is foo
# $(@F) is .all, with leading period
# $(@F:.%=%) is just all
$(SUBDIR_TARGETS) :
@$(MAKE) -C $(@D) $(@F:.%=%)