@@ -54,11 +54,14 @@ endif
5454
5555# unconditionally built by the default Make target
5656# TODO re-enable ncli_query if/when it works again
57+ TOOLS_CORE_CUSTOMCOMPILE := \
58+ libnimbus_lc.a
59+
5760TOOLS_CORE := \
5861 deposit_contract \
5962 resttest \
6063 logtrace \
61- mev_mock \
64+ mev_mock \
6265 ncli \
6366 ncli_db \
6467 ncli_split_keystore \
@@ -69,7 +72,8 @@ TOOLS_CORE := \
6972 nimbus_validator_client \
7073 nimbus_signing_node \
7174 validator_db_aggregator \
72- ncli_testnet
75+ ncli_testnet \
76+ $(TOOLS_CORE_CUSTOMCOMPILE )
7377
7478# This TOOLS/TOOLS_CORE decomposition is a workaroud so nimbus_beacon_node can
7579# build on its own, and if/when that becomes a non-issue, it can be recombined
@@ -280,7 +284,8 @@ XML_TEST_BINARIES := \
280284# test suite
281285TEST_BINARIES := \
282286 state_sim \
283- block_sim
287+ block_sim \
288+ test_libnimbus_lc
284289.PHONY : $(TEST_BINARIES ) $(XML_TEST_BINARIES ) force_build_alone_all_tests
285290
286291# Preset-dependent tests
@@ -392,14 +397,23 @@ endif
392397 rm -rf 0000-*.json t_slashprot_migration.* *.log block_sim_db
393398 for TEST_BINARY in $(TEST_BINARIES); do \
394399 PARAMS=""; \
400+ REDIRECT=""; \
395401 if [[ "$${TEST_BINARY}" == "state_sim" ]]; then PARAMS="--validators=8000 --slots=160"; \
396402 elif [[ "$${TEST_BINARY}" == "block_sim" ]]; then PARAMS="--validators=8000 --slots=160"; \
403+ elif [[ "$${TEST_BINARY}" == "test_libnimbus_lc" ]]; then REDIRECT="$${TEST_BINARY}.log"; \
397404 fi; \
398405 echo -e "\nRunning $${TEST_BINARY} $${PARAMS}\n"; \
399- build/$${TEST_BINARY} $${PARAMS} || { \
400- echo -e "\n$${TEST_BINARY} $${PARAMS} failed; Last 50 lines from the log:"; \
401- tail -n50 "$${TEST_BINARY}.log"; exit 1; \
402- }; \
406+ if [[ "$${REDIRECT}" != "" ]]; then \
407+ build/$${TEST_BINARY} $${PARAMS} > "$${REDIRECT}" && echo "OK" || { \
408+ echo -e "\n$${TEST_BINARY} $${PARAMS} failed; Last 50 lines from the log:"; \
409+ tail -n50 "$${TEST_BINARY}.log"; exit 1; \
410+ }; \
411+ else \
412+ build/$${TEST_BINARY} $${PARAMS} || { \
413+ echo -e "\n$${TEST_BINARY} $${PARAMS} failed; Last 50 lines from the log:"; \
414+ tail -n50 "$${TEST_BINARY}.log"; exit 1; \
415+ }; \
416+ fi; \
403417 done; \
404418 rm -rf 0000-*.json t_slashprot_migration.* *.log block_sim_db
405419
@@ -419,7 +433,7 @@ build/generate_makefile: tools/generate_makefile.nim | deps-common
419433# It also requires Make to pass open file descriptors to the GCC process,
420434# which is not possible if we let Nim handle this, so we generate and use a
421435# makefile instead.
422- $(TOOLS ) : | build deps
436+ $(filter-out $( TOOLS_CORE_CUSTOMCOMPILE ) , $( TOOLS ) ) : | build deps
423437 + for D in $( TOOLS_DIRS) ; do [ -e " $$ {D}/$@ .nim" ] && TOOL_DIR=" $$ {D}" && break ; done && \
424438 echo -e $(BUILD_MSG ) " build/$@ " && \
425439 MAKE=" $( MAKE) " V=" $( V) " $(ENV_SCRIPT ) scripts/compile_nim_program.sh $@ " $$ {TOOL_DIR}/$@ .nim" $(NIM_PARAMS ) && \
@@ -728,6 +742,34 @@ gnosis-chain-dev-deposit: | gnosis-build deposit_contract
728742clean-gnosis-chain :
729743 $(call CLEAN_NETWORK,gnosis-chain)
730744
745+ # ##
746+ # ## libnimbus_lc
747+ # ##
748+
749+ libnimbus_lc.a : | build deps
750+ + echo -e $(BUILD_MSG ) " build/$@ " && \
751+ set -x && \
752+ rm -f build/$@ && \
753+ $(ENV_SCRIPT ) $(NIMC ) c -d:disable_libbacktrace -d:release --app:staticlib --noMain --nimcache:nimcache/libnimbus_lc_static -o:build/$@ $(NIM_PARAMS ) beacon_chain/libnimbus_lc/libnimbus_lc.nim $(SILENCE_WARNINGS ) && \
754+ echo -e $(BUILD_END_MSG ) " build/$@ "
755+
756+ # `-Wno-maybe-uninitialized` in Linux: https://github.com/nim-lang/Nim/issues/22246
757+ test_libnimbus_lc : libnimbus_lc.a
758+ + echo -e $(BUILD_MSG ) " build/$@ " && \
759+ set -x && \
760+ case " $$ (uname)" in \
761+ Darwin) \
762+ clang -D__DIR__=" \" beacon_chain/libnimbus_lc\" " --std=c17 -Weverything -Werror -Wno-declaration-after-statement -Wno-nullability-extension -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -o build/test_libnimbus_lc beacon_chain/libnimbus_lc/test_libnimbus_lc.c build/libnimbus_lc.a -framework Security; \
763+ ;; \
764+ MINGW64_* ) \
765+ gcc -D__DIR__=" \" beacon_chain/libnimbus_lc\" " --std=c17 -Wall -Wextra -pedantic -Werror -pedantic-errors -flto -o build/test_libnimbus_lc -D_CRT_SECURE_NO_WARNINGS beacon_chain/libnimbus_lc/test_libnimbus_lc.c build/libnimbus_lc.a; \
766+ ;; \
767+ * ) \
768+ gcc -D__DIR__=" \" beacon_chain/libnimbus_lc\" " --std=c17 -Wall -Wextra -pedantic -Werror -pedantic-errors -Wno-maybe-uninitialized -flto -o build/test_libnimbus_lc beacon_chain/libnimbus_lc/test_libnimbus_lc.c build/libnimbus_lc.a; \
769+ ;; \
770+ esac && \
771+ echo -e $(BUILD_END_MSG ) " build/$@ "
772+
731773# ##
732774# ## Other
733775# ##
0 commit comments