From 0908a609fc1ad35308796b0bad1e05d37bfdb331 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Tue, 19 Mar 2024 16:56:46 +0000 Subject: Use Python script to build runtime --- runtime/build.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 runtime/build.py (limited to 'runtime') diff --git a/runtime/build.py b/runtime/build.py new file mode 100644 index 00000000..bd55dbf4 --- /dev/null +++ b/runtime/build.py @@ -0,0 +1,57 @@ +import dataclasses +import os +from pathlib import Path +import subprocess + + +@dataclasses.dataclass(frozen=True) +class Target: + name: str + requires_sizeof_jmp_buf: bool + + +targets = [ + Target( + name="amd64", + requires_sizeof_jmp_buf=True, + ), + Target( + name="i686", + requires_sizeof_jmp_buf=True, + ), + Target( + name="wasm32", + requires_sizeof_jmp_buf=False, + ), + Target( + name="wasm64", + requires_sizeof_jmp_buf=False, + ), +] + + +gcs = ["mark-and-sweep"] + + +def main(): + os.chdir(Path(__file__).parent) + + for target in targets: + for gc in gcs: + target_dir = Path("target") / target.name / gc + + setup_command = ["meson", "setup", target_dir, "--werror", f"-Dgc={gc}"] + if target.name != "amd64": + setup_command += ["--cross-file", f"{target.name}.meson"] + subprocess.check_call(setup_command) + + subprocess.check_call(["meson", "compile", "--verbose"], cwd=target_dir) + + if target.requires_sizeof_jmp_buf: + sizeof_jmp_buf = subprocess.check_output([Path("target") / target.name / gcs[0] / "sizeof_jmp_buf"]) + with open(Path("target") / target.name / "sizeof_jmp_buf.txt", "wb") as fileobj: + fileobj.write(sizeof_jmp_buf) + + +if __name__ == "__main__": + main() -- cgit v1.2.3