Skip to content

Commit

Permalink
Make wasm version to compile
Browse files Browse the repository at this point in the history
  • Loading branch information
smiasojed committed Nov 8, 2024
1 parent b7b28ef commit b6baf6c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
22 changes: 16 additions & 6 deletions crates/solidity/src/process/worker_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub struct WorkerProcess;

impl Process for WorkerProcess {
/// Read input from `stdin`, compile a contract, and write the output to `stdout`.
fn run() -> anyhow::Result<()> {
fn run(input_file: Option<&mut std::fs::File>) -> anyhow::Result<()> {
let mut buffer = Vec::with_capacity(16384);
// TODO: Init correctly stdin in emscripten - preload FS conf before module init
let mut stdin = File::open("/in")
Expand All @@ -43,16 +43,26 @@ impl Process for WorkerProcess {
let mut stderr = File::create("/err")
.map_err(|error| anyhow::anyhow!("File /err creating error: {}", error))?;

stdin.read_to_end(&mut buffer).expect("Stdin reading error");
match input_file {
Some(ins) => {
if let Err(error) = ins.read_to_end(&mut buffer) {
anyhow::bail!("Failed to read recursive process input file: {:?}", error);
}
}
None => {
if let Err(error) = stdin.read_to_end(&mut buffer) {
anyhow::bail!(
"Failed to read recursive process input from stdin: {:?}",
error
)
}
}
}

let input: Input = revive_common::deserialize_from_slice(buffer.as_slice())?;
if input.enable_test_encoding {
todo!()
}
let result = input.contract.compile(
input.project,
input.optimizer_settings,
input.is_system_mode,
input.include_metadata_hash,
input.debug_config,
);
Expand Down
1 change: 0 additions & 1 deletion crates/solidity/src/solc/soljson.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ impl Compiler for SoljsonCompiler {
)
})?;
output.preprocess_ast(&version, pipeline, suppressed_warnings.as_slice())?;
output.remove_evm();

Ok(output)
}
Expand Down

0 comments on commit b6baf6c

Please sign in to comment.