diff --git a/tools/extract.py b/tools/extract.py index c2c0d0ed..e50d384d 100644 --- a/tools/extract.py +++ b/tools/extract.py @@ -62,9 +62,16 @@ def version_dir(expected): return 'v0' if expected['version'] == 0 else 'v' + expected['display_version'].replace('.', '') +# The embeddable Python (a ._pth file) does not put a script's directory on sys.path, so a vendored script that imports +# its siblings fails when started by path. This stub adds the directory, then runs the script as __main__. +RUN_SCRIPT = ('import os, runpy, sys; p = sys.argv[1]; sys.path.insert(0, os.path.dirname(p)); sys.argv = sys.argv[1:]; ' + "runpy.run_path(p, run_name='__main__')") + + def run_logged(command, log): + args = [str(c) for c in command] with log.open('w') as out: - code = subprocess.run([str(c) for c in command], stdout=out, stderr=subprocess.STDOUT).returncode + code = subprocess.run([args[0], '-c', RUN_SCRIPT, *args[1:]], stdout=out, stderr=subprocess.STDOUT).returncode require(code == 0, f'{Path(command[1]).name} failed; see {log.relative_to(ROOT)}') diff --git a/tools/prepare_shaders.py b/tools/prepare_shaders.py index ad8069a6..4596758f 100644 --- a/tools/prepare_shaders.py +++ b/tools/prepare_shaders.py @@ -16,8 +16,9 @@ pipeline once, so the GPU driver's own disk cache holds them (vk_pipeline.c "sta a 12-core machine (inventory 1, translation 3, library builds 0.6) and 1.3 GB of shader cache; the seed files can be deleted afterwards. -Game-derived output stays in the build directory (ignored). The list is read from refs/ at preparation time; nothing -of it is copied into the repository. Needs Python 3.14 (compression.zstd), so run it in .venv-py314: +Game-derived output stays in the build directory (ignored). The list is read at preparation time from tools/data/shader_list.tsv when that file exists (the installer archive +bundles it; it stays out of the repository), else from refs/ through git; nothing of it is copied into the +repository. Needs Python 3.14 (compression.zstd), so run it in .venv-py314 or the embeddable 3.14: .venv-py314\\Scripts\\python tools\\prepare_shaders.py build\\v121 [--version v121] [--list ] [--no-run] """ @@ -50,9 +51,14 @@ CONTROL = 0x880 ANS_REC = 4 + 32 + 32 + 147 + 1 +BUNDLED_LIST = ROOT / 'tools' / 'data' / 'shader_list.tsv' # the installer archive carries a copy (no git, no refs/) + + def read_list(path): if path: return Path(path).read_text(encoding='utf-8') + if BUNDLED_LIST.is_file(): + return BUNDLED_LIST.read_text(encoding='utf-8') return subprocess.run(['git', '-C', str(ROOT / 'refs' / 'MacNativeGames'), 'show', ':'.join(LIST_REF)], check=True, capture_output=True, encoding='utf-8').stdout @@ -111,7 +117,7 @@ def main(): ap = argparse.ArgumentParser(description=__doc__.splitlines()[0]) ap.add_argument('build', type=Path, help='build directory holding totk.exe (build\\v121)') ap.add_argument('--version', default='v121', help='build/extracted/') - ap.add_argument('--list', help='a shader_list.tsv instead of the one in refs/MacNativeGames') + ap.add_argument('--list', help='a shader_list.tsv instead of tools/data/shader_list.tsv or refs/MacNativeGames') ap.add_argument('--no-run', action='store_true', help='write the seed files only') a = ap.parse_args() t0 = time.monotonic()