diff --git a/uw8-tool/src/filter_exports.rs b/uw8-tool/src/filter_exports.rs new file mode 100644 index 0000000..00f96c9 --- /dev/null +++ b/uw8-tool/src/filter_exports.rs @@ -0,0 +1,21 @@ +use std::path::Path; +use anyhow::Result; + +pub fn filter_exports(in_path: &Path, out_path: &Path) -> Result<()> { + let mut module = walrus::Module::from_file(in_path)?; + + let exports_to_delete: Vec<_> = module.exports.iter().filter_map(|export| match export.name.as_str() { + "upd" => None, + _ => Some(export.id()) + }).collect(); + + for id in exports_to_delete { + module.exports.delete(id); + } + + walrus::passes::gc::run(&mut module); + + module.emit_wasm_file(out_path)?; + + Ok(()) +} \ No newline at end of file