mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 07:53:26 +00:00
[Web] Fix Emscripten for WebXR and update minimum version
This commit is contained in:
parent
71a9948157
commit
793258919b
4 changed files with 35 additions and 23 deletions
2
.github/workflows/web_builds.yml
vendored
2
.github/workflows/web_builds.yml
vendored
|
@ -9,7 +9,7 @@ env:
|
|||
tests=no
|
||||
debug_symbols=no
|
||||
use_closure_compiler=yes
|
||||
EM_VERSION: 3.1.64
|
||||
EM_VERSION: 4.0.11
|
||||
|
||||
jobs:
|
||||
web-template:
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
/**************************************************************************/
|
||||
|
||||
const GodotWebXR = {
|
||||
$GodotWebXR__deps: ['$Browser', '$GL', '$GodotRuntime', '$runtimeKeepalivePush', '$runtimeKeepalivePop'],
|
||||
$GodotWebXR__deps: ['$MainLoop', '$GL', '$GodotRuntime', '$runtimeKeepalivePush', '$runtimeKeepalivePop'],
|
||||
$GodotWebXR: {
|
||||
gl: null,
|
||||
|
||||
|
@ -64,9 +64,9 @@ const GodotWebXR = {
|
|||
},
|
||||
monkeyPatchRequestAnimationFrame: (enable) => {
|
||||
if (GodotWebXR.orig_requestAnimationFrame === null) {
|
||||
GodotWebXR.orig_requestAnimationFrame = Browser.requestAnimationFrame;
|
||||
GodotWebXR.orig_requestAnimationFrame = MainLoop.requestAnimationFrame;
|
||||
}
|
||||
Browser.requestAnimationFrame = enable
|
||||
MainLoop.requestAnimationFrame = enable
|
||||
? GodotWebXR.requestAnimationFrame
|
||||
: GodotWebXR.orig_requestAnimationFrame;
|
||||
},
|
||||
|
@ -76,11 +76,11 @@ const GodotWebXR = {
|
|||
// enabled or disabled. When using the WebXR API Emulator, this
|
||||
// gets picked up automatically, however, in the Oculus Browser
|
||||
// on the Quest, we need to pause and resume the main loop.
|
||||
Browser.mainLoop.pause();
|
||||
MainLoop.pause();
|
||||
runtimeKeepalivePush();
|
||||
window.setTimeout(function () {
|
||||
runtimeKeepalivePop();
|
||||
Browser.mainLoop.resume();
|
||||
MainLoop.resume();
|
||||
}, 0);
|
||||
},
|
||||
|
||||
|
|
|
@ -101,6 +101,21 @@ def library_emitter(target, source, env):
|
|||
|
||||
|
||||
def configure(env: "SConsEnvironment"):
|
||||
env["CC"] = "emcc"
|
||||
env["CXX"] = "em++"
|
||||
|
||||
env["AR"] = "emar"
|
||||
env["RANLIB"] = "emranlib"
|
||||
|
||||
# Get version info for checks below.
|
||||
cc_version = get_compiler_version(env)
|
||||
cc_semver = (cc_version["major"], cc_version["minor"], cc_version["patch"])
|
||||
|
||||
# Minimum emscripten requirements.
|
||||
if cc_semver < (4, 0, 0):
|
||||
print_error("The minimum Emscripten version to build Godot is 4.0.0, detected: %s.%s.%s" % cc_semver)
|
||||
sys.exit(255)
|
||||
|
||||
env.Append(LIBEMITTER=[library_emitter])
|
||||
|
||||
env["EXPORTED_FUNCTIONS"] = ["_main"]
|
||||
|
@ -149,10 +164,15 @@ def configure(env: "SConsEnvironment"):
|
|||
env.Append(LINKFLAGS=["-Wl,--fatal-warnings"])
|
||||
|
||||
# LTO
|
||||
|
||||
if env["lto"] == "auto": # Enable LTO for production.
|
||||
env["lto"] = "thin"
|
||||
|
||||
if env["lto"] == "thin" and cc_semver < (4, 0, 9):
|
||||
print_warning(
|
||||
'"lto=thin" support requires Emscripten 4.0.9 (detected %s.%s.%s), using "lto=full" instead.' % cc_semver
|
||||
)
|
||||
env["lto"] = "full"
|
||||
|
||||
if env["lto"] != "none":
|
||||
if env["lto"] == "thin":
|
||||
env.Append(CCFLAGS=["-flto=thin"])
|
||||
|
@ -175,6 +195,13 @@ def configure(env: "SConsEnvironment"):
|
|||
env.Append(LINKFLAGS=["-sSAFE_HEAP=1"])
|
||||
|
||||
# Closure compiler
|
||||
if env["use_closure_compiler"] and cc_semver < (4, 0, 11):
|
||||
print_warning(
|
||||
'"use_closure_compiler=yes" support requires Emscripten 4.0.11 (detected %s.%s.%s), using "use_closure_compiler=no" instead.'
|
||||
% cc_semver
|
||||
)
|
||||
env["use_closure_compiler"] = False
|
||||
|
||||
if env["use_closure_compiler"]:
|
||||
# For emscripten support code.
|
||||
env.Append(LINKFLAGS=["--closure", "1"])
|
||||
|
@ -201,12 +228,6 @@ def configure(env: "SConsEnvironment"):
|
|||
# Add method for creating the final zip file
|
||||
env.AddMethod(create_template_zip, "CreateTemplateZip")
|
||||
|
||||
env["CC"] = "emcc"
|
||||
env["CXX"] = "em++"
|
||||
|
||||
env["AR"] = "emar"
|
||||
env["RANLIB"] = "emranlib"
|
||||
|
||||
# Use TempFileMunge since some AR invocations are too long for cmd.exe.
|
||||
# Use POSIX-style paths, required with TempFileMunge.
|
||||
env["ARCOM_POSIX"] = env["ARCOM"].replace("$TARGET", "$TARGET.posix").replace("$SOURCES", "$SOURCES.posix")
|
||||
|
@ -223,15 +244,6 @@ def configure(env: "SConsEnvironment"):
|
|||
env["LIBPREFIXES"] = ["$LIBPREFIX"]
|
||||
env["LIBSUFFIXES"] = ["$LIBSUFFIX"]
|
||||
|
||||
# Get version info for checks below.
|
||||
cc_version = get_compiler_version(env)
|
||||
cc_semver = (cc_version["major"], cc_version["minor"], cc_version["patch"])
|
||||
|
||||
# Minimum emscripten requirements.
|
||||
if cc_semver < (3, 1, 62):
|
||||
print_error("The minimum emscripten version to build Godot is 3.1.62, detected: %s.%s.%s" % cc_semver)
|
||||
sys.exit(255)
|
||||
|
||||
env.Prepend(CPPPATH=["#platform/web"])
|
||||
env.Append(CPPDEFINES=["WEB_ENABLED", "UNIX_ENABLED", "UNIX_SOCKET_UNAVAILABLE"])
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ if (process && process.env && process.env.npm_command && !fs.existsSync('./platf
|
|||
}
|
||||
|
||||
const emscriptenGlobals = {
|
||||
'Browser': true,
|
||||
'ERRNO_CODES': true,
|
||||
'FS': true,
|
||||
'GL': true,
|
||||
|
@ -22,6 +21,7 @@ const emscriptenGlobals = {
|
|||
'HEAPU32': true,
|
||||
'IDBFS': true,
|
||||
'LibraryManager': true,
|
||||
'MainLoop': true,
|
||||
'Module': true,
|
||||
'UTF8ToString': true,
|
||||
'UTF8Decoder': true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue