2022-06-06 13:09:32 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
def exists(env):
|
|
|
|
return "EM_CONFIG" in os.environ
|
|
|
|
|
|
|
|
|
|
|
|
def generate(env):
|
|
|
|
if env["arch"] not in ("wasm32"):
|
|
|
|
print("Only wasm32 supported on web. Exiting.")
|
2023-09-09 08:55:53 +00:00
|
|
|
env.Exit(1)
|
2022-06-06 13:09:32 +00:00
|
|
|
|
|
|
|
if "EM_CONFIG" in os.environ:
|
|
|
|
env["ENV"] = os.environ
|
|
|
|
|
|
|
|
env["CC"] = "emcc"
|
|
|
|
env["CXX"] = "em++"
|
|
|
|
env["AR"] = "emar"
|
|
|
|
env["RANLIB"] = "emranlib"
|
|
|
|
env.Append(CPPFLAGS=["-s", "SIDE_MODULE=1"])
|
|
|
|
env.Append(LINKFLAGS=["-s", "SIDE_MODULE=1"])
|
|
|
|
env["SHOBJSUFFIX"] = ".bc"
|
|
|
|
env["SHLIBSUFFIX"] = ".wasm"
|
|
|
|
# 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 LLVM bitcode.
|
|
|
|
env["OBJPREFIX"] = ""
|
|
|
|
env["OBJSUFFIX"] = ".bc"
|
|
|
|
env["PROGPREFIX"] = ""
|
|
|
|
# Program() output consists of multiple files, so specify suffixes manually at builder.
|
|
|
|
env["PROGSUFFIX"] = ""
|
|
|
|
env["LIBPREFIX"] = "lib"
|
|
|
|
env["LIBSUFFIX"] = ".a"
|
|
|
|
env["LIBPREFIXES"] = ["$LIBPREFIX"]
|
|
|
|
env["LIBSUFFIXES"] = ["$LIBSUFFIX"]
|
|
|
|
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"])
|
2023-07-22 12:46:14 +00:00
|
|
|
|
|
|
|
env.Append(CPPDEFINES=["WEB_ENABLED", "UNIX_ENABLED"])
|