MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / wasix_export_list_from_modules

Function wasix_export_list_from_modules

xtask/src/main.rs:7878–7932  ·  view source on GitHub ↗
(modules: &[BuildModuleManifestOut])

Source from the content-addressed store, hash-verified

7876}
7877
7878fn wasix_export_list_from_modules(modules: &[BuildModuleManifestOut]) -> Result<String> {
7879 for module in modules {
7880 validate_module_link_metadata(module)?;
7881 }
7882
7883 let runtime = modules
7884 .iter()
7885 .find(|module| module.kind == "runtime")
7886 .ok_or_else(|| anyhow!("build outputs are missing runtime module"))?;
7887 let runtime_exports = wasm_export_name_set(&runtime.link);
7888 let mut required_exports = BTreeSet::<String>::new();
7889 let mut unresolved = Vec::new();
7890
7891 for abi_export in required_runtime_abi_exports().iter().copied() {
7892 let normalized = abi_export.trim_start_matches('_');
7893 if runtime_exports.contains(abi_export) {
7894 required_exports.insert(abi_export.to_owned());
7895 } else if runtime_exports.contains(normalized) {
7896 required_exports.insert(normalized.to_owned());
7897 } else {
7898 unresolved.push(format!("runtime ABI export {abi_export}"));
7899 }
7900 }
7901
7902 for module in modules
7903 .iter()
7904 .filter(|module| matches!(module.kind.as_str(), "runtime-support" | "extension"))
7905 {
7906 for import in &module.link.imports {
7907 if !import_should_resolve_from_runtime(import) {
7908 continue;
7909 }
7910 let normalized = import.name.trim_start_matches('_');
7911 if runtime_exports.contains(import.name.as_str()) {
7912 required_exports.insert(import.name.clone());
7913 } else if runtime_exports.contains(normalized) {
7914 required_exports.insert(normalized.to_owned());
7915 } else {
7916 unresolved.push(format!(
7917 "{} imports {}.{}",
7918 module.name, import.module, import.name
7919 ));
7920 }
7921 }
7922 }
7923
7924 if !unresolved.is_empty() {
7925 bail!(
7926 "cannot generate WASIX dynamic-link export list with unresolved imports: {}",
7927 unresolved.join(", ")
7928 );
7929 }
7930
7931 Ok(required_exports.into_iter().collect::<Vec<_>>().join("\n") + "\n")
7932}
7933
7934fn required_runtime_abi_exports() -> &'static [&'static str] {
7935 &[

Callers 1

wasix_export_list_textFunction · 0.85

Calls 8

wasm_export_name_setFunction · 0.85
iterMethod · 0.80
insertMethod · 0.80
pushMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected