Skip to content

Commit 36ea69b

Browse files
pkhryxermicus
andauthored
Add --supported-solc-versions CLI command (paritytech#260)
### Description Adds `--supported-solc-versions` cli command to return a semver range of supported `solc` versions. Is a hack until paritytech#162 is implemented. --------- Co-authored-by: xermicus <[email protected]>
1 parent 2bbc5d7 commit 36ea69b

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Supported `polkadot-sdk` rev:`c29e72a8628835e34deb6aa7db9a78a2e4eabcee`
88

99
### Added
1010
- Support for solc v0.8.29
11+
- `--supported-solc-versions` for `resolc` binary to return a `semver` range of supported `solc` versions.
1112

1213
### Changed
1314
- Runner `resolc` using webkit is no longer supported.

crates/solidity/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ pub use self::solc::standard_json::output::contract::Contract as SolcStandardJso
4444
pub use self::solc::standard_json::output::Output as SolcStandardJsonOutput;
4545
pub use self::solc::version::Version as SolcVersion;
4646
pub use self::solc::Compiler;
47+
pub use self::solc::FIRST_SUPPORTED_VERSION as SolcFirstSupportedVersion;
48+
pub use self::solc::LAST_SUPPORTED_VERSION as SolcLastSupportedVersion;
4749
pub use self::version::Version as ResolcVersion;
4850
pub use self::warning::Warning;
51+
4952
#[cfg(not(target_os = "emscripten"))]
5053
pub mod test_utils;
5154
pub mod tests;

crates/solidity/src/resolc/arguments.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ pub struct Arguments {
1919
#[arg(long = "version")]
2020
pub version: bool,
2121

22+
/// Print supported `solc` versions and exit.
23+
#[arg(long = "supported-solc-versions")]
24+
pub supported_solc_versions: bool,
25+
2226
/// Print the licence and exit.
2327
#[arg(long = "license")]
2428
pub license: bool,
@@ -171,6 +175,12 @@ impl Arguments {
171175
anyhow::bail!("No other options are allowed while getting the compiler version.");
172176
}
173177

178+
if self.supported_solc_versions && std::env::args().count() > 2 {
179+
anyhow::bail!(
180+
"No other options are allowed while getting the supported `solc` versions."
181+
);
182+
}
183+
174184
#[cfg(debug_assertions)]
175185
if self.recursive_process_input.is_some() && !self.recursive_process {
176186
anyhow::bail!("--process-input can be only used when --recursive-process is given");

crates/solidity/src/resolc/main.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ fn main_inner() -> anyhow::Result<()> {
4141
return Ok(());
4242
}
4343

44+
if arguments.supported_solc_versions {
45+
writeln!(
46+
std::io::stdout(),
47+
">={},<={}",
48+
revive_solidity::SolcFirstSupportedVersion,
49+
revive_solidity::SolcLastSupportedVersion,
50+
)?;
51+
return Ok(());
52+
}
53+
4454
if arguments.license {
4555
let license_mit = include_str!("../../../../LICENSE-MIT");
4656
let license_apache = include_str!("../../../../LICENSE-APACHE");

0 commit comments

Comments
 (0)