mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-16 14:31:22 +00:00
Added an --out-name param to the CLI, to allow custom output file names
This commit is contained in:
@ -27,6 +27,7 @@ mod wasm_utils;
|
||||
|
||||
pub struct Bindgen {
|
||||
input: Input,
|
||||
out_name: Option<String>,
|
||||
nodejs: bool,
|
||||
nodejs_experimental_modules: bool,
|
||||
browser: bool,
|
||||
@ -56,6 +57,7 @@ impl Bindgen {
|
||||
pub fn new() -> Bindgen {
|
||||
Bindgen {
|
||||
input: Input::None,
|
||||
out_name: None,
|
||||
nodejs: false,
|
||||
nodejs_experimental_modules: false,
|
||||
browser: false,
|
||||
@ -77,6 +79,11 @@ impl Bindgen {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn out_name(&mut self, name: &str) -> &mut Bindgen {
|
||||
self.out_name = Some(name.to_string());
|
||||
self
|
||||
}
|
||||
|
||||
/// Explicitly specify the already parsed input module.
|
||||
pub fn input_module(&mut self, name: &str, module: Module) -> &mut Bindgen {
|
||||
let name = name.to_string();
|
||||
@ -155,7 +162,10 @@ impl Bindgen {
|
||||
.with_context(|_| format!("failed to read `{}`", path.display()))?;
|
||||
let module = parity_wasm::deserialize_buffer::<Module>(&contents)
|
||||
.context("failed to parse input file as wasm")?;
|
||||
let stem = path.file_stem().unwrap().to_str().unwrap();
|
||||
let stem = match &self.out_name {
|
||||
Some(name) => &name,
|
||||
None => path.file_stem().unwrap().to_str().unwrap(),
|
||||
};
|
||||
(module, stem)
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user