building for EVM works with complex cases

Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
Cyrill Leutwiler
2025-03-21 18:10:17 +01:00
parent 11bd08df4e
commit 3b713ad2cb
10 changed files with 149 additions and 17 deletions
+1
View File
@@ -13,3 +13,4 @@ anyhow = { workspace = true }
revive-solc-json-interface = { workspace = true }
revive-common = { workspace = true }
semver = { workspace = true }
serde_json = { workspace = true }
+25 -4
View File
@@ -1,25 +1,46 @@
//! Implements the [SolidityCompiler] trait with solc for
//! compiling contracts to EVM bytecode.
use std::{
path::PathBuf,
process::{Command, Stdio},
};
use revive_solc_json_interface::{SolcStandardJsonInput, SolcStandardJsonOutput};
use semver::Version;
use crate::SolidityCompiler;
pub struct Solc {}
pub struct Solc {
binary_path: PathBuf,
}
impl SolidityCompiler for Solc {
type Options = ();
fn build(
&self,
_input: &SolcStandardJsonInput,
input: &SolcStandardJsonInput,
_extra_options: &Option<Self::Options>,
) -> anyhow::Result<SolcStandardJsonOutput> {
todo!()
let mut child = Command::new(&self.binary_path)
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.arg("--standard-json")
.spawn()?;
let stdin = child.stdin.as_mut().expect("should be piped");
serde_json::to_writer(stdin, input)?;
let output = child.wait_with_output()?.stdout;
Ok(serde_json::from_slice(&output)?)
}
fn new(_solc_version: &Version) -> Self {
todo!()
Self {
binary_path: "solc".into(),
}
}
}