Files
ARCADIA-Studio/harness/experiments/text-navigation-native-20260911/build/build_gui_v2.py
T

51 lines
2.8 KiB
Python

"""Build one identified Windows GUI and bind its Cargo artifact to frozen inputs."""
import datetime
import hashlib
import json
import os
from pathlib import Path
import subprocess
root = Path(__file__).resolve().parents[2]
evidence = Path(__file__).resolve().parent
manifest = json.loads((evidence / "inputs4.json").read_text(encoding="utf-8"))
build_commit = "36db9356cce3c7614ae37eec9fe17678ca210afe"
assert subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=root).decode().strip() == build_commit
assert not subprocess.check_output(["git", "status", "--porcelain", "--", "crates", "docs", "examples", ".cargo", "Cargo.toml", "Cargo.lock", "harness/fixtures"], cwd=root).strip()
def sha(path):
return hashlib.sha256(path.read_bytes()).hexdigest()
def verify():
for entry in manifest["files"]:
path = (root / entry["path"]).resolve()
assert path.is_relative_to(root) and sha(path) == entry["sha256"], entry["path"]
def now():
return datetime.datetime.now(datetime.timezone.utc).isoformat()
verify()
os.environ["CARGO_BUILD_JOBS"] = "1"
args = ["cargo", "build", "--locked", "--offline", "-p", "oa-desktop", "--bin", "arcadia-studio", "--message-format=json-render-diagnostics"]
started = now()
with (evidence / "gui-build-v2-messages.jsonl").open("xb") as out, (evidence / "gui-build-v2-stderr.log").open("xb") as err:
result = subprocess.run(args, cwd=root, stdout=out, stderr=err)
receipt = {"started": started, "finished": now(), "exitCode": result.returncode,
"args": args, "buildJobs": 1, "head": build_commit, "capturedBaseHead": manifest["head"], "branch": manifest["branch"],
"rawInputs": "inputs4.json", "rawInputArchiveSha256": manifest["archiveSha256"],
"scope": "Windows development GUI from committed navigation source and exact inputs4 bytes; native evaluation pending"}
if result.returncode == 0:
verify()
messages = [json.loads(line) for line in (evidence / "gui-build-v2-messages.jsonl").read_text(encoding="utf-8").splitlines()]
artifacts = [m for m in messages if m.get("reason") == "compiler-artifact" and m.get("target", {}).get("name") == "arcadia-studio" and m.get("executable") and not m.get("profile", {}).get("test")]
assert len(artifacts) == 1, len(artifacts)
binary = Path(artifacts[0]["executable"]).resolve()
assert binary.is_relative_to(root / ".local/target-gnullvm")
receipt.update(binary=str(binary), sha256=sha(binary), bytes=binary.stat().st_size,
cargoArtifact=artifacts[0], inputsUnchanged=True)
with (evidence / "gui-build-v2.json").open("x", encoding="utf-8", newline="\n") as out:
json.dump(receipt, out, indent=2)
out.write("\n")
print(json.dumps({k: receipt[k] for k in ("started", "finished", "exitCode", "sha256", "bytes") if k in receipt}))
raise SystemExit(result.returncode)