Guard platform build target matrix

This commit is contained in:
2026-06-05 00:03:17 +02:00
parent 4ccedaae4c
commit db0ecb590c
5 changed files with 109 additions and 4 deletions

View File

@@ -0,0 +1,92 @@
#!/usr/bin/env python3
"""Verify platform-build wrappers include the current headless target matrix."""
from __future__ import annotations
import json
import re
import sys
from pathlib import Path
REQUIRED_COMPONENT_TARGETS = [
"pp_foundation",
"pp_assets",
"pp_paint",
"pp_document",
"pp_renderer_api",
"pp_renderer_gl",
"pp_paint_renderer",
"pp_ui_core",
"pp_platform_api",
"pp_app_core",
"pano_cli",
]
def repo_root() -> Path:
return Path(__file__).resolve().parents[2]
def cmake_test_targets(root: Path) -> list[str]:
cmake_lists = root / "tests" / "CMakeLists.txt"
text = cmake_lists.read_text(encoding="utf-8")
return sorted(set(re.findall(r"^\s*add_executable\(([^\s\)]+)", text, re.MULTILINE)))
def powershell_default_targets(root: Path) -> list[str]:
script = root / "scripts" / "automation" / "platform-build.ps1"
targets: list[str] = []
in_targets = False
for line in script.read_text(encoding="utf-8").splitlines():
if "[string[]]$Targets" in line:
in_targets = True
if not in_targets:
continue
targets.extend(re.findall(r'"([^"]+)"', line))
if in_targets and line.strip() == ")":
break
return sorted(set(targets))
def shell_default_targets(root: Path) -> list[str]:
script = root / "scripts" / "automation" / "platform-build.sh"
text = script.read_text(encoding="utf-8")
match = re.search(r'targets="\$\{[^:]+:-(.*)\}"', text)
if not match:
raise RuntimeError("Could not find default targets in platform-build.sh")
return sorted(set(match.group(1).split()))
def missing(expected: list[str], actual: list[str]) -> list[str]:
actual_set = set(actual)
return [target for target in expected if target not in actual_set]
def main() -> int:
root = repo_root()
expected = sorted(set(REQUIRED_COMPONENT_TARGETS + cmake_test_targets(root)))
ps_targets = powershell_default_targets(root)
sh_targets = shell_default_targets(root)
result = {
"ok": True,
"expectedTargetCount": len(expected),
"powershellTargetCount": len(ps_targets),
"shellTargetCount": len(sh_targets),
"missing": {
"platform-build.ps1": missing(expected, ps_targets),
"platform-build.sh": missing(expected, sh_targets),
},
}
result["ok"] = all(not values for values in result["missing"].values())
print(json.dumps(result, separators=(",", ":")))
return 0 if result["ok"] else 1
if __name__ == "__main__":
sys.exit(main())