From 36ea69b50f61e840ef1e4bec1abd17d4851445c3 Mon Sep 17 00:00:00 2001 From: Pavlo Khrystenko <45178695+pkhry@users.noreply.github.com> Date: Wed, 19 Mar 2025 16:07:48 +0100 Subject: [PATCH] Add --supported-solc-versions CLI command (#260) ### Description Adds `--supported-solc-versions` cli command to return a semver range of supported `solc` versions. Is a hack until #162 is implemented. --------- Co-authored-by: xermicus --- CHANGELOG.md | 1 + crates/solidity/src/lib.rs | 3 +++ crates/solidity/src/resolc/arguments.rs | 10 ++++++++++ crates/solidity/src/resolc/main.rs | 10 ++++++++++ 4 files changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42ef1a1..c58a162 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Supported `polkadot-sdk` rev:`c29e72a8628835e34deb6aa7db9a78a2e4eabcee` ### Added - Support for solc v0.8.29 +- `--supported-solc-versions` for `resolc` binary to return a `semver` range of supported `solc` versions. ### Changed - Runner `resolc` using webkit is no longer supported. diff --git a/crates/solidity/src/lib.rs b/crates/solidity/src/lib.rs index 7214120..24776e2 100644 --- a/crates/solidity/src/lib.rs +++ b/crates/solidity/src/lib.rs @@ -44,8 +44,11 @@ pub use self::solc::standard_json::output::contract::Contract as SolcStandardJso pub use self::solc::standard_json::output::Output as SolcStandardJsonOutput; pub use self::solc::version::Version as SolcVersion; pub use self::solc::Compiler; +pub use self::solc::FIRST_SUPPORTED_VERSION as SolcFirstSupportedVersion; +pub use self::solc::LAST_SUPPORTED_VERSION as SolcLastSupportedVersion; pub use self::version::Version as ResolcVersion; pub use self::warning::Warning; + #[cfg(not(target_os = "emscripten"))] pub mod test_utils; pub mod tests; diff --git a/crates/solidity/src/resolc/arguments.rs b/crates/solidity/src/resolc/arguments.rs index e0e9e92..c777b6b 100644 --- a/crates/solidity/src/resolc/arguments.rs +++ b/crates/solidity/src/resolc/arguments.rs @@ -19,6 +19,10 @@ pub struct Arguments { #[arg(long = "version")] pub version: bool, + /// Print supported `solc` versions and exit. + #[arg(long = "supported-solc-versions")] + pub supported_solc_versions: bool, + /// Print the licence and exit. #[arg(long = "license")] pub license: bool, @@ -171,6 +175,12 @@ impl Arguments { anyhow::bail!("No other options are allowed while getting the compiler version."); } + if self.supported_solc_versions && std::env::args().count() > 2 { + anyhow::bail!( + "No other options are allowed while getting the supported `solc` versions." + ); + } + #[cfg(debug_assertions)] if self.recursive_process_input.is_some() && !self.recursive_process { anyhow::bail!("--process-input can be only used when --recursive-process is given"); diff --git a/crates/solidity/src/resolc/main.rs b/crates/solidity/src/resolc/main.rs index b308771..5e133f6 100644 --- a/crates/solidity/src/resolc/main.rs +++ b/crates/solidity/src/resolc/main.rs @@ -41,6 +41,16 @@ fn main_inner() -> anyhow::Result<()> { return Ok(()); } + if arguments.supported_solc_versions { + writeln!( + std::io::stdout(), + ">={},<={}", + revive_solidity::SolcFirstSupportedVersion, + revive_solidity::SolcLastSupportedVersion, + )?; + return Ok(()); + } + if arguments.license { let license_mit = include_str!("../../../../LICENSE-MIT"); let license_apache = include_str!("../../../../LICENSE-APACHE");