From 062cd1e2de8245dcf192a7c8b0813447a5fbb022 Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Sun, 23 Jul 2023 10:18:25 -0500 Subject: [PATCH] Build wasm3 on Mac --- scripts/build_runtime.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/scripts/build_runtime.py b/scripts/build_runtime.py index 1fc9935..7dc98b0 100644 --- a/scripts/build_runtime.py +++ b/scripts/build_runtime.py @@ -188,13 +188,12 @@ def build_wasm3(release): print("Building wasm3...") os.makedirs("bin", exist_ok=True) - os.makedirs("bin\\obj", exist_ok=True) + os.makedirs("bin/obj", exist_ok=True) if platform.system() == "Windows": build_wasm3_lib_win(release) elif platform.system() == "Darwin": - log_error("can't yet build wasm3 on Mac") - exit(1) + build_wasm3_lib_mac(release) else: log_error(f"can't build wasm3 for unknown platform '{platform.system()}'") exit(1) @@ -217,6 +216,21 @@ def build_wasm3_lib_win(release): ], check=True) +def build_wasm3_lib_mac(release): + for f in glob.iglob("./ext/wasm3/source/*.c"): + name = os.path.splitext(os.path.basename(f))[0] + ".o" + subprocess.run([ + "clang", "-c", + "-g", *(["/O2"] if release else []), + "-foptimize-sibling-calls", "-Wno-extern-initializer", "-Dd_m3VerboseErrorMessages", + "-I./ext/wasm3/source", + "-o", f"./bin/obj/{name}", + f, + ], check=True) + subprocess.run(["ar", "-rcs", "./bin/libwasm3.a", *glob.glob("./bin/obj/*.o")], check=True) + subprocess.run(["rm", "-rf", "./bin/obj"], check=True) + + def build_orca(release): print("Building Orca...") @@ -225,7 +239,8 @@ def build_orca(release): if platform.system() == "Windows": build_orca_win(release) elif platform.system() == "Darwin": - raise "can't yet build Orca on Mac" + log_error("can't yet build Orca on Mac") + exit(1) else: log_error(f"can't build Orca for unknown platform '{platform.system()}'") exit(1)