From 87bdfd6a70fd20b9fdcb269ab870c1ca09552873 Mon Sep 17 00:00:00 2001 From: Alexander Arlt Date: Thu, 15 Feb 2024 22:59:11 +0100 Subject: [PATCH 1/4] [buildsystem] Fix libstdlib to use CMAKE_CURRENT_SOURCE_DIR. --- libstdlib/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libstdlib/CMakeLists.txt b/libstdlib/CMakeLists.txt index 65a3a1cda16b..b6b22832d6e6 100644 --- a/libstdlib/CMakeLists.txt +++ b/libstdlib/CMakeLists.txt @@ -1,18 +1,18 @@ # This will re-generate the headers if any file within src was modified. -set_directory_properties(PROPERTY CMAKE_CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/stdlib/src/) +set_directory_properties(PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/) set(STDLIB stub) set(GENERATED_STDLIB_HEADERS) foreach(src IN LISTS STDLIB) - set(STDLIB_FILE ${PROJECT_SOURCE_DIR}/libstdlib/src/${src}.sol) + set(STDLIB_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/${src}.sol) file(READ ${STDLIB_FILE} STDLIB_FILE_CONTENT HEX) string(REGEX MATCHALL ".." STDLIB_FILE_CONTENT "${STDLIB_FILE_CONTENT}") list(REMOVE_ITEM STDLIB_FILE_CONTENT "0d") string(REGEX REPLACE ";" ",\n\t0x" STDLIB_FILE_CONTENT "${STDLIB_FILE_CONTENT}") set(STDLIB_FILE_CONTENT "0x${STDLIB_FILE_CONTENT}") set(STDLIB_FILE_NAME ${src}) - configure_file("${PROJECT_SOURCE_DIR}/libstdlib/stdlib.src.h.in" ${PROJECT_BINARY_DIR}/include/libstdlib/${src}.h NEWLINE_STYLE LF @ONLY) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/stdlib.src.h.in" ${PROJECT_BINARY_DIR}/include/libstdlib/${src}.h NEWLINE_STYLE LF @ONLY) list(APPEND GENERATED_STDLIB_HEADERS ${PROJECT_BINARY_DIR}/include/libstdlib/${src}.h) endforeach() -configure_file("${PROJECT_SOURCE_DIR}/libstdlib/stdlib.h.in" ${PROJECT_BINARY_DIR}/include/libstdlib/stdlib.h NEWLINE_STYLE LF @ONLY) +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/stdlib.h.in" ${PROJECT_BINARY_DIR}/include/libstdlib/stdlib.h NEWLINE_STYLE LF @ONLY) From b60ed2b96a6b00b2d23a2dd9caf98173527fc38f Mon Sep 17 00:00:00 2001 From: Alexander Arlt Date: Fri, 16 Feb 2024 18:00:41 +0100 Subject: [PATCH 2/4] [buildsystem] Add USE_SYSTEM_LIBRARIES option. --- CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e2a2b4a32f1..6609585a7ba4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,16 +37,19 @@ option(SOLC_STATIC_STDLIBS "Link solc against static versions of libgcc and libs option(STRICT_Z3_VERSION "Use the latest version of Z3" ON) option(PEDANTIC "Enable extra warnings and pedantic build flags. Treat all warnings as errors." ON) option(PROFILE_OPTIMIZER_STEPS "Output performance metrics for the optimiser steps." OFF) +option(USE_SYSTEM_LIBRARIES "Use system libraries" OFF) # Setup cccache. include(EthCcache) # Let's find our dependencies include(EthDependencies) -include(fmtlib) -include(jsoncpp) -include(range-v3) -include_directories(SYSTEM ${JSONCPP_INCLUDE_DIR}) +if (NOT USE_SYSTEM_LIBRARIES) + include(fmtlib) + include(jsoncpp) + include(range-v3) + include_directories(SYSTEM ${JSONCPP_INCLUDE_DIR}) +endif() find_package(Threads) From d178c40102f024f17e64c777b37729aec544409e Mon Sep 17 00:00:00 2001 From: Alexander Arlt Date: Fri, 16 Feb 2024 19:33:38 +0100 Subject: [PATCH 3/4] [buildsystem] Add ONLY_BUILD_SOLIDITY_LIBRARIES option. --- CMakeLists.txt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6609585a7ba4..142e884edd02 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,7 @@ option(STRICT_Z3_VERSION "Use the latest version of Z3" ON) option(PEDANTIC "Enable extra warnings and pedantic build flags. Treat all warnings as errors." ON) option(PROFILE_OPTIMIZER_STEPS "Output performance metrics for the optimiser steps." OFF) option(USE_SYSTEM_LIBRARIES "Use system libraries" OFF) +option(ONLY_BUILD_SOLIDITY_LIBRARIES "Only build solidity libraries" OFF) # Setup cccache. include(EthCcache) @@ -144,12 +145,16 @@ add_subdirectory(libyul) add_subdirectory(libsolidity) add_subdirectory(libsolc) add_subdirectory(libstdlib) -add_subdirectory(tools) -if (NOT EMSCRIPTEN) - add_subdirectory(solc) -endif() +if (NOT ONLY_BUILD_SOLIDITY_LIBRARIES) + add_subdirectory(tools) + + if (NOT EMSCRIPTEN) + add_subdirectory(solc) + endif() -if (TESTS AND NOT EMSCRIPTEN) - add_subdirectory(test) + if (TESTS AND NOT EMSCRIPTEN) + add_subdirectory(test) + endif() endif() + From 780018ad21656f04a6737b87965706e9dc4e8058 Mon Sep 17 00:00:00 2001 From: Alexander Arlt Date: Fri, 16 Feb 2024 19:40:56 +0100 Subject: [PATCH 4/4] [buildsystem] Add STRICT_JSONCPP_VERSION option. --- CMakeLists.txt | 5 +++++ libsolutil/JSON.cpp | 2 ++ 2 files changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 142e884edd02..b9f2ddc36cad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,7 @@ option(PEDANTIC "Enable extra warnings and pedantic build flags. Treat all warni option(PROFILE_OPTIMIZER_STEPS "Output performance metrics for the optimiser steps." OFF) option(USE_SYSTEM_LIBRARIES "Use system libraries" OFF) option(ONLY_BUILD_SOLIDITY_LIBRARIES "Only build solidity libraries" OFF) +option(STRICT_JSONCPP_VERSION "Strictly check installed jsoncpp version" ON) # Setup cccache. include(EthCcache) @@ -62,6 +63,10 @@ if (PROFILE_OPTIMIZER_STEPS) add_definitions(-DPROFILE_OPTIMIZER_STEPS) endif() +if (STRICT_JSONCPP_VERSION) + add_definitions(-DSTRICT_JSONCPP_VERSION_CHECK) +endif() + # Figure out what compiler and system are we using include(EthCompilerSettings) diff --git a/libsolutil/JSON.cpp b/libsolutil/JSON.cpp index ea75ada0f79f..3a2570d47ec1 100644 --- a/libsolutil/JSON.cpp +++ b/libsolutil/JSON.cpp @@ -30,10 +30,12 @@ #include #include +#ifdef STRICT_JSONCPP_VERSION_CHECK static_assert( (JSONCPP_VERSION_MAJOR == 1) && (JSONCPP_VERSION_MINOR == 9) && (JSONCPP_VERSION_PATCH == 3), "Unexpected jsoncpp version: " JSONCPP_VERSION_STRING ". Expecting 1.9.3." ); +#endif namespace solidity::util {