-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
129 lines (98 loc) · 4.44 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
ifndef GOOS
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
GOOS := darwin
else ifeq ($(UNAME_S),Linux)
GOOS := linux
else
$(error "$$GOOS is not defined. If you are using Windows, try to re-make using 'GOOS=windows make ...' ")
endif
endif
PACKAGES := $(shell go list ./... | grep -v '/vendor/' | grep -v '/crypto/ed25519/chainkd' | grep -v '/mining/tensority')
BUILD_FLAGS := -ldflags "-X github.com/bytom/vapor/version.GitCommit=`git rev-parse HEAD`"
VAPORD_BINARY32 := vapord-$(GOOS)_386
VAPORD_BINARY64 := vapord-$(GOOS)_amd64
VAPORCLI_BINARY32 := vaporcli-$(GOOS)_386
VAPORCLI_BINARY64 := vaporcli-$(GOOS)_amd64
VERSION := $(shell awk -F= '/Version =/ {print $$2}' version/version.go | tr -d "\" ")
VAPORD_RELEASE32 := vapord-$(VERSION)-$(GOOS)_386
VAPORD_RELEASE64 := vapord-$(VERSION)-$(GOOS)_amd64
VAPORCLI_RELEASE32 := vaporcli-$(VERSION)-$(GOOS)_386
VAPORCLI_RELEASE64 := vaporcli-$(VERSION)-$(GOOS)_amd64
VAPOR_RELEASE32 := vapor-$(VERSION)-$(GOOS)_386
VAPOR_RELEASE64 := vapor-$(VERSION)-$(GOOS)_amd64
all: test target release-all install
fedd:
@echo "Building fedd to cmd/fedd/fedd"
@go build $(BUILD_FLAGS) -o cmd/fedd/fedd cmd/fedd/main.go
precognitive:
@echo "Building precognitive to cmd/precognitive/precognitive"
@go build $(BUILD_FLAGS) -o cmd/precognitive/precognitive cmd/precognitive/main.go
vapord:
@echo "Building vapord to cmd/vapord/vapord"
@go build $(BUILD_FLAGS) -o cmd/vapord/vapord cmd/vapord/main.go
vaporcli:
@echo "Building vaporcli to cmd/vaporcli/vaporcli"
@go build $(BUILD_FLAGS) -o cmd/vaporcli/vaporcli cmd/vaporcli/main.go
install:
@echo "Installing vapord and vaporcli to $(GOPATH)/bin"
@go install ./cmd/vapord
@go install ./cmd/vaporcli
target:
mkdir -p $@
binary: target/$(VAPORD_BINARY32) target/$(VAPORD_BINARY64) target/$(VAPORCLI_BINARY32) target/$(VAPORCLI_BINARY64)
ifeq ($(GOOS),windows)
release: binary
cd target && cp -f $(VAPORD_BINARY32) $(VAPORD_BINARY32).exe
cd target && cp -f $(VAPORCLI_BINARY32) $(VAPORCLI_BINARY32).exe
cd target && md5sum $(VAPORD_BINARY32).exe $(VAPORCLI_BINARY32).exe >$(VAPOR_RELEASE32).md5
cd target && zip $(VAPOR_RELEASE32).zip $(VAPORD_BINARY32).exe $(VAPORCLI_BINARY32).exe $(VAPOR_RELEASE32).md5
cd target && rm -f $(VAPORD_BINARY32) $(VAPORCLI_BINARY32) $(VAPORD_BINARY32).exe $(VAPORCLI_BINARY32).exe $(VAPOR_RELEASE32).md5
cd target && cp -f $(VAPORD_BINARY64) $(VAPORD_BINARY64).exe
cd target && cp -f $(VAPORCLI_BINARY64) $(VAPORCLI_BINARY64).exe
cd target && md5sum $(VAPORD_BINARY64).exe $(VAPORCLI_BINARY64).exe >$(VAPOR_RELEASE64).md5
cd target && zip $(VAPOR_RELEASE64).zip $(VAPORD_BINARY64).exe $(VAPORCLI_BINARY64).exe $(VAPOR_RELEASE64).md5
cd target && rm -f $(VAPORD_BINARY64) $(VAPORCLI_BINARY64) $(VAPORD_BINARY64).exe $(VAPORCLI_BINARY64).exe $(VAPOR_RELEASE64).md5
else
release: binary
cd target && md5sum $(VAPORD_BINARY32) $(VAPORCLI_BINARY32) >$(VAPOR_RELEASE32).md5
cd target && tar -czf $(VAPOR_RELEASE32).tgz $(VAPORD_BINARY32) $(VAPORCLI_BINARY32) $(VAPOR_RELEASE32).md5
cd target && rm -f $(VAPORD_BINARY32) $(VAPORCLI_BINARY32) $(VAPOR_RELEASE32).md5
cd target && md5sum $(VAPORD_BINARY64) $(VAPORCLI_BINARY64) >$(VAPOR_RELEASE64).md5
cd target && tar -czf $(VAPOR_RELEASE64).tgz $(VAPORD_BINARY64) $(VAPORCLI_BINARY64) $(VAPOR_RELEASE64).md5
cd target && rm -f $(VAPORD_BINARY64) $(VAPORCLI_BINARY64) $(VAPOR_RELEASE64).md5
endif
release-all: clean
GOOS=darwin make release
GOOS=linux make release
GOOS=windows make release
clean:
@echo "Cleaning binaries built..."
@rm -rf cmd/vapord/vapord
@rm -rf cmd/vaporcli/vaporcli
@rm -rf target
@rm -rf $(GOPATH)/bin/vapord
@rm -rf $(GOPATH)/bin/vaporcli
@echo "Cleaning temp test data..."
@rm -rf test/pseudo_hsm*
@rm -rf blockchain/pseudohsm/testdata/pseudo/
@echo "Cleaning sm2 pem files..."
@rm -rf crypto/sm2/*.pem
@echo "Done."
target/$(VAPORD_BINARY32):
CGO_ENABLED=0 GOARCH=386 go build $(BUILD_FLAGS) -o $@ cmd/vapord/main.go
target/$(VAPORD_BINARY64):
CGO_ENABLED=0 GOARCH=amd64 go build $(BUILD_FLAGS) -o $@ cmd/vapord/main.go
target/$(VAPORCLI_BINARY32):
CGO_ENABLED=0 GOARCH=386 go build $(BUILD_FLAGS) -o $@ cmd/vaporcli/main.go
target/$(VAPORCLI_BINARY64):
CGO_ENABLED=0 GOARCH=amd64 go build $(BUILD_FLAGS) -o $@ cmd/vaporcli/main.go
test:
@echo "====> Running go test"
@go test -tags "network" $(PACKAGES)
benchmark:
@go test -bench $(PACKAGES)
functional-tests:
@go test -timeout=5m -tags="functional" ./test
ci: test
.PHONY: all target release-all clean test benchmark