forked from iost-official/go-iost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
162 lines (125 loc) · 4.41 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
GO = go
GO_BUILD = $(GO) build
GO_TEST := $(GO) test -timeout 600s
GO_INSTALL := $(GO) install
PROJECT_NAME := $(shell basename "$(PWD)")
BUILDER_VERSION = 3.9.0
VERSION = 3.9.1
COMMIT = $(shell git rev-parse --short HEAD)
PROJECT = github.com/iost-official/go-iost
DOCKER_IMAGE = iostio/iost-node:$(VERSION)-$(COMMIT)
DOCKER_RELEASE_IMAGE = iostio/iost-node:$(VERSION)
DOCKER_DEVIMAGE = iostio/iost-dev:$(BUILDER_VERSION)
TARGET_DIR = target
DEV_DOCKER_RUN = docker run --rm -v `pwd`:/go-iost $(DOCKER_DEVIMAGE)
export GOBASE = $(shell pwd)
export GOARCH=amd64
export CGO_ENABLED=1
ifeq ($(shell uname),Darwin)
#export CGO_LDFLAGS=-L$(shell pwd)/vm/v8vm/v8/libv8/_darwin_amd64
#export CGO_CFLAGS=-I$(shell pwd)/vm/v8vm/v8/include/_darwin_amd64
export DYLD_LIBRARY_PATH=$(shell pwd)/vm/v8vm/v8/libv8/_darwin_amd64
GO_TEST := $(GO_TEST) -exec "env DYLD_LIBRARY_PATH=$(DYLD_LIBRARY_PATH)"
endif
ifeq ($(shell uname),Linux)
export CGO_LDFLAGS=-L$(shell pwd)/vm/v8vm/v8/libv8/_linux_amd64
export CGO_CFLAGS=-I$(shell pwd)/vm/v8vm/v8/include/_linux_amd64
export LD_LIBRARY_PATH=$(shell pwd)/vm/v8vm/v8/libv8/_linux_amd64
GO_TEST := $(GO_TEST) -race
endif
BUILD_TIME := $(shell date +%Y%m%d_%H%M%S%z)
LD_FLAGS := -X github.com/iost-official/go-iost/v3/core/global.BuildTime=$(BUILD_TIME) -X github.com/iost-official/go-iost/v3/core/global.GitHash=$(shell git rev-parse HEAD) -X github.com/iost-official/go-iost/v3/core/global.CodeVersion=$(VERSION)
.PHONY: all build iserver iwallet itest lint test e2e_test image push devimage swagger protobuf install clean debug clear_debug_file env
all: build
build: iserver iwallet itest
iserver: $(eval SHELL:=/bin/bash)
$(GO_BUILD) -ldflags "$(LD_FLAGS)" -o $(TARGET_DIR)/iserver ./cmd/iserver
@if [[ "`uname`" == "Darwin"* ]]; then \
echo change libvm dylib path; \
install_name_tool -change libvm.dylib $(DYLD_LIBRARY_PATH)/libvm.dylib ./target/iserver; \
fi
iwallet:
$(GO_BUILD) -o $(TARGET_DIR)/iwallet ./cmd/iwallet
itest:
$(GO_BUILD) -o $(TARGET_DIR)/itest ./cmd/itest
format:
find . -name "*.go" |grep -v vendor |xargs gofmt -s -w
lint-tool:
env GOARCH= go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
lint:
golangci-lint run
vmlib:
(cd vm/v8vm/v8/; make clean js_bin vm install; cd ../../..)
vmlib_install:
(cd vm/v8vm/v8/; make deploy; cd ../../..)
vmlib_linux:
$(DEV_DOCKER_RUN) bash -c 'cd vm/v8vm/v8/ && make clean js_bin vm install'
test:
$(GO) clean -testcache
ifeq ($(origin VERBOSE),undefined)
$(GO_TEST) ./...
else
$(GO_TEST) -v ./...
endif
e2e_test_local: clear_debug_file build
target/iserver -f config/iserver.yml &
sleep 20
$(TARGET_DIR)/itest run a_case
$(TARGET_DIR)/itest run t_case
$(TARGET_DIR)/itest run c_case
killall iserver
e2e_test: image
docker rm -f iserver || true
docker run -d --name iserver $(DOCKER_IMAGE)
sleep 20
docker exec -it iserver ./itest run a_case
docker exec -it iserver ./itest run t_case
docker exec -it iserver ./itest run c_case
image:
$(DEV_DOCKER_RUN) make BUILD_TIME=$(BUILD_TIME)
docker build -f Dockerfile.run -t $(DOCKER_IMAGE) .
release_image:
$(DEV_DOCKER_RUN) make BUILD_TIME=$(BUILD_TIME)
docker build -f Dockerfile -t $(DOCKER_RELEASE_IMAGE) .
push:
docker push $(DOCKER_IMAGE)
devimage:
docker build -f Dockerfile.dev -t $(DOCKER_DEVIMAGE) .
docker_build:
$(DEV_DOCKER_RUN) make build
docker_lint:
$(DEV_DOCKER_RUN) make lint
docker_test:
$(DEV_DOCKER_RUN) make test
dev_image_tag:
docker tag $(DOCKER_DEVIMAGE) iostio/iost-dev:latest
docker_full_test: devimage dev_image_tag image docker_lint docker_test e2e_test
devpush: dev_image_tag
docker push $(DOCKER_DEVIMAGE)
docker push iostio/iost-dev:latest
release: release_image
docker push $(DOCKER_RELEASE_IMAGE)
docker tag $(DOCKER_RELEASE_IMAGE) iostio/iost-node:latest
docker push iostio/iost-node:latest
protobuf:
env GOARCH= ./script/gen_protobuf.sh
install:
$(GO_INSTALL) -ldflags "$(LD_FLAGS)" ./cmd/iserver/
$(GO_INSTALL) ./cmd/iwallet/
$(GO_INSTALL) ./cmd/itest/
clean:
rm -rf ${TARGET_DIR}
debug: build
target/iserver -f config/iserver.yml
clear_debug_file:
rm -rf storage logs ilog/logs1 ilog/logs2
rm -f p2p/priv.key
rm -f p2p/routing.table
env:
@echo export GOBASE=$(GOBASE)
@echo export GOARCH=$(GOARCH)
@echo export CGO_ENABLED=$(CGO_ENABLED)
@echo export CGO_CFLAGS=$(CGO_CFLAGS)
@echo export CGO_LDFLAGS=$(CGO_LDFLAGS)
@echo export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH)
@echo export DYLD_LIBRARY_PATH=$(DYLD_LIBRARY_PATH)