mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 21:39:58 -04:00
Build the Linux kit against pinned Vulkan headers and without #embed, and try the compiler before the long steps.
A player's AppImage build of 0.7.1 stopped in its compile step after eight minutes of RomFS work: four files did not compile, because the kit builds with the system's compiler and headers and theirs were older than the runtime needs. vk_pipeline.c and vk_device.c name VK_KHR_pipeline_binary, VK_KHR_dynamic_rendering_local_read and VK_KHR_shader_maximal_reconvergence, which their Vulkan headers did not declare, and ui/menu.cpp takes its font in with #embed, which clang has from version 19. - Vulkan headers: tools/vulkan_pin.py holds the release the other builds use (1.4.363, the archive and hash tools/make_release_linux.py already pinned, which now reads them from there). The AppImage carries its C headers in toolchain/vulkan-headers and builds against them whatever the system has; a kit or a source checkout uses the system's when they are at least that release and fetches the pinned ones otherwise (build_game.py vulkan_include). Their folder goes first on the include path of the runtime's sources only, so the lifted code's objects keep their keys, and a runtime object compiled before against the system's headers is taken over instead of compiled again. AppRun no longer asks for the system's Vulkan headers. - #embed: tools/build_shaders.py also writes the font's bytes as runtime/ui/roboto_ttf.h (ignored by git, carried by a kit), and menu.cpp includes that where the compiler has no __has_embed. With #embed nothing changes. - Before its long steps a Linux build that will compile now checks every runtime source that needs no header of the install with the compile step's own command (clang -fsyntax-only) and links an empty program against the game's libraries (make_game.py preflight): an old compiler, an old header or a missing development package stops it in the first seconds with the compiler's own errors. A failed compile names every file that failed, not only the three whose errors it prints. Checked on Windows: tests/launcher_test.py passes with four new tests (117); the header of bytes and #embed give the same 162,588 bytes, and both branches of menu.cpp compile; the early check passes on the Windows file set with clang 23 and stops on files made to fail; the 34 local headers of release 363 are the upstream tag's files by git blob id. Not run: anything on Linux, the pinned archive's download, a compiler older than 23. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""Build the runtime's own shaders into C headers of SPIR-V words.
|
||||
"""Build the runtime's own shaders into C headers of SPIR-V words, and the files it embeds into headers of bytes.
|
||||
|
||||
The repository holds the shaders as source only. Each becomes runtime/<name>_spv.h, which declares
|
||||
`static const uint32_t <name>_spv[]`; the headers are build outputs (ignored by git) and tools/build_game.py builds the
|
||||
@@ -8,6 +8,9 @@ missing and the stale ones before it compiles the runtime. Three kinds of source
|
||||
runtime/shaders/<name>.spvasm SPIR-V assembly, assembled with spirv-as and checked with spirv-val
|
||||
tools/make_dlaa_mask.py, make_mvobj_fs.py shaders assembled in Python (ASSEMBLED); they need no other tool
|
||||
|
||||
One more kind of header is no shader: a file the runtime embeds (EMBEDDED: the menu's font) as a list of its bytes,
|
||||
for a compiler without #embed (runtime/ui/menu.cpp includes it there). It needs no tool.
|
||||
|
||||
A compiled or assembled header records the SHA-256 of its source and is stale when that no longer matches; a Python
|
||||
one is stale when its text is not what its script gives. glslc, spirv-as and spirv-val come from MSYS2 UCRT64 on
|
||||
Windows (packages mingw-w64-ucrt-x86_64-shaderc and mingw-w64-ucrt-x86_64-spirv-tools) and from PATH elsewhere
|
||||
@@ -36,10 +39,28 @@ ASM = '.spvasm'
|
||||
ASM_TARGET = 'vulkan1.3'
|
||||
# header name -> the script beside this one that assembles it; the script's HEADER is the header's text
|
||||
ASSEMBLED = {'dlaa_mask': 'make_dlaa_mask.py', 'mvobj_fs': 'make_mvobj_fs.py'}
|
||||
# a file below runtime/ the runtime embeds -> the header of its bytes, below runtime/ too (git ignores it)
|
||||
EMBEDDED = {'ui/fonts/Roboto-Medium.ttf': 'ui/roboto_ttf.h'}
|
||||
|
||||
|
||||
def embedded(src):
|
||||
"""True for a file of EMBEDDED: a binary file, read as it is."""
|
||||
return src.suffix not in STAGES and src.suffix not in (ASM, '.py')
|
||||
|
||||
|
||||
def source_hash(src):
|
||||
return hashlib.sha256(src.read_bytes().replace(b'\r\n', b'\n')).hexdigest() # the same on a CRLF checkout
|
||||
data = src.read_bytes()
|
||||
return hashlib.sha256(data if embedded(src) else data.replace(b'\r\n', b'\n')).hexdigest() # text: the same on a CRLF checkout
|
||||
|
||||
|
||||
def bytes_header(src, runtime):
|
||||
"""The header of an embedded file: its bytes as decimal numbers, to include inside an array's braces."""
|
||||
data = src.read_bytes()
|
||||
lines = [f'// Generated by tools/build_shaders.py from runtime/{src.relative_to(runtime).as_posix()}; do not edit.',
|
||||
f'// source sha256 {source_hash(src)}',
|
||||
f'// The file\'s {len(data)} bytes, for a compiler without #embed.']
|
||||
lines += [','.join(map(str, data[i:i + 32])) + ',' for i in range(0, len(data), 32)]
|
||||
return '\n'.join(lines) + '\n'
|
||||
|
||||
|
||||
def header_of(src, words):
|
||||
@@ -64,6 +85,7 @@ def sources(runtime):
|
||||
found = sorted(p for p in shaders.iterdir() if p.suffix in STAGES or p.suffix == ASM) if shaders.is_dir() else []
|
||||
out = [(p, runtime / f'{p.stem}_spv.h') for p in found]
|
||||
out += [(TOOLS / script, runtime / f'{name}_spv.h') for name, script in ASSEMBLED.items() if (TOOLS / script).is_file()]
|
||||
out += [(runtime / src, runtime / header) for src, header in EMBEDDED.items() if (runtime / src).is_file()]
|
||||
return out
|
||||
|
||||
|
||||
@@ -130,12 +152,14 @@ def build(runtime, only=None):
|
||||
todo = stale(runtime) if only is None else list(only)
|
||||
headers = dict(sources(runtime))
|
||||
for src in todo:
|
||||
text = assembled_text(src) if src.suffix == '.py' else header_of(src, words_of(src))
|
||||
text = (assembled_text(src) if src.suffix == '.py' else bytes_header(src, runtime) if embedded(src)
|
||||
else header_of(src, words_of(src)))
|
||||
header = headers[src]
|
||||
part = header.with_name(header.name + '.part') # whole or not at all: another build may be reading the folder
|
||||
part.write_text(text, encoding='utf-8', newline='\n')
|
||||
part.replace(header)
|
||||
print(f'{header.name}: {text.count("0x")} words from {src.name}')
|
||||
print(f'{header.name}: {src.stat().st_size} bytes of {src.name}' if embedded(src)
|
||||
else f'{header.name}: {text.count("0x")} words from {src.name}')
|
||||
return len(todo)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user