mirror of
https://github.com/godotengine/godot-cpp.git
synced 2026-01-01 05:48:37 +03:00
SUPPORT_LONGJMP have changed since emscripten 3.1.32 to default to
"wasm" mode when exceptions are enabled, and "emscripten" mode when
disabled.
While we generally doesn't use exception in core, linked libraries may
need them, and emscripten don't plan to support WASM EH + Emscripten
SjLj in the long term.
(cherry picked from commit 1bb543b6f4)
52 lines
1.5 KiB
Python
52 lines
1.5 KiB
Python
import common_compiler_flags
|
|
from SCons.Util import WhereIs
|
|
|
|
|
|
def exists(env):
|
|
return WhereIs("emcc") is not None
|
|
|
|
|
|
def generate(env):
|
|
if env["arch"] not in ("wasm32"):
|
|
print("Only wasm32 supported on web. Exiting.")
|
|
env.Exit(1)
|
|
|
|
# Emscripten toolchain
|
|
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")
|
|
env["ARCOM"] = "${TEMPFILE(ARCOM_POSIX)}"
|
|
|
|
# All intermediate files are just object files.
|
|
env["OBJSUFFIX"] = ".o"
|
|
env["SHOBJSUFFIX"] = ".o"
|
|
|
|
# Static libraries clang-style.
|
|
env["LIBPREFIX"] = "lib"
|
|
env["LIBSUFFIX"] = ".a"
|
|
|
|
# Shared library as wasm.
|
|
env["SHLIBSUFFIX"] = ".wasm"
|
|
|
|
# Thread support (via SharedArrayBuffer).
|
|
if env["threads"]:
|
|
env.Append(CCFLAGS=["-sUSE_PTHREADS=1"])
|
|
env.Append(LINKFLAGS=["-sUSE_PTHREADS=1"])
|
|
|
|
# Build as side module (shared library).
|
|
env.Append(CPPFLAGS=["-sSIDE_MODULE=1"])
|
|
env.Append(LINKFLAGS=["-sSIDE_MODULE=1"])
|
|
|
|
# Force wasm longjmp mode.
|
|
env.Append(CCFLAGS=["-sSUPPORT_LONGJMP='wasm'"])
|
|
env.Append(LINKFLAGS=["-sSUPPORT_LONGJMP='wasm'"])
|
|
|
|
env.Append(CPPDEFINES=["WEB_ENABLED", "UNIX_ENABLED"])
|
|
|
|
common_compiler_flags.generate(env)
|