Skip to content

Commit

Permalink
Use submodules for some dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
aarlt committed Jul 30, 2024
1 parent e0fb91f commit 24dbe1c
Show file tree
Hide file tree
Showing 16 changed files with 76 additions and 86 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ jobs:
name: Check spelling
command: |
~/.local/bin/codespell \
--skip "*.enc,.git,Dockerfile*,LICENSE,codespell_whitelist.txt,codespell_ignored_lines.txt" \
--skip "*.enc,.git,Dockerfile*,LICENSE,codespell_whitelist.txt,codespell_ignored_lines.txt,deps" \
--ignore-words scripts/codespell_whitelist.txt \
--exclude-file scripts/codespell_ignored_lines.txt
- matrix_notify_failure_unless_pr
Expand Down Expand Up @@ -1273,7 +1273,7 @@ jobs:
- run:
name: Install runtime dependencies
command: |
pacman --noconfirm -Syu --noprogressbar --needed z3
pacman --noconfirm -Syu --noprogressbar --needed z3 git
- soltest

t_ubu_clang_soltest: &t_ubu_clang_soltest
Expand Down
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "deps/nlohmann-json"]
path = deps/nlohmann-json
url = https://github.com/nlohmann/json.git
[submodule "deps/range-v3"]
path = deps/range-v3
url = https://github.com/ericniebler/range-v3.git
[submodule "deps/fmtlib"]
path = deps/fmtlib
url = https://github.com/fmtlib/fmt.git
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Bugfixes:
* Yul Optimizer: Name simplification could lead to forbidden identifiers with a leading and/or trailing dot, e.g., ``x._`` would get simplified into ``x.``.
* Yul Parser: Fix segfault when parsing very long location comments.

Build System:
* Change build system to use git submodules for some dependencies (nlohmann-json, fmtlib & range-v3).

### 0.8.26 (2024-05-21)

Expand Down
42 changes: 42 additions & 0 deletions cmake/EthDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,45 @@ foreach (BOOST_COMPONENT IN LISTS BOOST_COMPONENTS)
get_property(LOCATION TARGET Boost::${BOOST_COMPONENT} PROPERTY IMPORTED_LOCATION)
message(STATUS "Found Boost::${BOOST_COMPONENT} at ${LOCATION}")
endforeach()

if(NOT USE_SYSTEM_LIBRARIES)
file(GLOB fmtlib_contents "${CMAKE_SOURCE_DIR}/deps/fmtlib/*")
file(GLOB nlohmannjson_contents "${CMAKE_SOURCE_DIR}/deps/nlohmann-json/*")
file(GLOB rangev3_contents "${CMAKE_SOURCE_DIR}/deps/range-v3/*")

if (fmtlib_contents AND nlohmannjson_contents AND rangev3_contents)
message(STATUS "git submodules seem to be already initialized: nothing to do.")
else()
message(STATUS "git submodules seem not to be initialized: implicitly executing 'git submodule update --init'.")
find_package(Git)
if (NOT Git_FOUND)
message(FATAL_ERROR "Failed to initialize submodules: 'git' command not found.")
endif()
execute_process(
COMMAND git submodule update --init
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE result
)
if(NOT result EQUAL 0)
message(FATAL_ERROR "Failed to initialize submodules: 'git submodule update --init' failed.")
endif()
endif()

if (NOT WIN32)
file(GLOB potential_submodules "${CMAKE_SOURCE_DIR}/deps/*")
set(expected_potential_submodule_count 3)
set(potential_submodule_count 0)
foreach(ITEM ${potential_submodules})
if(IS_DIRECTORY ${ITEM})
math(EXPR potential_submodule_count "${potential_submodule_count} + 1")
endif()
endforeach()
if (NOT ${potential_submodule_count} EQUAL ${expected_potential_submodule_count})
message(WARNING
"There are more directories (potential submodules) found (${potential_submodule_count}) in '${CMAKE_SOURCE_DIR}/deps' than expected (${expected_potential_submodule_count}). "
"This is just a reminder to potentially update e.g. '${CMAKE_SOURCE_DIR}/cmake/EthDependencies.cmake'."
)
endif()
endif()
endif()

23 changes: 4 additions & 19 deletions cmake/fmtlib.cmake
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
include(FetchContent)

