Skip to content

Commit 9816e48

Browse files
authored
Merge pull request #516 from zecozephyr/wasm-4.2
Fix wasm exports in Godot 4.2
2 parents ff4838a + 0f444d7 commit 9816e48

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

godot-macros/src/gdextension.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,23 @@ pub fn attribute_gdextension(decl: Declaration) -> ParseResult<TokenStream> {
5555
let script = std::ffi::CString::new(concat!(
5656
"var pkgName = '", env!("CARGO_PKG_NAME"), "';", r#"
5757
var libName = pkgName.replaceAll('-', '_') + '.wasm';
58-
var dso = LDSO.loadedLibsByName[libName]["module"];
58+
var dso = LDSO.loadedLibsByName[libName];
59+
// This property was renamed as of emscripten 3.1.34
60+
var dso_exports = "module" in dso ? dso["module"] : dso["exports"];
5961
var registrants = [];
60-
for (sym in dso) {
62+
for (sym in dso_exports) {
6163
if (sym.startsWith("dynCall_")) {
6264
if (!(sym in Module)) {
6365
console.log(`Patching Module with ${sym}`);
64-
Module[sym] = dso[sym];
66+
Module[sym] = dso_exports[sym];
6567
}
6668
} else if (sym.startsWith("rust_gdext_registrant_")) {
6769
registrants.push(sym);
6870
}
6971
}
7072
for (sym of registrants) {
7173
console.log(`Running registrant ${sym}`);
72-
dso[sym]();
74+
dso_exports[sym]();
7375
}
7476
console.log("Added", registrants.length, "plugins to registry!");
7577
"#)).expect("Unable to create CString from script");

0 commit comments

Comments
 (0)