mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-17 07:09:57 -04:00
Keep the runtime's shaders in the repository as source only, and compile them when the game is built.
The fifteen headers of SPIR-V words under runtime/ are no longer tracked. tools/build_shaders.py builds all of them: the GLSL with glslc, the SPIR-V assembly with spirv-as, and the two shaders assembled in Python from their scripts. build_game.py builds the missing and the stale ones before it compiles the runtime, and the build kit, the launcher release and the AppImage build them before they copy runtime/, so a player's PC still needs no shader compiler. git ignores the headers and check_content.py refuses a compiled shader in a commit. The headers built this way are byte for byte the ones removed here. vk_mvobj_fs.h is now mvobj_fs_spv.h, named like the others. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""Refuse files that look like game content, keys or generated game code.
|
||||
"""Refuse files that look like game content, keys, generated game code or compiled shaders.
|
||||
|
||||
Runs in CI on every push and pull request, and locally as the pre-commit hook
|
||||
(.githooks/pre-commit). With no arguments it checks every tracked file; with
|
||||
@@ -83,6 +83,14 @@ def problems_for(path: Path, allow_large: bool = False, data: bytes | None = Non
|
||||
return found
|
||||
|
||||
|
||||
def compiled_shader(path: Path) -> bool:
|
||||
"""A SPIR-V binary or a header of SPIR-V words. The repository holds its shaders as source (runtime/shaders/, the
|
||||
tools/make_*.py assemblers) and tools/build_shaders.py builds runtime/<name>_spv.h from them when the game is
|
||||
built. A build kit or a release folder carries the headers, so make_kit.py and make_release.py, which call
|
||||
problems_for, are not held to this."""
|
||||
return path.suffix.lower() == ".spv" or path.name.lower().endswith("_spv.h")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||
parser.add_argument("--staged", action="store_true", help="check staged files only")
|
||||
@@ -92,11 +100,14 @@ def main() -> int:
|
||||
for path in list_files(args.staged):
|
||||
# --staged checks what the commit takes: a marker staged and then removed from the working copy alone
|
||||
# passed when the file on disk was read
|
||||
for problem in problems_for(path, data=staged_bytes(path) if args.staged else None):
|
||||
problems = problems_for(path, data=staged_bytes(path) if args.staged else None)
|
||||
if compiled_shader(path):
|
||||
problems.append("compiled shader: the repository holds the source, tools/build_shaders.py builds this")
|
||||
for problem in problems:
|
||||
print(f"{path}: {problem}")
|
||||
failed = True
|
||||
if failed:
|
||||
print("\nGame content, keys and generated game code never go into the repository.")
|
||||
print("\nGame content, keys, generated game code and compiled shaders never go into the repository.")
|
||||
print("See CONTRIBUTING.md.")
|
||||
return 1
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user