From 25f660227fba1ae095decbacd182dd189b5e4ace Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Wed, 19 Jul 2023 18:14:27 -0500 Subject: [PATCH] Add Windows wasm3 build --- scripts/build_runtime.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/scripts/build_runtime.py b/scripts/build_runtime.py index e832187..eb642f9 100644 --- a/scripts/build_runtime.py +++ b/scripts/build_runtime.py @@ -27,6 +27,7 @@ def build_runtime(args): ensure_angle() build_milepost("lib", args.release) + build_wasm3(args.release) def build_milepost(target, release): @@ -180,6 +181,38 @@ def build_milepost_lib_mac(release): ], check=True) +def build_wasm3(release): + print("Building wasm3...") + + os.makedirs("bin", exist_ok=True) + os.makedirs("bin\\obj", exist_ok=True) + + if platform.system() == "Windows": + build_wasm3_lib_win(release) + elif platform.system() == "Darwin": + raise "can't yet build wasm3 on Mac" + else: + log_error(f"can't build wasm3 for unknown platform '{platform.system()}'") + exit(1) + + +def build_wasm3_lib_win(release): + for f in glob.iglob(".\\ext\\wasm3\\source\\*.c"): + name = os.path.splitext(os.path.basename(f))[0] + subprocess.run([ + "cl", "/nologo", + "/Zi", "/Zc:preprocessor", "/c", + *(["/O2"] if release else []), + f"/Fo:bin\\obj\\{name}.obj", + "/I", ".\\ext\\wasm3\\source", + f, + ], check=True) + subprocess.run([ + "lib", "/nologo", "/out:bin\\wasm3.lib", + "bin\\obj\\*.obj", + ], check=True) + + def ensure_programs(): if platform.system() == "Windows": try: