Skip to content

Commit 5ffe604

Browse files
committed
Remove dependency on parity_wasm from chisel CLI
1 parent 4d3d98b commit 5ffe604

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

chisel/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ edition = "2018"
1212

1313
[dependencies]
1414
libchisel = { path = "../libchisel", version = "0.5.0" }
15-
parity-wasm = "^0.40.2"
15+
#parity-wasm = "^0.40.2"
1616
clap = "2.32.0"
1717
serde = "1.0.80"
1818
serde_derive = "1.0.80"

chisel/src/main.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
extern crate libchisel;
2-
extern crate parity_wasm;
32
#[macro_use]
43
extern crate clap;
54
extern crate serde;
@@ -10,7 +9,7 @@ extern crate serde_yaml;
109
mod logger;
1110
mod config;
1211

13-
use std::fs::{read, read_to_string};
12+
use std::fs::{read, read_to_string, write};
1413
use std::process;
1514

1615
use libchisel::{
@@ -23,7 +22,6 @@ use libchisel::binaryenopt::*;
2322

2423
use clap::{App, Arg, ArgMatches, SubCommand};
2524
use libchisel::*;
26-
use parity_wasm::elements::{deserialize_buffer, serialize_to_file, Module};
2725
use serde_yaml::Value;
2826

2927
// Error messages
@@ -311,7 +309,7 @@ fn execute_module(context: &ModuleContext, module: &mut Module) -> bool {
311309

312310
fn chisel_execute(context: &ChiselContext) -> Result<bool, &'static str> {
313311
if let Ok(buffer) = read(context.file()) {
314-
if let Ok(module) = deserialize_buffer::<Module>(&buffer) {
312+
if let Ok(module) = module_from_bytes(&buffer) {
315313
// If we do not parse the NamesSection here, parity-wasm will drop it at serialisation
316314
// It is useful to have this for a number of optimisation passes, including binaryenopt and snip
317315
// TODO: better error handling
@@ -327,12 +325,13 @@ fn chisel_execute(context: &ChiselContext) -> Result<bool, &'static str> {
327325

328326
// If the module was mutated, serialize to file.
329327
if original != module {
328+
let serialized = module.to_bytes().unwrap();
330329
if let Some(path) = context.outfile() {
331330
chisel_debug!(1, "Writing to file: {}", path);
332-
serialize_to_file(path, module).unwrap();
331+
write(path, serialized).unwrap();
333332
} else {
334333
chisel_debug!(1, "No output file specified; writing in place");
335-
serialize_to_file(context.file(), module).unwrap();
334+
write(context.file(), serialized).unwrap();
336335
}
337336
}
338337
Ok(chisel_results)

0 commit comments

Comments
 (0)