[HTML5] Make GDNative support feature-based.
This is suboptimal as it requires adding an extra flag, but rewriting how feature tags work is beyond the scope of this work.
This commit is contained in:
parent
2cbfe1afd4
commit
79a1418e7d
4 changed files with 22 additions and 3 deletions
|
@ -335,7 +335,7 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() {
|
||||||
|
|
||||||
NativePlatformConfig platform_html5;
|
NativePlatformConfig platform_html5;
|
||||||
platform_html5.name = "HTML5";
|
platform_html5.name = "HTML5";
|
||||||
platform_html5.entries.push_back("web");
|
platform_html5.entries.push_back("wasm32");
|
||||||
platform_html5.library_extension = "*.wasm";
|
platform_html5.library_extension = "*.wasm";
|
||||||
platforms["HTML5"] = platform_html5;
|
platforms["HTML5"] = platform_html5;
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ if env["gdnative_enabled"]:
|
||||||
|
|
||||||
# The side library, containing all Godot code.
|
# The side library, containing all Godot code.
|
||||||
wasm_env = env.Clone()
|
wasm_env = env.Clone()
|
||||||
|
wasm_env.Append(CPPDEFINES=["WASM_GDNATIVE"]) # So that OS knows it can run GDNative libraries.
|
||||||
wasm_env.Append(CCFLAGS=["-s", "SIDE_MODULE=2"])
|
wasm_env.Append(CCFLAGS=["-s", "SIDE_MODULE=2"])
|
||||||
wasm_env.Append(LINKFLAGS=["-s", "SIDE_MODULE=2"])
|
wasm_env.Append(LINKFLAGS=["-s", "SIDE_MODULE=2"])
|
||||||
wasm = wasm_env.add_program("#bin/godot.side${PROGSUFFIX}.wasm", javascript_files)
|
wasm = wasm_env.add_program("#bin/godot.side${PROGSUFFIX}.wasm", javascript_files)
|
||||||
|
|
|
@ -328,6 +328,12 @@ void EditorExportPlatformJavaScript::get_preset_features(const Ref<EditorExportP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ExportMode mode = (ExportMode)(int)p_preset->get("variant/export_type");
|
||||||
|
if (mode == EXPORT_MODE_THREADS) {
|
||||||
|
r_features->push_back("threads");
|
||||||
|
} else if (mode == EXPORT_MODE_GDNATIVE) {
|
||||||
|
r_features->push_back("wasm32");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorExportPlatformJavaScript::get_export_options(List<ExportOption> *r_options) {
|
void EditorExportPlatformJavaScript::get_export_options(List<ExportOption> *r_options) {
|
||||||
|
|
|
@ -1071,12 +1071,24 @@ int OS_JavaScript::get_process_id() const {
|
||||||
|
|
||||||
bool OS_JavaScript::_check_internal_feature_support(const String &p_feature) {
|
bool OS_JavaScript::_check_internal_feature_support(const String &p_feature) {
|
||||||
|
|
||||||
if (p_feature == "HTML5" || p_feature == "web")
|
if (p_feature == "HTML5" || p_feature == "web") {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef JAVASCRIPT_EVAL_ENABLED
|
#ifdef JAVASCRIPT_EVAL_ENABLED
|
||||||
if (p_feature == "JavaScript")
|
if (p_feature == "JavaScript") {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifndef NO_THREADS
|
||||||
|
if (p_feature == "threads") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if WASM_GDNATIVE
|
||||||
|
if (p_feature == "wasm32") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue