mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-20 03:59:59 -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:
@@ -61,6 +61,7 @@ import ctypes.wintypes as wt # the job-object structures below; importing it w
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -180,6 +181,40 @@ def vma_include():
|
||||
return VMA_LOCAL
|
||||
|
||||
|
||||
def system_vulkan_version(clang, env=None):
|
||||
"""VK_HEADER_VERSION of the <vulkan/vulkan_core.h> this compiler finds by itself (its own search path, CPATH
|
||||
included), 0 when it finds none."""
|
||||
probe = '#include <vulkan/vulkan_core.h>\nnx2navi_vulkan_headers VK_HEADER_VERSION\n'
|
||||
try:
|
||||
p = subprocess.run([str(clang), '-E', '-P', '-x', 'c', '-'], input=probe, capture_output=True, text=True,
|
||||
env=env, errors='replace')
|
||||
except OSError:
|
||||
return 0
|
||||
m = re.search(r'nx2navi_vulkan_headers\s+(\d+)', p.stdout) if p.returncode == 0 else None
|
||||
return int(m.group(1)) if m else 0
|
||||
|
||||
|
||||
def vulkan_include(clang=None, env=None):
|
||||
"""A build with the system's own headers (Linux without --deps): the folder to put ahead of them for
|
||||
<vulkan/vulkan.h>, or None when the system's serve. The runtime names Vulkan extensions newer than the headers
|
||||
many distributions package, and every file that does fails to compile there (tools/vulkan_pin.py). So:
|
||||
toolchain/vulkan-headers when it holds the pinned release (a kit carries it; a checkout once it was fetched), else
|
||||
nothing when the system's headers are at least that release, else the pinned release, fetched there once.
|
||||
Windows takes MSYS2's headers and returns None."""
|
||||
if WIN:
|
||||
return None
|
||||
import vulkan_pin
|
||||
local = ROOT / vulkan_pin.FOLDER
|
||||
if vulkan_pin.have(local):
|
||||
return local / 'include'
|
||||
found = system_vulkan_version(clang or CLANG, env)
|
||||
if found >= vulkan_pin.HEADER_VERSION:
|
||||
return None
|
||||
print(f'build_game: the system\'s Vulkan headers are {f"release {found}" if found else "missing"}; the runtime is '
|
||||
f'built against release {vulkan_pin.HEADER_VERSION} ({vulkan_pin.VERSION}) or newer', flush=True)
|
||||
return vulkan_pin.resolve(local) / 'include'
|
||||
|
||||
|
||||
# --toolchain: an llvm-mingw tree. The libraries, headers and DLLs MSYS2 supplies come from the deps directory instead.
|
||||
LLVM_LINK_LIBS = ['-lpsapi', '-lbcrypt', '-luser32', '-lgdi32', '-ldwmapi', '-limm32', '-lwinmm', '-lole32', '-lshell32', '-luuid', '-lvulkan-1', '-lSDL3', '-lopus',
|
||||
'-l:libvpx.a', '-l:libzstd.a', '-l:libc++.a', '-l:libc++abi.a', '-l:libunwind.a', '-l:libwinpthread.a']
|
||||
@@ -380,6 +415,9 @@ def ninja_file(gen, out, mods, pool_depth, skip=(), prebuilt=False, runtime_lib=
|
||||
vma = f'{cmd_path(DEPS / "include")} -I {cmd_path(DEPS / "include" / "vma")}' if DEPS else cmd_path(vma_include())
|
||||
imgui = cmd_path(RUNTIME / 'third_party' / 'imgui')
|
||||
rt_inc = f'{inc} -I {cmd_path(out)} -I {vma} -I {imgui}' # romfs_config.h, vk_mem_alloc.h (+ deps headers), imgui.h
|
||||
vulkan = None if DEPS else vulkan_include() # deps carries the Vulkan headers itself
|
||||
if vulkan: # first, so that no other folder on the path answers for <vulkan/vulkan.h> (VMA's may be /usr/include)
|
||||
rt_inc = f'-I {cmd_path(vulkan)} {rt_inc}'
|
||||
libs = [f'-L {cmd_path(DEPS / "lib")}'] + (LLVM_LINK_LIBS if WIN else LINK_LIBS) if DEPS else LINK_LIBS
|
||||
# A compiler cache (sccache) may front clang: every lift rewrites the generated chunks with the same contents, so
|
||||
# the cached objects save the compile step on the next build.
|
||||
|
||||
Reference in New Issue
Block a user