mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-19 14:45:29 +00:00
Fix freeze build failure
This commit is contained in:
parent
df55c5f015
commit
08a1bf9028
3 changed files with 40 additions and 9 deletions
|
|
@ -127,17 +127,29 @@ def copy_libs(env) -> None:
|
|||
shutil.copy2(os.path.join(BIN, 'slangc'), env.bin_dir)
|
||||
|
||||
|
||||
GPU_DRIVERS = {'opengl': 'glsl-', 'vulkan': 'spirv-'} # driver name -> shader target prefix
|
||||
|
||||
|
||||
def check_gpu_drivers(env) -> None:
|
||||
# Both GPU drivers must be part of the build, along with the built-in
|
||||
# shaders compiled for their shader targets, otherwise kitty silently
|
||||
# Both GPU drivers must be part of the build, otherwise kitty silently
|
||||
# falls back to whichever driver is present
|
||||
print('Checking GPU drivers...')
|
||||
ext_dir = os.path.join(env.lib_dir, 'kitty-extensions')
|
||||
shaders_dir = os.path.join(env.lib_dir, 'kitty', 'shaders')
|
||||
for driver, target_prefix in (('opengl', 'glsl-'), ('vulkan', 'spirv-')):
|
||||
for driver in GPU_DRIVERS:
|
||||
path = os.path.join(ext_dir, f'kitty.{driver}.so')
|
||||
if not os.path.isfile(path):
|
||||
raise SystemExit(f'The {driver} GPU driver was not built, {path} does not exist')
|
||||
|
||||
|
||||
def check_builtin_shaders(env) -> None:
|
||||
# The built-in shaders must be compiled for the shader targets of both GPU
|
||||
# drivers. They are compiled by build_frozen_tools() so this must be called
|
||||
# after it.
|
||||
print('Checking built-in shaders...')
|
||||
shaders_dir = os.path.join(env.lib_dir, 'kitty', 'shaders')
|
||||
if not os.path.isdir(shaders_dir):
|
||||
raise SystemExit(f'The built-in shaders were not compiled, {shaders_dir} does not exist')
|
||||
for driver, target_prefix in GPU_DRIVERS.items():
|
||||
targets = [x for x in os.listdir(shaders_dir) if x.startswith(target_prefix) and os.path.isfile(os.path.join(shaders_dir, x, 'cell.json'))]
|
||||
if not targets:
|
||||
raise SystemExit(f'The built-in shaders were not compiled for the {driver} GPU driver in {shaders_dir}')
|
||||
|
|
@ -281,6 +293,7 @@ def main() -> None:
|
|||
add_ca_certs(env)
|
||||
kitty_exe = os.path.join(env.base, 'bin', 'kitty')
|
||||
iv['build_frozen_tools'](kitty_exe)
|
||||
check_builtin_shaders(env)
|
||||
if not args.dont_strip:
|
||||
strip_binaries(files)
|
||||
if not args.skip_tests:
|
||||
|
|
|
|||
|
|
@ -150,6 +150,9 @@ def sign_app(app_dir, notarize) -> None:
|
|||
notarize_app(app_dir, 'kitty')
|
||||
|
||||
|
||||
GPU_DRIVERS = {'opengl': 'glsl-', 'metal': 'msl-'} # driver name -> shader target prefix
|
||||
|
||||
|
||||
class Freeze(object):
|
||||
FID = '@executable_path/../Frameworks'
|
||||
|
||||
|
|
@ -184,6 +187,7 @@ class Freeze(object):
|
|||
self.freeze_python()
|
||||
self.add_ca_certs()
|
||||
self.build_frozen_tools()
|
||||
self.check_builtin_shaders()
|
||||
self.complete_sub_bundles()
|
||||
if not self.dont_strip:
|
||||
self.strip_files()
|
||||
|
|
@ -410,7 +414,7 @@ class Freeze(object):
|
|||
os.mkdir(pdir)
|
||||
print('Extracting extension modules from', self.python_stdlib, 'to', pdir)
|
||||
ext_map = extract_extension_modules(self.python_stdlib, pdir)
|
||||
self.check_gpu_drivers(pdir, join(kitty_dir, 'shaders'))
|
||||
self.check_gpu_drivers(pdir)
|
||||
shutil.copy(join(os.path.dirname(self_dir), 'site.py'), join(self.python_stdlib, 'site.py'))
|
||||
for x in bases:
|
||||
iv['sanitize_source_folder'](join(self.python_stdlib, x))
|
||||
|
|
@ -429,15 +433,25 @@ class Freeze(object):
|
|||
self.fix_dependencies_in_lib(f)
|
||||
|
||||
@flush
|
||||
def check_gpu_drivers(self, ext_dir: str, shaders_dir: str) -> None:
|
||||
# Both GPU drivers must be part of the build, along with the built-in
|
||||
# shaders compiled for their shader targets, otherwise kitty silently
|
||||
def check_gpu_drivers(self, ext_dir: str) -> None:
|
||||
# Both GPU drivers must be part of the build, otherwise kitty silently
|
||||
# falls back to whichever driver is present
|
||||
print('\nChecking GPU drivers...')
|
||||
for driver, target_prefix in (('opengl', 'glsl-'), ('metal', 'msl-')):
|
||||
for driver in GPU_DRIVERS:
|
||||
path = join(ext_dir, f'kitty.{driver}.so')
|
||||
if not os.path.isfile(path):
|
||||
raise SystemExit(f'The {driver} GPU driver was not built, {path} does not exist')
|
||||
|
||||
@flush
|
||||
def check_builtin_shaders(self) -> None:
|
||||
# The built-in shaders must be compiled for the shader targets of both
|
||||
# GPU drivers. They are compiled by build_frozen_tools() so this must
|
||||
# be called after it.
|
||||
print('\nChecking built-in shaders...')
|
||||
shaders_dir = join(self.resources_dir, 'kitty', 'shaders')
|
||||
if not os.path.isdir(shaders_dir):
|
||||
raise SystemExit(f'The built-in shaders were not compiled, {shaders_dir} does not exist')
|
||||
for driver, target_prefix in GPU_DRIVERS.items():
|
||||
targets = [x for x in os.listdir(shaders_dir) if x.startswith(target_prefix) and os.path.isfile(join(shaders_dir, x, 'cell.json'))]
|
||||
if not targets:
|
||||
raise SystemExit(f'The built-in shaders were not compiled for the {driver} GPU driver in {shaders_dir}')
|
||||
|
|
|
|||
4
setup.py
4
setup.py
|
|
@ -555,6 +555,8 @@ def test_compile(
|
|||
ldflags: Iterable[str] = (),
|
||||
get_output_arch: bool = False,
|
||||
) -> Union[bool, BinaryArch]:
|
||||
if not cc:
|
||||
raise SystemExit('test_compile() called with no C compiler, the build environment has not been initialized')
|
||||
src = src or 'int main(void) { return 0; }'
|
||||
with tempfile.TemporaryDirectory(prefix='kitty-test-compile-') as tdir:
|
||||
with open(os.path.join(tdir, f'source.{source_ext}'), 'w', encoding='utf-8') as srcf:
|
||||
|
|
@ -2675,6 +2677,8 @@ def do_build(args: Options) -> None:
|
|||
bundle_type = ('macos' if is_macos else 'linux') + '-freeze'
|
||||
build_launcher(args, launcher_dir=os.path.join(args.prefix, 'bin'), bundle_type=bundle_type)
|
||||
elif args.action == 'build-frozen-tools':
|
||||
# The env is needed to detect which GPU drivers, and hence shader targets, to build
|
||||
init_env_from_args(args, False)
|
||||
build_static_kittens(args, launcher_dir=args.prefix, for_freeze=True)
|
||||
elif args.action == 'linux-package':
|
||||
build(args, native_optimizations=False)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue