Build wasm3 on Mac

This commit is contained in:
Ben Visness 2023-07-23 10:18:25 -05:00
parent 389b9607d6
commit 062cd1e2de
1 changed files with 19 additions and 4 deletions

View File

@ -188,13 +188,12 @@ def build_wasm3(release):
print("Building wasm3...") print("Building wasm3...")
os.makedirs("bin", exist_ok=True) os.makedirs("bin", exist_ok=True)
os.makedirs("bin\\obj", exist_ok=True) os.makedirs("bin/obj", exist_ok=True)
if platform.system() == "Windows": if platform.system() == "Windows":
build_wasm3_lib_win(release) build_wasm3_lib_win(release)
elif platform.system() == "Darwin": elif platform.system() == "Darwin":
log_error("can't yet build wasm3 on Mac") build_wasm3_lib_mac(release)
exit(1)
else: else:
log_error(f"can't build wasm3 for unknown platform '{platform.system()}'") log_error(f"can't build wasm3 for unknown platform '{platform.system()}'")
exit(1) exit(1)
@ -217,6 +216,21 @@ def build_wasm3_lib_win(release):
], check=True) ], 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): def build_orca(release):
print("Building Orca...") print("Building Orca...")
@ -225,7 +239,8 @@ def build_orca(release):
if platform.system() == "Windows": if platform.system() == "Windows":
build_orca_win(release) build_orca_win(release)
elif platform.system() == "Darwin": elif platform.system() == "Darwin":
raise "can't yet build Orca on Mac" log_error("can't yet build Orca on Mac")
exit(1)
else: else:
log_error(f"can't build Orca for unknown platform '{platform.system()}'") log_error(f"can't build Orca for unknown platform '{platform.system()}'")
exit(1) exit(1)