Files

35 lines
1.7 KiB
Python

# SPDX-License-Identifier: GPL-3.0-or-later
"""Run bounded-allocation checks and the manual's crew example on both guest CPUs."""
import argparse
import os
from pathlib import Path
import subprocess
import tempfile
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("runtime", type=Path, help="staged toolchain with vcccompat and wydealloc")
parser.add_argument("core", type=Path, help="current libVCCCore.a")
parser.add_argument("rom", type=Path, help="privately supplied CoCo 3 ROM")
args = parser.parse_args()
runtime = args.runtime.resolve(strict=True)
fixture = Path(__file__).resolve().parent
root = fixture.parents[2]
env = dict(os.environ, VCC_CMOC_COMPAT="1", PATH=str(runtime / "bin") + os.pathsep + os.environ["PATH"])
with tempfile.TemporaryDirectory(prefix="vcc-heap-") as work:
subprocess.run(["xcrun", "clang++", "-std=c++17", "-O2", "-mmacosx-version-min=14.0",
"-I", root / "src", fixture / "run.cpp", args.core.resolve(strict=True), "-o", "run"],
cwd=work, check=True)
for optimization in ("-O0", "-O2"):
for source, name in ((fixture / "qualification.c", "QUAL.BIN"),
(root / "examples/cmoc/manual/crew.c", "CREW.BIN")):
subprocess.run([runtime / "bin/cmoc", "--coco", optimization, "-Werror", "--org=2800",
"-o", name, source, "-lvcccompat", "-lwydealloc"], env=env, cwd=work, check=True)
print("Checking", optimization, flush=True)
subprocess.run(["./run", args.rom.resolve(strict=True), "QUAL.BIN", "CREW.BIN"], cwd=work, check=True)
if __name__ == "__main__":
main()