Skip to content

Commit

Permalink
Add zkevm specific details in the --version output
Browse files Browse the repository at this point in the history
This patch also adds the SOLC_VERSION_ZKEVM cmake setting to configure
the zkevm version.
  • Loading branch information
abinavpp committed Apr 6, 2023
1 parent 014efa2 commit 0b0fd9e
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions cmake/EthBuildInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function(create_build_info NAME)
-DPROJECT_VERSION_MAJOR="${PROJECT_VERSION_MAJOR}"
-DPROJECT_VERSION_MINOR="${PROJECT_VERSION_MINOR}"
-DPROJECT_VERSION_PATCH="${PROJECT_VERSION_PATCH}"
-DSOLC_VERSION_ZKEVM="${SOLC_VERSION_ZKEVM}"
-P "${ETH_SCRIPTS_DIR}/buildinfo.cmake"
)
include_directories("${PROJECT_BINARY_DIR}/include")
Expand Down
5 changes: 4 additions & 1 deletion cmake/scripts/buildinfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ if (EXISTS ${ETH_SOURCE_DIR}/prerelease.txt)
file(READ ${ETH_SOURCE_DIR}/prerelease.txt SOL_VERSION_PRERELEASE)
string(STRIP "${SOL_VERSION_PRERELEASE}" SOL_VERSION_PRERELEASE)
else()
string(TIMESTAMP SOL_VERSION_PRERELEASE "develop.%Y.%m.%d" UTC)
string(REPLACE .0 . SOL_VERSION_PRERELEASE "${SOL_VERSION_PRERELEASE}")
endif()

Expand Down Expand Up @@ -64,6 +63,10 @@ set(SOL_VERSION_COMMIT "commit.${SOL_COMMIT_HASH}")
set(SOl_VERSION_PLATFORM ETH_BUILD_PLATFORM)
set(SOL_VERSION_BUILDINFO "commit.${SOL_COMMIT_HASH}.${ETH_BUILD_PLATFORM}")

if (NOT SOLC_VERSION_ZKEVM)
set(SOLC_VERSION_ZKEVM "undefined")
endif()

set(TMPFILE "${ETH_DST_DIR}/BuildInfo.h.tmp")
set(OUTFILE "${ETH_DST_DIR}/BuildInfo.h")

Expand Down
1 change: 1 addition & 0 deletions cmake/templates/BuildInfo.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
#define SOL_VERSION_BUILDINFO "@SOL_VERSION_BUILDINFO@"
#define SOL_VERSION_COMMIT "@SOL_VERSION_COMMIT@"
#define SOL_VERSION_PLATFORM "@SOL_VERSION_PLATFORM@"
#define SOL_VERSION_ZKEVM "@SOLC_VERSION_ZKEVM@"
1 change: 1 addition & 0 deletions libsolidity/interface/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using namespace std;

char const* solidity::frontend::VersionNumber = ETH_PROJECT_VERSION;
char const* solidity::frontend::ZKEVMVersionString = SOL_VERSION_ZKEVM;

string const solidity::frontend::VersionString =
string(solidity::frontend::VersionNumber) +
Expand Down
1 change: 1 addition & 0 deletions libsolidity/interface/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ extern std::string const VersionString;
extern std::string const VersionStringStrict;
extern bytes const VersionCompactBytes;
extern bool const VersionIsRelease;
extern char const* ZKEVMVersionString;

}
}
3 changes: 2 additions & 1 deletion solc/CommandLineInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,9 @@ void CommandLineInterface::processInput()

void CommandLineInterface::printVersion()
{
sout() << "solc, the solidity compiler commandline interface" << endl;
sout() << "solc, the zkEVM Solidity compiler commandline interface" << endl;
sout() << "Version: " << solidity::frontend::VersionString << endl;
sout() << "zkEVM: " << solidity::frontend::ZKEVMVersionString << endl;
}

void CommandLineInterface::printLicense()
Expand Down
3 changes: 2 additions & 1 deletion test/solc/CommandLineInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ BOOST_AUTO_TEST_CASE(version)
OptionsReaderAndMessages result = runCLI({"solc", "--version"}, "");

BOOST_TEST(result.success);
BOOST_TEST(boost::ends_with(result.stdoutContent, "Version: " + solidity::frontend::VersionString + "\n"));
BOOST_TEST(boost::ends_with(result.stdoutContent, "Version: " + solidity::frontend::VersionString + "\n"
+ "zkEVM: " + solidity::frontend::ZKEVMVersionString + "\n"));
BOOST_TEST(result.stderrContent == "");
BOOST_TEST(result.options.input.mode == InputMode::Version);
}
Expand Down

0 comments on commit 0b0fd9e

Please sign in to comment.