11from utils import download_wasmer, download_wasmtime, WASMER_VER_DEFAULT, WASMTIME_VER_DEFAULT
22
3+ # Import env and create module-specific clone
4+ Import("env")
5+
6+ default_runtime = "wasmtime"
7+ if env["platform"] in ["web"]:
8+ default_runtime = "wamr"
9+
310opts = Variables([], ARGUMENTS)
411
5- opts.Add(EnumVariable("wasm_runtime", "Wasm runtime used", "wasmtime" , ["wasmer", "wasmtime"]))
12+ opts.Add(EnumVariable("wasm_runtime", "Wasm runtime used", default_runtime , ["wasmer", "wasmtime", "wamr "]))
613opts.Add(BoolVariable("download_runtime", "(Re)download runtime library", "no"))
714opts.Add("runtime_version", "Runtime library version", None)
815
9- # Import env and create module-specific clone
10- Import("env")
16+
17+
1118module_env = env.Clone()
1219opts.Update(module_env)
1320
@@ -33,21 +40,29 @@ elif env["platform"] == "windows":
3340 env.Append(LINKFLAGS=["bcrypt.lib", "userenv.lib", "ws2_32.lib", "advapi32.lib", "ntdll.lib"])
3441
3542# Explicit static libraries
36- runtime_lib = env.File(
37- "{runtime}/lib/{prefix}{runtime}{suffix}".format(
38- runtime=module_env["wasm_runtime"],
39- prefix=env["LIBPREFIX"],
40- suffix=env.get("LIBRUNTIMESUFFIX", env["LIBSUFFIX"]),
43+ if module_env["wasm_runtime"] != "wamr":
44+ runtime_lib = env.File(
45+ "{runtime}/lib/{prefix}{runtime}{suffix}".format(
46+ runtime=module_env["wasm_runtime"],
47+ prefix=env["LIBPREFIX"],
48+ suffix=env.get("LIBRUNTIMESUFFIX", env["LIBSUFFIX"]),
49+ )
50+ )
51+ env.Append(LIBS=[runtime_lib])
52+ else:
53+ module_env.add_source_files(
54+ env.modules_sources, [env.Glob("wamr/src/*.c"), "wamr/stub.cpp"]
4155 )
42- )
4356
4457# Linked libraries (global env) and includes (cloned env)
45- env.Append(LIBPATH=[env.Dir("{}/lib".format(module_env["wasm_runtime"])).abspath])
46- env.Append(LIBS=[runtime_lib])
58+ if module_env["wasm_runtime"] != "wamr":
59+ env.Append(LIBPATH=[env.Dir("{}/lib".format(module_env["wasm_runtime"])).abspath])
60+
4761module_env.Append(CPPPATH=[env.Dir("{}/include".format(module_env["wasm_runtime"])).abspath])
4862
4963# Defines for module agnosticism
5064module_env.Append(CPPDEFINES=["GODOT_MODULE", "LIBWASM_STATIC"])
65+ module_env.Append(CPPDEFINES=["WASM_RUNTIME_" + module_env["wasm_runtime"]])
5166
5267# Module sources
5368module_env.add_source_files(
0 commit comments