the solc download per target helper

Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
Cyrill Leutwiler
2025-03-24 22:33:37 +01:00
parent 97156ed21e
commit c69a87238d
16 changed files with 272 additions and 96 deletions
+8 -4
View File
@@ -3,7 +3,11 @@
//! - Polkadot revive resolc compiler
//! - Polkadot revive Wasm compiler
use std::{fs::read_to_string, hash::Hash, path::Path};
use std::{
fs::read_to_string,
hash::Hash,
path::{Path, PathBuf},
};
use revive_common::EVMVersion;
use revive_solc_json_interface::{
@@ -28,7 +32,7 @@ pub trait SolidityCompiler {
input: CompilerInput<Self::Options>,
) -> anyhow::Result<CompilerOutput<Self::Options>>;
fn new(solc_version: &Version) -> Self;
fn new(solc_executable: PathBuf) -> Self;
}
/// The generic compilation input configuration.
@@ -142,8 +146,8 @@ where
self
}
pub fn try_build(self, solc_version: &Version) -> anyhow::Result<CompilerOutput<T::Options>> {
T::new(solc_version).build(CompilerInput {
pub fn try_build(self, solc_path: PathBuf) -> anyhow::Result<CompilerOutput<T::Options>> {
T::new(solc_path).build(CompilerInput {
extra_options: self.extra_options,
input: self.input,
})
+4 -6
View File
@@ -11,7 +11,7 @@ use semver::Version;
use crate::{CompilerInput, CompilerOutput, SolidityCompiler};
pub struct Solc {
binary_path: PathBuf,
solc_path: PathBuf,
}
impl SolidityCompiler for Solc {
@@ -21,7 +21,7 @@ impl SolidityCompiler for Solc {
&self,
input: CompilerInput<Self::Options>,
) -> anyhow::Result<CompilerOutput<Self::Options>> {
let mut child = Command::new(&self.binary_path)
let mut child = Command::new(&self.solc_path)
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
@@ -38,9 +38,7 @@ impl SolidityCompiler for Solc {
})
}
fn new(_solc_version: &Version) -> Self {
Self {
binary_path: "solc".into(),
}
fn new(solc_path: PathBuf) -> Self {
Self { solc_path }
}
}