forked from xuperchain/xuperchain
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
executable file
·87 lines (72 loc) · 1.89 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
# init project PATH
HOMEDIR := $(shell pwd)
OUTDIR := $(HOMEDIR)/output
COMPILECACHEDIR := $(HOMEDIR)/.compile_cache
XVMDIR := $(COMPILECACHEDIR)/xvm
TESTNETDIR := $(HOMEDIR)/testnet
LICENSEEYE := license-eye
GOINSTALL := go install
PIP := pip3
PIPINSTALL := $(PIP) install
VERSION:=$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown)
COMMIT_ID:=$(shell git rev-parse --short HEAD 2>/dev/null ||echo unknown)
# init command params
export GO111MODULE=on
X_ROOT_PATH := $(HOMEDIR)
export X_ROOT_PATH
export PATH := $(OUTDIR)/bin:$(XVMDIR):$(PATH)
# make, make all
all: clean compile
# make compile, go build
compile: xvm xchain
xchain:
VERSION=$(VERSION) COMMIT_ID=$(COMMIT_ID) bash $(HOMEDIR)/auto/build.sh
prepare:
go env -w GOPROXY=https://goproxy.cn,direct
go mod download
# make xvm
xvm:
bash $(HOMEDIR)/auto/build_xvm.sh
# make test, test your code
test: xvm unit
unit:
go test -coverprofile=coverage.txt -covermode=atomic ./...
# make clean
cleanall: clean cleantest cleancache
clean:
rm -rf $(OUTDIR)
cleantest:
rm -rf $(TESTNETDIR)
cleancache:
rm -rf $(COMPILECACHEDIR)
# deploy test network
testnet:
bash $(HOMEDIR)/auto/deploy_testnet.sh
# Docker related tasks
build-image:
docker build -t xchain:dev .
# make deps
deps:
$(call PIP_INSTALL_PKG, pre-commit)
$(call INSTALL_PKG, license-eye, github.com/apache/skywalking-eyes/cmd/license-eye@latest)
# go install package
# $(1) package name
# $(2) package address
define INSTALL_PKG
@echo installing $(1)
$(GOINSTALL) $(2)
@echo $(1) installed
endef
define PIP_INSTALL_PKG
@echo installing $(1)
$(PIPINSTALL) $(1)
@echo $(1) installed
endef
# make license-check, check code file's license declaration
license-check:
$(LICENSEEYE) header check
# make license-fix, fix code file's license declaration
license-fix:
$(LICENSEEYE) header fix
# avoid filename conflict and speed up build
.PHONY: all compile test clean