mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-28 07:51:07 +00:00
Merge pull request #1024 from alexcrichton/remove-names
Add a flag to remove the wasm name section
This commit is contained in:
commit
406581da7e
@ -116,6 +116,7 @@ impl<'a> Context<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn finalize(&mut self, module_name: &str) -> Result<(String, String), Error> {
|
pub fn finalize(&mut self, module_name: &str) -> Result<(String, String), Error> {
|
||||||
|
self.parse_wasm_names();
|
||||||
self.write_classes()?;
|
self.write_classes()?;
|
||||||
|
|
||||||
self.bind("__wbindgen_object_clone_ref", &|me| {
|
self.bind("__wbindgen_object_clone_ref", &|me| {
|
||||||
@ -1692,7 +1693,6 @@ impl<'a> Context<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn gc(&mut self) {
|
fn gc(&mut self) {
|
||||||
self.parse_wasm_names();
|
|
||||||
gc::Config::new()
|
gc::Config::new()
|
||||||
.demangle(self.config.demangle)
|
.demangle(self.config.demangle)
|
||||||
.keep_debug(self.config.keep_debug || self.config.debug)
|
.keep_debug(self.config.keep_debug || self.config.debug)
|
||||||
@ -1703,6 +1703,14 @@ impl<'a> Context<'a> {
|
|||||||
let module = mem::replace(self.module, Module::default());
|
let module = mem::replace(self.module, Module::default());
|
||||||
let module = module.parse_names().unwrap_or_else(|p| p.1);
|
let module = module.parse_names().unwrap_or_else(|p| p.1);
|
||||||
*self.module = module;
|
*self.module = module;
|
||||||
|
if self.config.remove_name_section {
|
||||||
|
self.module.sections_mut().retain(|s| {
|
||||||
|
match s {
|
||||||
|
Section::Name(_) => false,
|
||||||
|
_ => true,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn describe(&mut self, name: &str) -> Option<Descriptor> {
|
fn describe(&mut self, name: &str) -> Option<Descriptor> {
|
||||||
|
@ -35,6 +35,7 @@ pub struct Bindgen {
|
|||||||
typescript: bool,
|
typescript: bool,
|
||||||
demangle: bool,
|
demangle: bool,
|
||||||
keep_debug: bool,
|
keep_debug: bool,
|
||||||
|
remove_name_section: bool,
|
||||||
// Experimental support for `WeakRefGroup`, an upcoming ECMAScript feature.
|
// Experimental support for `WeakRefGroup`, an upcoming ECMAScript feature.
|
||||||
// Currently only enable-able through an env var.
|
// Currently only enable-able through an env var.
|
||||||
weak_refs: bool,
|
weak_refs: bool,
|
||||||
@ -62,6 +63,7 @@ impl Bindgen {
|
|||||||
typescript: false,
|
typescript: false,
|
||||||
demangle: true,
|
demangle: true,
|
||||||
keep_debug: false,
|
keep_debug: false,
|
||||||
|
remove_name_section: false,
|
||||||
weak_refs: env::var("WASM_BINDGEN_WEAKREF").is_ok(),
|
weak_refs: env::var("WASM_BINDGEN_WEAKREF").is_ok(),
|
||||||
threads: threads_config(),
|
threads: threads_config(),
|
||||||
}
|
}
|
||||||
@ -124,6 +126,11 @@ impl Bindgen {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn remove_name_section(&mut self, remove: bool) -> &mut Bindgen {
|
||||||
|
self.remove_name_section = remove;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn generate<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error> {
|
pub fn generate<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error> {
|
||||||
self._generate(path.as_ref())
|
self._generate(path.as_ref())
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ Options:
|
|||||||
--debug Include otherwise-extraneous debug checks in output
|
--debug Include otherwise-extraneous debug checks in output
|
||||||
--no-demangle Don't demangle Rust symbol names
|
--no-demangle Don't demangle Rust symbol names
|
||||||
--keep-debug Keep debug sections in wasm files
|
--keep-debug Keep debug sections in wasm files
|
||||||
|
--remove-name-section Remove the debugging `name` section of the file
|
||||||
-V --version Print the version number of wasm-bindgen
|
-V --version Print the version number of wasm-bindgen
|
||||||
";
|
";
|
||||||
|
|
||||||
@ -52,6 +53,7 @@ struct Args {
|
|||||||
flag_version: bool,
|
flag_version: bool,
|
||||||
flag_no_demangle: bool,
|
flag_no_demangle: bool,
|
||||||
flag_no_modules_global: Option<String>,
|
flag_no_modules_global: Option<String>,
|
||||||
|
flag_remove_name_section: bool,
|
||||||
flag_keep_debug: bool,
|
flag_keep_debug: bool,
|
||||||
arg_input: Option<PathBuf>,
|
arg_input: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
@ -92,6 +94,7 @@ fn rmain(args: &Args) -> Result<(), Error> {
|
|||||||
.debug(args.flag_debug)
|
.debug(args.flag_debug)
|
||||||
.demangle(!args.flag_no_demangle)
|
.demangle(!args.flag_no_demangle)
|
||||||
.keep_debug(args.flag_keep_debug)
|
.keep_debug(args.flag_keep_debug)
|
||||||
|
.remove_name_section(args.flag_remove_name_section)
|
||||||
.typescript(typescript);
|
.typescript(typescript);
|
||||||
if let Some(ref name) = args.flag_no_modules_global {
|
if let Some(ref name) = args.flag_no_modules_global {
|
||||||
b.no_modules_global(name);
|
b.no_modules_global(name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user