mirror of
https://github.com/fluencelabs/wasm-utils
synced 2025-05-18 02:01:25 +00:00
rename wasm-opt binary to wasm-prune
This commit is contained in:
parent
c69d8327c8
commit
203cc4fea8
@ -14,8 +14,8 @@ glob = "0.2"
|
|||||||
[lib]
|
[lib]
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "wasm-opt"
|
name = "wasm-prune"
|
||||||
path = "opt/src/main.rs"
|
path = "prune/src/main.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "wasm-ext"
|
name = "wasm-ext"
|
||||||
|
2
opt/.gitignore
vendored
2
opt/.gitignore
vendored
@ -1,2 +0,0 @@
|
|||||||
target
|
|
||||||
Cargo.lock
|
|
@ -1,9 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "wasm-opt"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["NikVolf <nikvolf@gmail.com>"]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
parity-wasm = "0.12"
|
|
||||||
wasm-utils = { path = "../" }
|
|
||||||
clap = "2.24"
|
|
@ -1,44 +0,0 @@
|
|||||||
extern crate parity_wasm;
|
|
||||||
extern crate wasm_utils;
|
|
||||||
extern crate clap;
|
|
||||||
|
|
||||||
use clap::{App, Arg};
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
wasm_utils::init_log();
|
|
||||||
|
|
||||||
let matches = App::new("wasm-opt")
|
|
||||||
.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("exports")
|
|
||||||
.long("exports")
|
|
||||||
.short("e")
|
|
||||||
.takes_value(true)
|
|
||||||
.value_name("functions")
|
|
||||||
.help("Comma-separated list of exported functions to keep. Default: _call"))
|
|
||||||
.get_matches();
|
|
||||||
|
|
||||||
let exports = matches
|
|
||||||
.value_of("exports")
|
|
||||||
.unwrap_or("_call")
|
|
||||||
.split(',')
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let input = matches.value_of("input").expect("is required; qed");
|
|
||||||
let output = matches.value_of("output").expect("is required; qed");
|
|
||||||
|
|
||||||
let mut module = parity_wasm::deserialize_file(&input).unwrap();
|
|
||||||
|
|
||||||
// Invoke optimizer
|
|
||||||
// Contract is supposed to have only these functions as public api
|
|
||||||
// All other symbols not usable by this list is optimized away
|
|
||||||
wasm_utils::optimize(&mut module, exports).expect("Optimizer to finish without errors");
|
|
||||||
|
|
||||||
parity_wasm::serialize_to_file(&output, module).unwrap();
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user