-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathSCsub
55 lines (46 loc) · 2.27 KB
/
SCsub
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from utils import download_wasmer, download_wasmtime, WASMER_VER_DEFAULT, WASMTIME_VER_DEFAULT
opts = Variables([], ARGUMENTS)
opts.Add(EnumVariable("wasm_runtime", "Wasm runtime used", "wasmer", ["wasmer", "wasmtime"]))
opts.Add(BoolVariable("download_runtime", "(Re)download runtime library", "no"))
opts.Add("runtime_version", "Runtime library version", None)
# Import env and create module-specific clone
Import("env")
module_env = env.Clone()
opts.Update(module_env)
# Download runtime if required
if module_env["wasm_runtime"] == "wasmer":
download_wasmer(env, module_env["download_runtime"], module_env.get("runtime_version", WASMER_VER_DEFAULT))
elif module_env["wasm_runtime"] == "wasmtime":
download_wasmtime(env, module_env["download_runtime"], module_env.get("runtime_version", WASMTIME_VER_DEFAULT))
# Check platform specifics
if env["platform"] in ["linux", "linuxbsd", "x11"]:
env["LIBRUNTIMESUFFIX"] = ".a"
elif env["platform"] in ["osx", "macos"]:
env["LIBRUNTIMESUFFIX"] = ".a"
env.Append(LINKFLAGS=["-framework", "Security", "-framework", "CoreFoundation", "-framework", "SystemConfiguration"])
elif env["platform"] == "windows":
if env.get("use_mingw"): # MinGW
env["LIBRUNTIMESUFFIX"] = ".a"
env.Append(LIBS=["userenv"])
else: # MSVC
env["LIBRUNTIMESUFFIX"] = ".lib"
# Force Windows SDK library suffix (see https://github.com/godotengine/godot/issues/23687)
env.Append(LINKFLAGS=["bcrypt.lib", "userenv.lib", "ws2_32.lib", "advapi32.lib", "ntdll.lib"])
# Explicit static libraries
runtime_lib = env.File(
"{runtime}/lib/{prefix}{runtime}{suffix}".format(
runtime=module_env["wasm_runtime"],
prefix=env["LIBPREFIX"],
suffix=env.get("LIBRUNTIMESUFFIX", env["LIBSUFFIX"]),
)
)
# Linked libraries (global env) and includes (cloned env)
env.Append(LIBPATH=[env.Dir("{}/lib".format(module_env["wasm_runtime"])).abspath])
env.Append(LIBS=[runtime_lib])
module_env.Append(CPPPATH=[env.Dir("{}/include".format(module_env["wasm_runtime"])).abspath])
# Defines for module agnosticism
module_env.Append(CPPDEFINES=["GODOT_MODULE", "LIBWASM_STATIC"])
# Module sources
module_env.add_source_files(
env.modules_sources, ["register_types.cpp", env.Glob("src/*.cpp", exclude="src/godot-library.cpp")]
)