FetchContent_Declare(
fmtlib
PREFIX "${PROJECT_BINARY_DIR}/deps"
DOWNLOAD_DIR "${PROJECT_SOURCE_DIR}/deps/downloads"
DOWNLOAD_NAME fmt-9.1.0.tar.gz
URL https://github.com/fmtlib/fmt/archive/9.1.0.tar.gz
URL_HASH SHA256=5dea48d1fcddc3ec571ce2058e13910a0d4a6bab4cc09a809d8b1dd1c88ae6f2
set(FMT_SYSTEM_HEADERS ON)
add_subdirectory(
${CMAKE_SOURCE_DIR}/deps/fmtlib
EXCLUDE_FROM_ALL
)

if (CMAKE_VERSION VERSION_LESS "3.14.0")
FetchContent_GetProperties(fmtlib)
if (NOT fmtlib_POPULATED)
FetchContent_Populate(fmtlib)
add_subdirectory(${fmtlib_SOURCE_DIR} ${fmtlib_BINARY_DIR})
endif()
else()
FetchContent_MakeAvailable(fmtlib)
endif()
23 changes: 4 additions & 19 deletions cmake/nlohmann-json.cmake
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
include(ExternalProject)

ExternalProject_Add(nlohmann-json-project
DOWNLOAD_DIR "${CMAKE_SOURCE_DIR}/deps/nlohmann/nlohmann"
DOWNLOAD_NAME json.hpp
DOWNLOAD_NO_EXTRACT 1
URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.hpp
URL_HASH SHA256=9bea4c8066ef4a1c206b2be5a36302f8926f7fdc6087af5d20b417d0cf103ea6
CMAKE_COMMAND true
BUILD_COMMAND true
INSTALL_COMMAND true
set(JSON_Install OFF CACHE INTERNAL "")
add_subdirectory(
${CMAKE_SOURCE_DIR}/deps/nlohmann-json
EXCLUDE_FROM_ALL
)

# Create nlohmann-json imported library
add_library(nlohmann-json INTERFACE IMPORTED)
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/deps/nlohmann) # Must exist.
set_target_properties(nlohmann-json PROPERTIES
INTERFACE_COMPILE_OPTIONS "\$<\$<CXX_COMPILER_ID:MSVC>:/permissive->"
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/deps/nlohmann
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/deps/nlohmann)
add_dependencies(nlohmann-json nlohmann-json-project)
39 changes: 4 additions & 35 deletions cmake/range-v3.cmake
Original file line number Diff line number Diff line change
@@ -1,38 +1,7 @@
include(ExternalProject)

if (${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
set(RANGE_V3_CMAKE_COMMAND emcmake cmake)
else()
set(RANGE_V3_CMAKE_COMMAND ${CMAKE_COMMAND})
endif()

set(prefix "${PROJECT_BINARY_DIR}/deps")
set(RANGE_V3_INCLUDE_DIR "${prefix}/include")

ExternalProject_Add(range-v3-project
PREFIX "${prefix}"
DOWNLOAD_DIR "${PROJECT_SOURCE_DIR}/deps/downloads"
DOWNLOAD_NAME range-v3-0.12.0.tar.gz
URL https://github.com/ericniebler/range-v3/archive/0.12.0.tar.gz
URL_HASH SHA256=015adb2300a98edfceaf0725beec3337f542af4915cec4d0b89fa0886f4ba9cb
CMAKE_COMMAND ${RANGE_V3_CMAKE_COMMAND}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DBUILD_TESTING=OFF
-DRANGES_CXX_STD=${CMAKE_CXX_STANDARD}
-DRANGE_V3_DOCS=OFF
-DRANGE_V3_EXAMPLES=OFF
-DRANGE_V3_TESTS=OFF
-DRANGES_BUILD_CALENDAR_EXAMPLE=OFF
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
BUILD_BYPRODUCTS "${RANGE_V3_INCLUDE_DIR}/range/v3/all.hpp"
)

# Create range-v3 imported library
add_library(range-v3 INTERFACE IMPORTED)
file(MAKE_DIRECTORY ${RANGE_V3_INCLUDE_DIR}) # Must exist.
set_target_properties(range-v3 PROPERTIES
INTERFACE_COMPILE_OPTIONS "\$<\$<CXX_COMPILER_ID:MSVC>:/permissive->"
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${RANGE_V3_INCLUDE_DIR}
INTERFACE_INCLUDE_DIRECTORIES ${RANGE_V3_INCLUDE_DIR})
INTERFACE_COMPILE_OPTIONS "\$<\$<CXX_COMPILER_ID:MSVC>:/permissive->"
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/deps/range-v3/include
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/deps/range-v3/include
)
add_dependencies(range-v3 range-v3-project)
1 change: 1 addition & 0 deletions deps/fmtlib
Submodule fmtlib added at a33701
1 change: 1 addition & 0 deletions deps/nlohmann-json
Submodule nlohmann-json added at 9cca28
1 change: 1 addition & 0 deletions deps/range-v3
Submodule range-v3 added at a81477
2 changes: 1 addition & 1 deletion libsolutil/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ set(sources
)

add_library(solutil ${sources})
target_link_libraries(solutil PUBLIC Boost::boost Boost::filesystem Boost::system range-v3 fmt::fmt-header-only nlohmann-json)
target_link_libraries(solutil PUBLIC Boost::boost Boost::filesystem Boost::system range-v3 fmt::fmt-header-only nlohmann_json::nlohmann_json)
target_include_directories(solutil PUBLIC "${PROJECT_SOURCE_DIR}")
add_dependencies(solutil solidity_BuildInfo.h)

Expand Down
1 change: 1 addition & 0 deletions scripts/check_style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ERROR_LOG="$(mktemp -t check_style_XXXXXX.log)"

EXCLUDE_FILES=(
# The line below is left unquoted to allow the shell globbing path expansion
deps/*
test/cmdlineTests/*/{err,output}
"libsolutil/picosha2.h"
"test/cmdlineTests/strict_asm_only_cr/input.yul"
Expand Down
2 changes: 1 addition & 1 deletion scripts/chk_shellscripts/chk_shellscripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ if [ ! -f "${SHELLCHECK}" ]; then
exit 1
fi

mapfile -t FILES < <(find . -type f -name "*.sh")
mapfile -t FILES < <(find . -type f -name "*.sh" -not -path "./deps/*")
"${SHELLCHECK}" "${FILES[@]}"
2 changes: 2 additions & 0 deletions scripts/create_source_tarball.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ REPO_ROOT="$(dirname "$0")"/..
mkdir "$SOLDIR"
# Store the current source
git checkout-index -a --prefix="$SOLDIR"
# shellcheck disable=SC2016
SOLDIR="$SOLDIR" git submodule foreach 'git checkout-index -a --prefix="$SOLDIR/$sm_path/"'
# Store the commit hash
echo "$commithash" > "$SOLDIR/commit_hash.txt"
if [ -e prerelease.txt ] && [ ! -s prerelease.txt ]
Expand Down
3 changes: 1 addition & 2 deletions scripts/install_evmone.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ $progressPreference = "silentlyContinue"

Invoke-WebRequest -URI "https://github.com/ethereum/evmone/releases/download/v0.11.0/evmone-0.11.0-windows-amd64.zip" -OutFile "evmone.zip"
tar -xf evmone.zip "bin/evmone.dll"
mkdir deps
mv bin/evmone.dll deps
mv bin/evmone.dll deps/
7 changes: 0 additions & 7 deletions scripts/release_ppa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,6 @@ ppafilesurl=https://launchpad.net/~ethereum/+archive/ubuntu/${pparepo}/+files
git clone --depth 2 --recursive https://github.com/ethereum/solidity.git -b "$branch"
mv solidity solc

# Fetch dependencies
mkdir -p ./solc/deps/downloads/ 2>/dev/null || true
mkdir -p ./solc/deps/nlohmann/nlohmann/ 2>/dev/null || true
wget -O ./solc/deps/nlohmann/nlohmann/json.hpp https://github.com/nlohmann/json/releases/download/v3.11.3/json.hpp
wget -O ./solc/deps/downloads/range-v3-0.12.0.tar.gz https://github.com/ericniebler/range-v3/archive/0.12.0.tar.gz
wget -O ./solc/deps/downloads/fmt-9.1.0.tar.gz https://github.com/fmtlib/fmt/archive/9.1.0.tar.gz

# Determine version
cd solc
version=$("$(dirname "$0")/get_version.sh")
Expand Down

0 comments on commit 24dbe1c

Please sign in to comment.