upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/tools/first_light.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/first_light.py')
-rw-r--r--tools/first_light.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/tools/first_light.py b/tools/first_light.py
index 7ce4c8a7d..75d14d7af 100644
--- a/tools/first_light.py
+++ b/tools/first_light.py
@@ -50,6 +50,8 @@ TOOLS = os.path.dirname(os.path.abspath(__file__))
50ROOT = os.path.dirname(TOOLS) 50ROOT = os.path.dirname(TOOLS)
51sys.path.insert(0, os.path.join(ROOT, "runtime", "test", "shaders")) 51sys.path.insert(0, os.path.join(ROOT, "runtime", "test", "shaders"))
52from compute_fixture import find_test_program # noqa: E402 52from compute_fixture import find_test_program # noqa: E402
53sys.path.insert(0, TOOLS) # python -I leaves the script's own folder off sys.path
54from stale_build import newer_sources # noqa: E402
53 55
54DEFAULT_VS = "VS_main_170e32e6_Wrapped" 56DEFAULT_VS = "VS_main_170e32e6_Wrapped"
55DEFAULT_PS = "$PS_Rage_Untextured_14f8529b_Wrapped" 57DEFAULT_PS = "$PS_Rage_Untextured_14f8529b_Wrapped"
@@ -584,6 +586,24 @@ def uv_probes(vertices, indices, width: int, height: int, limit: int = 4) -> lis
584 return found 586 return found
585 587
586 588
589def warn_if_stale(harness: str) -> str:
590 """`harness`, after a warning when it is a build in this checkout's runtime/build older than vk_harness's sources
591 (a pull since it was built): it would draw with the old harness and say nothing. A harness outside runtime/build
592 (--harness or LEONIDA_VK_HARNESS naming another folder) isn't compared."""
593 build = os.path.abspath(os.path.join(ROOT, "runtime", "build"))
594 try:
595 ours = os.path.commonpath([build, os.path.abspath(harness)]) == build
596 except ValueError: # another drive
597 ours = False
598 newer = newer_sources(harness, ROOT, "vk_harness") if ours else []
599 if newer:
600 more = f" and {len(newer) - 3} more" if len(newer) > 3 else ""
601 print(f"WARNING: {harness} is older than {', '.join(newer[:3])}{more}; rebuild it "
602 f"(cmake --build <build folder> --target vk_harness) to draw with this checkout's harness",
603 file=sys.stderr)
604 return harness
605
606
587def find_harness(explicit: str | None) -> str: 607def find_harness(explicit: str | None) -> str:
588 executable = "vk_harness.exe" if os.name == "nt" else "vk_harness" 608 executable = "vk_harness.exe" if os.name == "nt" else "vk_harness"
589 build = os.path.join(ROOT, "runtime", "build") 609 build = os.path.join(ROOT, "runtime", "build")
@@ -594,11 +614,11 @@ def find_harness(explicit: str | None) -> str:
594 *(os.path.join(folder, executable) for folder in build_dirs), 614 *(os.path.join(folder, executable) for folder in build_dirs),
595 ): 615 ):
596 if candidate and os.path.isfile(candidate): 616 if candidate and os.path.isfile(candidate):
597 return candidate 617 return warn_if_stale(candidate)
598 for folder in build_dirs: 618 for folder in build_dirs:
599 configured = find_test_program(folder, "vk_harness") 619 configured = find_test_program(folder, "vk_harness")
600 if configured: 620 if configured:
601 return os.path.join(configured, executable) 621 return warn_if_stale(os.path.join(configured, executable))
602 raise SystemExit( 622 raise SystemExit(
603 "vk_harness not found: build runtime/build/linux or runtime/build/windows (target vk_harness), " 623 "vk_harness not found: build runtime/build/linux or runtime/build/windows (target vk_harness), "
604 "or set --harness/LEONIDA_VK_HARNESS" 624 "or set --harness/LEONIDA_VK_HARNESS"