-
Notifications
You must be signed in to change notification settings - Fork 91
/
Makefile
89 lines (63 loc) · 3.02 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
.PHONY: all clean
.PHONY: gvite-linux-amd64
.PHONY: gvite-linux-arm64
.PHONY: gvite-darwin
.PHONY: gvite-windows
.PHONY: build_version build
.PHONY: test
GO ?= latest
MAIN_DIR=gvite
WORK_DIR=$(shell pwd)
MAIN=$(shell pwd)/cmd/$(MAIN_DIR)/main.go
BUILD_ROOT_DIR=$(shell pwd)/build
VITE_GIT_COMMIT=$(shell git rev-parse HEAD)
VITE_VERSION=$(shell cat version/buildversion)
VITE_VERSION_FILE=$(shell pwd)/version/buildversion.go
BUILD_DIR=$(BUILD_ROOT_DIR)/cmd/$(MAIN_DIR)
BUILD_BIN=$(BUILD_DIR)/gvite
build_version:
@echo "package version" > $(VITE_VERSION_FILE)
@echo "const VITE_COMMIT_VERSION = "\"$(VITE_GIT_COMMIT)\" >> $(VITE_VERSION_FILE)
@echo "const VITE_BUILD_VERSION = "\"$(VITE_VERSION)\" >> $(VITE_VERSION_FILE)
@echo "gvite build version is "$(VITE_VERSION)", git commit is "$(VITE_GIT_COMMIT)"."
build:
GO111MODULE=on go build -o $(BUILD_BIN) $(MAIN)
@echo "Build gvite done."
@echo "Run $(BUILD_DIR)/gvite to start gvite."
test:
GO111MODULE=on go test ./common/upgrade
GO111MODULE=on go test ./ledger/pipeline
GO111MODULE=on go test ./tools/toposort
GO111MODULE=on go test ./vm
GO111MODULE=on go test ./wallet
GO111MODULE=on go test ./ledger/onroad/pool
build_linux_amd64:
env GOOS=linux CGO_ENABLED=0 GO111MODULE=on GOARCH=amd64 go build -o $(BUILD_DIR)/gvite-$(VITE_VERSION)-linux/gvite $(MAIN)
@cp $(shell pwd)/conf/node_config.json $(BUILD_DIR)/gvite-$(VITE_VERSION)-linux/node_config.json
@cp $(shell pwd)/bin/bootstrap_linux $(BUILD_DIR)/gvite-$(VITE_VERSION)-linux/bootstrap
@ls -d $(BUILD_DIR)/gvite-$(VITE_VERSION)-linux/gvite
@echo "Build linux version done."
build_linux_arm64:
env GOOS=linux CGO_ENABLED=0 GO111MODULE=on GOARCH=arm64 go build -o $(BUILD_DIR)/gvite-$(VITE_VERSION)-linux-arm64/gvite $(MAIN)
@cp $(shell pwd)/conf/node_config.json $(BUILD_DIR)/gvite-$(VITE_VERSION)-linux-arm64/node_config.json
@cp $(shell pwd)/bin/bootstrap_linux $(BUILD_DIR)/gvite-$(VITE_VERSION)-linux-arm64/bootstrap
@ls -d $(BUILD_DIR)/gvite-$(VITE_VERSION)-linux-arm64/gvite
@echo "Build linux-arm64 version done."
build_darwin:
env GOOS=darwin CGO_ENABLED=0 GO111MODULE=on GOARCH=amd64 go build -o $(BUILD_DIR)/gvite-$(VITE_VERSION)-darwin/gvite $(MAIN)
@cp $(shell pwd)/conf/node_config.json $(BUILD_DIR)/gvite-$(VITE_VERSION)-darwin/node_config.json
@ls -d $(BUILD_DIR)/gvite-$(VITE_VERSION)-darwin/gvite
@echo "Build darwin version done"
build_windows:
env GOOS=windows CGO_ENABLED=0 GO111MODULE=on GOARCH=amd64 go build -o $(BUILD_DIR)/gvite-$(VITE_VERSION)-windows/gvite-windows-amd64.exe $(MAIN)
@cp $(shell pwd)/conf/node_config.json $(BUILD_DIR)/gvite-$(VITE_VERSION)-windows/node_config.json
@ls -d $(BUILD_DIR)/gvite-$(VITE_VERSION)-windows/gvite-windows-amd64.exe
@echo "Build windows version done."
gvite-darwin: build_version build_darwin
gvite-linux: build_version build_linux_amd64
gvite-linux-arm64: build_version build_linux_arm64
gvite-windows: build_version build_windows
gvite: build_version build
all: gvite-windows gvite-darwin gvite-linux gvite-linux-arm64
clean:
rm -r $(BUILD_ROOT_DIR)/