Merge pull request #1247 from nicholas-maltbie/nickmaltbie/javascript-wasm-fix

Javascript Web WASM Fix
This commit is contained in:
David Snopek
2023-10-04 09:58:01 -05:00
committed by GitHub
3 changed files with 25 additions and 9 deletions

View File

@@ -1,8 +1,9 @@
import os
from SCons.Util import WhereIs
def exists(env):
return "EM_CONFIG" in os.environ
return WhereIs("emcc") is not None
def generate(env):
@@ -10,9 +11,6 @@ def generate(env):
print("Only wasm32 supported on web. Exiting.")
env.Exit(1)
if "EM_CONFIG" in os.environ:
env["ENV"] = os.environ
env["CC"] = "emcc"
env["CXX"] = "em++"
env["AR"] = "emar"
@@ -26,6 +24,10 @@ def generate(env):
env["ARCOM_POSIX"] = env["ARCOM"].replace("$TARGET", "$TARGET.posix").replace("$SOURCES", "$SOURCES.posix")
env["ARCOM"] = "${TEMPFILE(ARCOM_POSIX)}"
# Thread support (via SharedArrayBuffer).
env.Append(CCFLAGS=["-s", "USE_PTHREADS=1"])
env.Append(LINKFLAGS=["-s", "USE_PTHREADS=1"])
# All intermediate files are just LLVM bitcode.
env["OBJPREFIX"] = ""
env["OBJSUFFIX"] = ".bc"
@@ -39,9 +41,4 @@ def generate(env):
env.Replace(SHLINKFLAGS="$LINKFLAGS")
env.Replace(SHLINKFLAGS="$LINKFLAGS")
if env["target"] == "debug":
env.Append(CCFLAGS=["-O0", "-g"])
elif env["target"] == "release":
env.Append(CCFLAGS=["-O3"])
env.Append(CPPDEFINES=["WEB_ENABLED", "UNIX_ENABLED"])