forked from status-im/nimbus-eth1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
331 lines (273 loc) · 10.8 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# Copyright (c) 2018-2022 Status Research & Development GmbH. Licensed under
# either of:
# - Apache License, version 2.0
# - MIT license
# at your option. This file may not be copied, modified, or distributed except
# according to those terms.
SHELL := bash # the shell used internally by "make"
# used inside the included makefiles
BUILD_SYSTEM_DIR := vendor/nimbus-build-system
LINK_PCRE := 0
EXCLUDED_NIM_PACKAGES := \
vendor/nimbus-eth2/vendor/nim-bearssl \
vendor/nimbus-eth2/vendor/nim-blscurve \
vendor/nimbus-eth2/vendor/nim-bearssl \
vendor/nimbus-eth2/vendor/nim-blscurve \
vendor/nimbus-eth2/vendor/nimbus-build-system \
vendor/nimbus-eth2/vendor/nim-chronicles \
vendor/nimbus-eth2/vendor/nim-chronos \
vendor/nimbus-eth2/vendor/nim-confutils \
vendor/nimbus-eth2/vendor/nimcrypto \
vendor/nimbus-eth2/vendor/nim-eth \
vendor/nimbus-eth2/vendor/nim-faststreams \
vendor/nimbus-eth2/vendor/nim-http-utils \
vendor/nimbus-eth2/vendor/nim-json-rpc \
vendor/nimbus-eth2/vendor/nim-json-serialization\
vendor/nimbus-eth2/vendor/nim-libbacktrace \
vendor/nimbus-eth2/vendor/nim-metrics \
vendor/nimbus-eth2/vendor/nim-nat-traversal \
vendor/nimbus-eth2/vendor/nim-secp256k1 \
vendor/nimbus-eth2/vendor/nim-serialization \
vendor/nimbus-eth2/vendor/nim-snappy \
vendor/nimbus-eth2/vendor/nim-sqlite3-abi \
vendor/nimbus-eth2/vendor/nim-ssz-serialization \
vendor/nimbus-eth2/vendor/nim-stew \
vendor/nimbus-eth2/vendor/nim-stint \
vendor/nimbus-eth2/vendor/nim-testutils \
vendor/nimbus-eth2/vendor/nim-toml-serialization\
vendor/nimbus-eth2/vendor/nim-unittest2 \
vendor/nimbus-eth2/vendor/nim-web3 \
vendor/nimbus-eth2/vendor/nim-websock \
vendor/nimbus-eth2/vendor/nim-zlib \
vendor/nimbus-eth2/vendor/nim-taskpools \
vendor/nimbus-eth2/vendor/nim-normalize \
vendor/nimbus-eth2/vendor/nim-unicodedb \
vendor/nimbus-eth2/vendor/nim-libp2p \
vendor/nimbus-eth2/vendor/nim-presto \
vendor/nimbus-eth2/vendor/nim-zxcvbn \
vendor/nimbus-eth2/vendor/nim-kzg4844 \
vendor/nimbus-eth2/vendor/nimbus-security-resources
# we don't want an error here, so we can handle things later, in the ".DEFAULT" target
-include $(BUILD_SYSTEM_DIR)/makefiles/variables.mk
# debugging tools + testing tools
TOOLS := \
test_tools_build
TOOLS_DIRS := \
tests
# comma-separated values for the "clean" target
TOOLS_CSV := $(subst $(SPACE),$(COMMA),$(TOOLS))
.PHONY: \
all \
$(TOOLS) \
deps \
update \
nimbus \
fluffy \
nimbus_verified_proxy \
test \
test-reproducibility \
clean \
libnimbus.so \
libnimbus.a \
libbacktrace \
dist-amd64 \
dist-arm64 \
dist-arm \
dist-win64 \
dist-macos \
dist-macos-arm64 \
dist
ifeq ($(NIM_PARAMS),)
# "variables.mk" was not included, so we update the submodules.
GIT_SUBMODULE_UPDATE := git submodule update --init --recursive
.DEFAULT:
+@ echo -e "Git submodules not found. Running '$(GIT_SUBMODULE_UPDATE)'.\n"; \
$(GIT_SUBMODULE_UPDATE); \
echo
# Now that the included *.mk files appeared, and are newer than this file, Make will restart itself:
# https://www.gnu.org/software/make/manual/make.html#Remaking-Makefiles
#
# After restarting, it will execute its original goal, so we don't have to start a child Make here
# with "$(MAKE) $(MAKECMDGOALS)". Isn't hidden control flow great?
else # "variables.mk" was included. Business as usual until the end of this file.
# default target, because it's the first one that doesn't start with '.'
all: | $(TOOLS) nimbus
# must be included after the default target
-include $(BUILD_SYSTEM_DIR)/makefiles/targets.mk
# default: use blst
USE_MIRACL := 0
# default: use nim native evm
ENABLE_EVMC := 0
# "-d:release" cannot be added to config.nims
NIM_PARAMS += -d:release
ifeq ($(BOEHM_GC),1)
NIM_PARAMS += --mm:boehm
endif
T8N_PARAMS := -d:chronicles_default_output_device=stderr
ifeq ($(USE_LIBBACKTRACE), 0)
NIM_PARAMS += -d:disable_libbacktrace
endif
deps: | deps-common nat-libs nimbus.nims
ifneq ($(USE_LIBBACKTRACE), 0)
deps: | libbacktrace
endif
ifneq ($(USE_MIRACL), 0)
NIM_PARAMS += -d:BLS_FORCE_BACKEND=miracl
endif
ifneq ($(ENABLE_EVMC), 0)
NIM_PARAMS += -d:evmc_enabled
T8N_PARAMS := -d:chronicles_enabled=off
endif
# disabled by default, enable with ENABLE_VMLOWMEM=1
ifneq ($(if $(ENABLE_VMLOWMEM),$(ENABLE_VMLOWMEM),0),0)
NIM_PARAMS += -d:lowmem:1
endif
# chunked messages enabled by default, use ENABLE_CHUNKED_RLPX=0 to disable
ifneq ($(if $(ENABLE_CHUNKED_RLPX),$(ENABLE_CHUNKED_RLPX),1),0)
NIM_PARAMS := $(NIM_PARAMS) -d:chunked_rlpx_enabled
endif
# legacy wire protocol enabled by default, use ENABLE_LEGACY_ETH66=0 to disable
ifneq ($(if $(ENABLE_LEGACY_ETH66),$(ENABLE_LEGACY_ETH66),1),0)
NIM_PARAMS := $(NIM_PARAMS) -d:legacy_eth66_enabled
endif
#- deletes and recreates "nimbus.nims" which on Windows is a copy instead of a proper symlink
update: | update-common
rm -rf nimbus.nims && \
$(MAKE) nimbus.nims $(HANDLE_OUTPUT)
# builds the tools, wherever they are
$(TOOLS): | build deps
for D in $(TOOLS_DIRS); do [ -e "$${D}/[email protected]" ] && TOOL_DIR="$${D}" && break; done && \
echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim c $(NIM_PARAMS) -o:build/$@ "$${TOOL_DIR}/[email protected]"
# a phony target, because teaching `make` how to do conditional recompilation of Nim projects is too complicated
nimbus: | build deps
echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim c $(NIM_PARAMS) -d:chronicles_log_level=TRACE -o:build/$@ "nimbus/[email protected]"
# symlink
nimbus.nims:
ln -s nimbus.nimble $@
# nim-libbacktrace
libbacktrace:
+ $(MAKE) -C vendor/nim-libbacktrace --no-print-directory BUILD_CXX_LIB=0
# builds and runs the nimbus test suite
test: | build deps
$(ENV_SCRIPT) nim test_rocksdb $(NIM_PARAMS) nimbus.nims
$(ENV_SCRIPT) nim test $(NIM_PARAMS) nimbus.nims
# builds and runs an EVM-related subset of the nimbus test suite
test-evm: | build deps
$(ENV_SCRIPT) nim test_evm $(NIM_PARAMS) nimbus.nims
# Primitive reproducibility test.
#
# On some platforms, with some GCC versions, it may not be possible to get a
# deterministic order for debugging info sections - even with
# "-frandom-seed=...". Striping the binaries should make them identical, though.
test-reproducibility:
+ [ -e build/nimbus ] || $(MAKE) V=0 nimbus; \
MD5SUM1=$$($(MD5SUM) build/nimbus | cut -d ' ' -f 1) && \
rm -rf nimcache/*/nimbus && \
$(MAKE) V=0 nimbus && \
MD5SUM2=$$($(MD5SUM) build/nimbus | cut -d ' ' -f 1) && \
[ "$$MD5SUM1" = "$$MD5SUM2" ] && echo -e "\e[92mSuccess: identical binaries.\e[39m" || \
{ echo -e "\e[91mFailure: the binary changed between builds.\e[39m"; exit 1; }
# Fluffy related targets
# builds the fluffy client
fluffy: | build deps
echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim fluffy $(NIM_PARAMS) nimbus.nims
lc-bridge: | build deps
echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim lc_bridge $(NIM_PARAMS) nimbus.nims
# primitive reproducibility test
fluffy-test-reproducibility:
+ [ -e build/fluffy ] || $(MAKE) V=0 fluffy; \
MD5SUM1=$$($(MD5SUM) build/fluffy | cut -d ' ' -f 1) && \
rm -rf nimcache/*/fluffy && \
$(MAKE) V=0 fluffy && \
MD5SUM2=$$($(MD5SUM) build/fluffy | cut -d ' ' -f 1) && \
[ "$$MD5SUM1" = "$$MD5SUM2" ] && echo -e "\e[92mSuccess: identical binaries.\e[39m" || \
{ echo -e "\e[91mFailure: the binary changed between builds.\e[39m"; exit 1; }
# builds and runs the fluffy test suite
fluffy-test: | build deps
$(ENV_SCRIPT) nim fluffy_test $(NIM_PARAMS) nimbus.nims
# builds the fluffy tools
fluffy-tools: | build deps
$(ENV_SCRIPT) nim fluffy_tools $(NIM_PARAMS) nimbus.nims
# builds the fluffy tools
utp-test-app: | build deps
$(ENV_SCRIPT) nim utp_test_app $(NIM_PARAMS) nimbus.nims
# builds and runs the utp integration test suite
utp-test: | build deps
$(ENV_SCRIPT) nim utp_test $(NIM_PARAMS) nimbus.nims
# Build fluffy test_portal_testnet
fluffy-test-portal-testnet: | build deps
$(ENV_SCRIPT) nim fluffy_test_portal_testnet $(NIM_PARAMS) nimbus.nims
# Nimbus Verified Proxy related targets
# Builds the nimbus_verified_proxy
nimbus_verified_proxy: | build deps
echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim nimbus_verified_proxy $(NIM_PARAMS) nimbus.nims
# builds and runs the nimbus_verified_proxy test suite
nimbus-verified-proxy-test: | build deps
$(ENV_SCRIPT) nim nimbus_verified_proxy_test $(NIM_PARAMS) nimbus.nims
# builds transition tool
t8n: | build deps
$(ENV_SCRIPT) nim c $(NIM_PARAMS) $(T8N_PARAMS) "tools/t8n/[email protected]"
# builds and runs transition tool test suite
t8n_test: | build deps t8n
$(ENV_SCRIPT) nim c -r $(NIM_PARAMS) -d:chronicles_default_output_device=stderr "tools/t8n/[email protected]"
# builds evm state test tool
evmstate: | build deps
$(ENV_SCRIPT) nim c $(NIM_PARAMS) "tools/evmstate/[email protected]"
# builds and runs evm state tool test suite
evmstate_test: | build deps evmstate
$(ENV_SCRIPT) nim c -r $(NIM_PARAMS) "tools/evmstate/[email protected]"
# builds txparse tool
txparse: | build deps
$(ENV_SCRIPT) nim c $(NIM_PARAMS) "tools/txparse/[email protected]"
# usual cleaning
clean: | clean-common
rm -rf build/{nimbus,fluffy,nimbus_verified_proxy,$(TOOLS_CSV),all_tests,test_kvstore_rocksdb,test_rpc,all_fluffy_tests,all_fluffy_portal_spec_tests,test_portal_testnet,portalcli,blockwalk,eth_data_exporter,utp_test_app,utp_test,*.dSYM}
rm -rf tools/t8n/{t8n,t8n_test}
rm -rf tools/evmstate/{evmstate,evmstate_test}
ifneq ($(USE_LIBBACKTRACE), 0)
+ $(MAKE) -C vendor/nim-libbacktrace clean $(HANDLE_OUTPUT)
endif
# Note about building Nimbus as a library:
#
# There were `wrappers`, `wrappers-static`, `libnimbus.so` and `libnimbus.a`
# target scripts here, and C and Go examples for calling the Nimbus library in
# directory `wrappers/`. They have been removed because they only wrapped
# Whisper protocol support, which has been removed as it is obsolete.
#
# This note is kept so that anyone wanting to build Nimbus as a library or call
# from C or Go will know it has been done before. The previous working version
# can be found in Git history. Look for the `nimbus-eth1` commit that adds
# this comment and removes `wrappers/*`.
dist-amd64:
+ MAKE="$(MAKE)" \
scripts/make_dist.sh amd64
dist-arm64:
+ MAKE="$(MAKE)" \
scripts/make_dist.sh arm64
# We get an ICE on RocksDB-7.0.2 with "arm-linux-gnueabihf-g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0"
# and with "arm-linux-gnueabihf-g++ (Ubuntu 10.3.0-1ubuntu1) 10.3.0".
#dist-arm:
#+ MAKE="$(MAKE)" \
#scripts/make_dist.sh arm
dist-win64:
+ MAKE="$(MAKE)" \
scripts/make_dist.sh win64
dist-macos:
+ MAKE="$(MAKE)" \
scripts/make_dist.sh macos
dist-macos-arm64:
+ MAKE="$(MAKE)" \
scripts/make_dist.sh macos-arm64
dist:
+ $(MAKE) --no-print-directory dist-amd64
+ $(MAKE) --no-print-directory dist-arm64
#+ $(MAKE) --no-print-directory dist-arm
+ $(MAKE) --no-print-directory dist-win64
+ $(MAKE) --no-print-directory dist-macos
+ $(MAKE) --no-print-directory dist-macos-arm64
endif # "variables.mk" was not included