upleb.uk

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

summaryrefslogtreecommitdiff
path: root/make_game.py
diff options
context:
space:
mode:
Diffstat (limited to 'make_game.py')
-rw-r--r--make_game.py36
1 files changed, 30 insertions, 6 deletions
diff --git a/make_game.py b/make_game.py
index ff5ff7676..6ec27e33d 100644
--- a/make_game.py
+++ b/make_game.py
@@ -73,6 +73,7 @@ from mc_command import mc_command # noqa: E402
73import leonida_tui # noqa: E402 73import leonida_tui # noqa: E402
74from shader_stage_manifest import shader_stems # noqa: E402 74from shader_stage_manifest import shader_stems # noqa: E402
75from replace_retry import replace as replace_retry # noqa: E402 75from replace_retry import replace as replace_retry # noqa: E402
76from stale_build import newer_sources # noqa: E402
76 77
77VERSIONS = os.path.join(ROOT, "game") 78VERSIONS = os.path.join(ROOT, "game")
78STAGES = ["check", "shaders", "assets", "runtime", "pipelines"] 79STAGES = ["check", "shaders", "assets", "runtime", "pipelines"]
@@ -900,12 +901,16 @@ def preflight(stages: list, work: str, wav: bool = False, runtime_build: str | N
900 "Free some space or choose another drive with --work." + hint) 901 "Free some space or choose another drive with --work." + hint)
901 if os.name != "nt" and not runtime_build and any(s in WINDOWS_ONLY for s in stages): 902 if os.name != "nt" and not runtime_build and any(s in WINDOWS_ONLY for s in stages):
902 cross_configure() 903 cross_configure()
903 if "pipelines" in stages and os.name != "nt" and not pipeline_check_exe(): 904 if "pipelines" in stages and os.name != "nt":
904 build_pipeline_check(jobs) 905 checker = pipeline_check_exe()
905 if not pipeline_check_exe(): 906 # A checker built before a pull is rebuilt too; cmake --build only recompiles what changed. Without CMake
906 fail("vk_pipeline_check built, but not as runtime/build/linux/vk_pipeline_check (a multi-config " 907 # the pipelines stage says it is out of date and uses it.
907 "generator puts it in a subfolder): unset CMAKE_GENERATOR if it names one, delete " 908 if not checker or (stale_checker(checker) and shutil.which("cmake")):
908 "runtime/build/linux and run the build again.") 909 build_pipeline_check(jobs)
910 if not pipeline_check_exe():
911 fail("vk_pipeline_check built, but not as runtime/build/linux/vk_pipeline_check (a multi-config "
912 "generator puts it in a subfolder): unset CMAKE_GENERATOR if it names one, delete "
913 "runtime/build/linux and run the build again.")
909 if "assets" in stages: 914 if "assets" in stages:
910 ensure_submodule() 915 ensure_submodule()
911 916
@@ -2369,6 +2374,18 @@ def pipeline_check_exe(runtime_build: str | None = None) -> str | None:
2369 return next((p for p in found if os.path.isfile(p) and (windows or os.access(p, os.X_OK))), None) 2374 return next((p for p in found if os.path.isfile(p) and (windows or os.access(p, os.X_OK))), None)
2370 2375
2371 2376
2377def stale_checker(exe: str) -> list:
2378 """The sources of vk_pipeline_check changed after `exe` was built, when `exe` is in this checkout's runtime/build.
2379 A checker from elsewhere (--runtime-build) isn't compared: its time stamp says nothing about these sources."""
2380 build = os.path.abspath(os.path.join(ROOT, "runtime", "build"))
2381 try:
2382 if os.path.commonpath([build, os.path.abspath(exe)]) != build:
2383 return []
2384 except ValueError: # another drive
2385 return []
2386 return newer_sources(exe, ROOT, "vk_pipeline_check")
2387
2388
2372def require_translated_shaders(work: str) -> str: 2389def require_translated_shaders(work: str) -> str:
2373 spirv = os.path.join(work, "shaders", "spirv") 2390 spirv = os.path.join(work, "shaders", "spirv")
2374 index = os.path.join(spirv, "index.json") 2391 index = os.path.join(spirv, "index.json")
@@ -2394,6 +2411,13 @@ def pipelines(work: str, out: str, jobs: "int | None" = None, *, runtime_build:
2394 fail("vk_pipeline_check wasn't built. With CMake 3.24+, a C++20 compiler and the Vulkan headers and " 2411 fail("vk_pipeline_check wasn't built. With CMake 3.24+, a C++20 compiler and the Vulkan headers and "
2395 "loader installed, run: cmake -S runtime -B runtime/build/linux && " 2412 "loader installed, run: cmake -S runtime -B runtime/build/linux && "
2396 "cmake --build runtime/build/linux --parallel") 2413 "cmake --build runtime/build/linux --parallel")
2414 newer = stale_checker(exe)
2415 if newer:
2416 rebuild = ("run the runtime stage with VULKAN_SDK set" if os.name == "nt" else
2417 "cmake --build runtime/build/linux --target vk_pipeline_check")
2418 more = f" and {len(newer) - 3} more" if len(newer) > 3 else ""
2419 log(f"pipelines: WARNING: {exe} is older than {', '.join(newer[:3])}{more}, so it is not this checkout's "
2420 f"checker; to rebuild it, {rebuild}")
2397 spirv = require_translated_shaders(work) 2421 spirv = require_translated_shaders(work)
2398 log("pipelines: creating every shader module and pipeline (compute and graphics) on this GPU") 2422 log("pipelines: creating every shader module and pipeline (compute and graphics) on this GPU")
2399 os.makedirs(out, exist_ok=True) 2423 os.makedirs(out, exist_ok=True)