mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 07:53:26 +00:00
[Web] Add Web-build specific stdout header
This commit is contained in:
parent
cc9761c3f0
commit
f411c5b2f1
9 changed files with 101 additions and 5 deletions
|
@ -591,15 +591,20 @@ bool OS::has_feature(const String &p_feature) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef THREADS_ENABLED
|
|
||||||
if (p_feature == "threads") {
|
if (p_feature == "threads") {
|
||||||
|
#ifdef THREADS_ENABLED
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
if (p_feature == "nothreads") {
|
return false;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
if (p_feature == "nothreads") {
|
||||||
|
#ifdef THREADS_ENABLED
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (_check_internal_feature_support(p_feature)) {
|
if (_check_internal_feature_support(p_feature)) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -40,6 +40,7 @@ sys_env.AddJSLibraries(
|
||||||
[
|
[
|
||||||
"js/libs/library_godot_audio.js",
|
"js/libs/library_godot_audio.js",
|
||||||
"js/libs/library_godot_display.js",
|
"js/libs/library_godot_display.js",
|
||||||
|
"js/libs/library_godot_emscripten.js",
|
||||||
"js/libs/library_godot_fetch.js",
|
"js/libs/library_godot_fetch.js",
|
||||||
"js/libs/library_godot_webmidi.js",
|
"js/libs/library_godot_webmidi.js",
|
||||||
"js/libs/library_godot_os.js",
|
"js/libs/library_godot_os.js",
|
||||||
|
|
|
@ -267,6 +267,7 @@ def configure(env: "SConsEnvironment"):
|
||||||
print_warning("GDExtension support requires proxy_to_pthread=no, disabling proxy to pthread.")
|
print_warning("GDExtension support requires proxy_to_pthread=no, disabling proxy to pthread.")
|
||||||
env["proxy_to_pthread"] = False
|
env["proxy_to_pthread"] = False
|
||||||
|
|
||||||
|
env.Append(CPPDEFINES=["WEB_DLINK_ENABLED"])
|
||||||
env.Append(CCFLAGS=["-sSIDE_MODULE=2"])
|
env.Append(CCFLAGS=["-sSIDE_MODULE=2"])
|
||||||
env.Append(LINKFLAGS=["-sSIDE_MODULE=2"])
|
env.Append(LINKFLAGS=["-sSIDE_MODULE=2"])
|
||||||
env.Append(CCFLAGS=["-fvisibility=hidden"])
|
env.Append(CCFLAGS=["-fvisibility=hidden"])
|
||||||
|
|
|
@ -29,6 +29,7 @@ const emscriptenGlobals = {
|
||||||
'_free': true,
|
'_free': true,
|
||||||
'_malloc': true,
|
'_malloc': true,
|
||||||
'autoAddDeps': true,
|
'autoAddDeps': true,
|
||||||
|
'addToLibrary': true,
|
||||||
'addOnPostRun': true,
|
'addOnPostRun': true,
|
||||||
'getValue': true,
|
'getValue': true,
|
||||||
'lengthBytesUTF8': true,
|
'lengthBytesUTF8': true,
|
||||||
|
|
|
@ -353,6 +353,11 @@ void EditorExportPlatformWeb::get_preset_features(const Ref<EditorExportPreset>
|
||||||
} else {
|
} else {
|
||||||
r_features->push_back("nothreads");
|
r_features->push_back("nothreads");
|
||||||
}
|
}
|
||||||
|
if (p_preset->get("variant/extensions_support").operator bool()) {
|
||||||
|
r_features->push_back("web_extensions");
|
||||||
|
} else {
|
||||||
|
r_features->push_back("web_noextensions");
|
||||||
|
}
|
||||||
r_features->push_back("wasm32");
|
r_features->push_back("wasm32");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,9 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Emscripten
|
||||||
|
extern char *godot_js_emscripten_get_version();
|
||||||
|
|
||||||
// Config
|
// Config
|
||||||
extern void godot_js_config_locale_get(char *p_ptr, int p_ptr_max);
|
extern void godot_js_config_locale_get(char *p_ptr, int p_ptr_max);
|
||||||
extern void godot_js_config_canvas_id_get(char *p_ptr, int p_ptr_max);
|
extern void godot_js_config_canvas_id_get(char *p_ptr, int p_ptr_max);
|
||||||
|
|
44
platform/web/js/libs/library_godot_emscripten.js
Normal file
44
platform/web/js/libs/library_godot_emscripten.js
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/**************************************************************************/
|
||||||
|
/* library_godot_emscripten.js */
|
||||||
|
/**************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/**************************************************************************/
|
||||||
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||||
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* */
|
||||||
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||||
|
/* a copy of this software and associated documentation files (the */
|
||||||
|
/* "Software"), to deal in the Software without restriction, including */
|
||||||
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||||
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||||
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||||
|
/* the following conditions: */
|
||||||
|
/* */
|
||||||
|
/* The above copyright notice and this permission notice shall be */
|
||||||
|
/* included in all copies or substantial portions of the Software. */
|
||||||
|
/* */
|
||||||
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||||
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||||
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||||
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||||
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||||
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||||
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
|
/**************************************************************************/
|
||||||
|
|
||||||
|
const GodotEmscripten = {
|
||||||
|
$GodotEmscripten__deps: ['$GodotRuntime'],
|
||||||
|
$GodotEmscripten: {},
|
||||||
|
|
||||||
|
godot_js_emscripten_get_version__proxy: 'sync',
|
||||||
|
godot_js_emscripten_get_version__sig: 'p',
|
||||||
|
godot_js_emscripten_get_version: function () {
|
||||||
|
// WARNING: The caller needs to free the string pointer.
|
||||||
|
const emscriptenVersionPtr = GodotRuntime.allocString('{{{ EMSCRIPTEN_VERSION }}}');
|
||||||
|
return emscriptenVersionPtr;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
autoAddDeps(GodotEmscripten, '$GodotEmscripten');
|
||||||
|
addToLibrary(GodotEmscripten);
|
|
@ -160,6 +160,22 @@ bool OS_Web::_check_internal_feature_support(const String &p_feature) {
|
||||||
if (p_feature == "web") {
|
if (p_feature == "web") {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (p_feature == "web_extensions") {
|
||||||
|
#ifdef WEB_DLINK_ENABLED
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (p_feature == "web_noextensions") {
|
||||||
|
#ifdef WEB_DLINK_ENABLED
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (godot_js_os_has_feature(p_feature.utf8().get_data())) {
|
if (godot_js_os_has_feature(p_feature.utf8().get_data())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,24 @@ void main_loop_callback() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_web_header() {
|
||||||
|
// Emscripten.
|
||||||
|
char *emscripten_version_char = godot_js_emscripten_get_version();
|
||||||
|
String emscripten_version = vformat("Emscripten %s", emscripten_version_char);
|
||||||
|
memfree(emscripten_version_char);
|
||||||
|
|
||||||
|
// Build features.
|
||||||
|
String thread_support = OS::get_singleton()->has_feature("threads")
|
||||||
|
? "multi-threaded"
|
||||||
|
: "single-threaded";
|
||||||
|
String extensions_support = OS::get_singleton()->has_feature("web_extensions")
|
||||||
|
? "GDExtension support"
|
||||||
|
: "no GDExtension support";
|
||||||
|
|
||||||
|
Vector<String> build_configuration = { emscripten_version, thread_support, extensions_support };
|
||||||
|
print_line(vformat("Build configuration: %s.", String(", ").join(build_configuration)));
|
||||||
|
}
|
||||||
|
|
||||||
/// When calling main, it is assumed FS is setup and synced.
|
/// When calling main, it is assumed FS is setup and synced.
|
||||||
extern EMSCRIPTEN_KEEPALIVE int godot_web_main(int argc, char *argv[]) {
|
extern EMSCRIPTEN_KEEPALIVE int godot_web_main(int argc, char *argv[]) {
|
||||||
os = new OS_Web();
|
os = new OS_Web();
|
||||||
|
@ -128,6 +146,8 @@ extern EMSCRIPTEN_KEEPALIVE int godot_web_main(int argc, char *argv[]) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print_web_header();
|
||||||
|
|
||||||
main_started = true;
|
main_started = true;
|
||||||
|
|
||||||
// Ease up compatibility.
|
// Ease up compatibility.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue