Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HTML5] Optional GDNative Support #44076

Merged
merged 5 commits into from
Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[HTML5] Make GDNative support feature-based.
This is suboptimal as it requires adding an extra compile flag, but
rewriting how feature tags work is beyond the scope of this work.
  • Loading branch information
Faless committed Dec 5, 2020
commit dd9503dc1937e1469b2a6f8e145e80acbf2c7cbb
2 changes: 1 addition & 1 deletion modules/gdnative/gdnative_library_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() {

NativePlatformConfig platform_html5;
platform_html5.name = "HTML5";
platform_html5.entries.push_back("web");
platform_html5.entries.push_back("wasm32");
platform_html5.library_extension = "*.wasm";
platforms["HTML5"] = platform_html5;

Expand Down
1 change: 1 addition & 0 deletions platform/javascript/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ if env["gdnative_enabled"]:

# The side library, containing all Godot code.
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(LINKFLAGS=["-s", "SIDE_MODULE=2"])
wasm = wasm_env.add_program("#bin/godot.side${PROGSUFFIX}.wasm", javascript_files)
Expand Down
6 changes: 6 additions & 0 deletions platform/javascript/export/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,12 @@ void EditorExportPlatformJavaScript::get_preset_features(const Ref<EditorExportP
r_features->push_back("etc2");
}
}
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) {
Expand Down
16 changes: 14 additions & 2 deletions platform/javascript/os_javascript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,24 @@ int OS_JavaScript::get_process_id() const {
}

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;
}

#ifdef JAVASCRIPT_EVAL_ENABLED
if (p_feature == "JavaScript")
if (p_feature == "JavaScript") {
return true;
}
#endif
#ifndef NO_THREADS
if (p_feature == "threads") {
return true;
}
#endif
#if WASM_GDNATIVE
if (p_feature == "wasm32") {
return true;
}
#endif

return false;
Expand Down