mirror of
https://github.com/pezkuwichain/wasm-instrument.git
synced 2026-04-22 06:48:03 +00:00
Add rustfmt.toml from substrate repo (#161)
* Add rustfmt.toml from substrate repo * Apply rustfmt to code base * Fix formatting * Move rustfmt job to the top
This commit is contained in:
committed by
GitHub
parent
77ad07e347
commit
a0b548b37d
+10
-12
@@ -1,5 +1,5 @@
|
||||
use pwasm_utils::{self as utils, logger};
|
||||
use clap::{App, Arg};
|
||||
use pwasm_utils::{self as utils, logger};
|
||||
|
||||
fn main() {
|
||||
logger::init();
|
||||
@@ -7,27 +7,25 @@ fn main() {
|
||||
let target_runtime = utils::TargetRuntime::pwasm();
|
||||
|
||||
let matches = App::new("wasm-pack")
|
||||
.arg(Arg::with_name("input")
|
||||
.index(1)
|
||||
.required(true)
|
||||
.help("Input WASM file"))
|
||||
.arg(Arg::with_name("output")
|
||||
.index(2)
|
||||
.required(true)
|
||||
.help("Output WASM file"))
|
||||
.arg(Arg::with_name("input").index(1).required(true).help("Input WASM file"))
|
||||
.arg(Arg::with_name("output").index(2).required(true).help("Output WASM file"))
|
||||
.get_matches();
|
||||
|
||||
let input = matches.value_of("input").expect("is required; qed");
|
||||
let output = matches.value_of("output").expect("is required; qed");
|
||||
|
||||
let module = parity_wasm::deserialize_file(&input).expect("Input module deserialization failed");
|
||||
let module =
|
||||
parity_wasm::deserialize_file(&input).expect("Input module deserialization failed");
|
||||
let ctor_module = module.clone();
|
||||
let raw_module = parity_wasm::serialize(module).expect("Serialization failed");
|
||||
|
||||
// Invoke packer
|
||||
let mut result_module = utils::pack_instance(raw_module, ctor_module, &utils::TargetRuntime::pwasm()).expect("Packing failed");
|
||||
let mut result_module =
|
||||
utils::pack_instance(raw_module, ctor_module, &utils::TargetRuntime::pwasm())
|
||||
.expect("Packing failed");
|
||||
// Optimize constructor, since it does not need everything
|
||||
utils::optimize(&mut result_module, vec![target_runtime.symbols().call]).expect("Optimization failed");
|
||||
utils::optimize(&mut result_module, vec![target_runtime.symbols().call])
|
||||
.expect("Optimization failed");
|
||||
|
||||
parity_wasm::serialize_to_file(&output, result_module).expect("Serialization failed");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user