Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace jsoncpp with nlohmann json #14877

Merged
merged 1 commit into from May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 4 additions & 6 deletions CMakeLists.txt
Expand Up @@ -39,7 +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)
option(STRICT_NLOHMANN_JSON_VERSION "Strictly check installed nlohmann json version" ON)

# Setup cccache.
include(EthCcache)
Expand All @@ -48,9 +48,8 @@ include(EthCcache)
include(EthDependencies)
if (NOT USE_SYSTEM_LIBRARIES)
include(fmtlib)
include(jsoncpp)
include(nlohmann-json)
include(range-v3)
include_directories(SYSTEM ${JSONCPP_INCLUDE_DIR})
endif()

find_package(Threads)
Expand All @@ -63,8 +62,8 @@ if (PROFILE_OPTIMIZER_STEPS)
add_definitions(-DPROFILE_OPTIMIZER_STEPS)
endif()

if (STRICT_JSONCPP_VERSION)
add_definitions(-DSTRICT_JSONCPP_VERSION_CHECK)
if (STRICT_NLOHMANN_JSON_VERSION)
add_definitions(-DSTRICT_NLOHMANN_JSON_VERSION_CHECK)
endif()

# Figure out what compiler and system are we using
Expand Down Expand Up @@ -162,4 +161,3 @@ if (NOT ONLY_BUILD_SOLIDITY_LIBRARIES)
add_subdirectory(test)
endif()
endif()

2 changes: 2 additions & 0 deletions Changelog.md
Expand Up @@ -32,6 +32,8 @@ Bugfixes:
* SMTChecker: Fix internal error caused by not respecting the sign of an integer type when constructing zero-value SMT expressions.
* SMTChecker: Run Eldarica only when explicitly requested with `--model-checker-solvers eld`, even when it is present on the system.

Build System:
* Replace internal JSON library jsoncpp with nlohmann::json.

### 0.8.24 (2024-01-25)

Expand Down
72 changes: 0 additions & 72 deletions cmake/jsoncpp.cmake

This file was deleted.

21 changes: 21 additions & 0 deletions cmake/nlohmann-json.cmake
@@ -0,0 +1,21 @@
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
)

# 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)
2 changes: 1 addition & 1 deletion libevmasm/AbstractAssemblyStack.h
Expand Up @@ -40,7 +40,7 @@ class AbstractAssemblyStack
virtual std::string const* sourceMapping(std::string const& _contractName) const = 0;
virtual std::string const* runtimeSourceMapping(std::string const& _contractName) const = 0;

virtual Json::Value assemblyJSON(std::string const& _contractName) const = 0;
virtual Json assemblyJSON(std::string const& _contractName) const = 0;
virtual std::string assemblyString(std::string const& _contractName, StringMap const& _sourceCodes) const = 0;

virtual std::string const filesystemFriendlyName(std::string const& _contractName) const = 0;
Expand Down