1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-10 13:00:37 +00:00

Add proxy_to_pthread option to platform=web

Co-authored-by: Fabio Alessandrelli <fabio.alessandrelli@gmail.com>
This commit is contained in:
Adam Scott
2023-07-20 09:42:03 -04:00
parent c2b916751d
commit 78c2a08fae
20 changed files with 420 additions and 39 deletions

View File

@@ -41,6 +41,11 @@ def get_opts():
"dlink_enabled", "Enable WebAssembly dynamic linking (GDExtension support). Produces bigger binaries", False
),
BoolVariable("use_closure_compiler", "Use closure compiler to minimize JavaScript code", False),
BoolVariable(
"proxy_to_pthread",
"Use Emscripten PROXY_TO_PTHREAD option to run the main application code to a separate thread",
True,
),
]
@@ -211,6 +216,10 @@ def configure(env: "Environment"):
env.Append(LINKFLAGS=["-Wl,-u,scalbnf"])
if env["dlink_enabled"]:
if env["proxy_to_pthread"]:
print("GDExtension support requires proxy_to_pthread=no, disabling")
env["proxy_to_pthread"] = False
if cc_semver < (3, 1, 14):
print("GDExtension support requires emscripten >= 3.1.14, detected: %s.%s.%s" % cc_semver)
sys.exit(255)
@@ -221,6 +230,16 @@ def configure(env: "Environment"):
env.Append(LINKFLAGS=["-fvisibility=hidden"])
env.extra_suffix = ".dlink" + env.extra_suffix
# Run the main application in a web worker
if env["proxy_to_pthread"]:
env.Append(LINKFLAGS=["-s", "PROXY_TO_PTHREAD=1"])
env.Append(CPPDEFINES=["PROXY_TO_PTHREAD_ENABLED"])
env.Append(LINKFLAGS=["-s", "EXPORTED_RUNTIME_METHODS=['_emscripten_proxy_main']"])
# https://github.com/emscripten-core/emscripten/issues/18034#issuecomment-1277561925
env.Append(LINKFLAGS=["-s", "TEXTDECODER=0"])
# BigInt support to pass object pointers between contexts
env.Append(LINKFLAGS=["-s", "WASM_BIGINT"])
# Reduce code size by generating less support code (e.g. skip NodeJS support).
env.Append(LINKFLAGS=["-s", "ENVIRONMENT=web,worker"])