mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-21 07:55:10 +02:00
Do not generate empty default specialization files
This commit is contained in:
@@ -295,7 +295,7 @@ def commands_to_compile_to_spirv(sources: dict[str, SlangFile], build_dir: str,
|
|||||||
for x in sfile.specializations:
|
for x in sfile.specializations:
|
||||||
cmd = list(scmd)
|
cmd = list(scmd)
|
||||||
dest = f'{base_dest}.{x.name}.spv' if x.name else f'{base_dest}.spv'
|
dest = f'{base_dest}.{x.name}.spv' if x.name else f'{base_dest}.spv'
|
||||||
if x.name:
|
if x.variables:
|
||||||
cmd.insert(-1, f'{base_dest}{x.filename_insert}.slang-module')
|
cmd.insert(-1, f'{base_dest}{x.filename_insert}.slang-module')
|
||||||
cmd += base_cmd + ['-o', dest, '-reflection-json', dest + '.json']
|
cmd += base_cmd + ['-o', dest, '-reflection-json', dest + '.json']
|
||||||
output_mtime = safe_mtime(dest)
|
output_mtime = safe_mtime(dest)
|
||||||
@@ -430,20 +430,24 @@ def create_specialisations(sources: dict[str, SlangFile], build_dir: str, dest_d
|
|||||||
if sfile.entry_points and sfile.specializations:
|
if sfile.entry_points and sfile.specializations:
|
||||||
for sp in sfile.specializations:
|
for sp in sfile.specializations:
|
||||||
dest = f'{base_dest}{sp.filename_insert}.slang'
|
dest = f'{base_dest}{sp.filename_insert}.slang'
|
||||||
lines = []
|
payload = existing = ''
|
||||||
for key, val in sp.variables.items():
|
if sp.variables:
|
||||||
declaration = sfile.specializable_variables[key].rpartition('=')[0]
|
lines = []
|
||||||
if not declaration:
|
for key, val in sp.variables.items():
|
||||||
declaration = sfile.specializable_variables[key].rstrip(';')
|
declaration = sfile.specializable_variables[key].rpartition('=')[0]
|
||||||
declaration = declaration.replace('extern ', 'export ', 1)
|
if not declaration:
|
||||||
lines.append(f'{declaration} = {val};')
|
declaration = sfile.specializable_variables[key].rstrip(';')
|
||||||
payload = '\n'.join(lines)
|
declaration = declaration.replace('extern ', 'export ', 1)
|
||||||
needs_build = True
|
lines.append(f'{declaration} = {val};')
|
||||||
|
payload = '\n'.join(lines)
|
||||||
with suppress(FileNotFoundError), open(dest) as f:
|
with suppress(FileNotFoundError), open(dest) as f:
|
||||||
needs_build = f.read() != payload
|
existing = f.read()
|
||||||
if needs_build:
|
if needs_build := payload != existing:
|
||||||
with open(dest, 'w') as fw:
|
if payload:
|
||||||
fw.write(payload)
|
with open(dest, 'w') as fw:
|
||||||
|
fw.write(payload)
|
||||||
|
else:
|
||||||
|
os.remove(dest)
|
||||||
yield Command(needs_build, f'Compiling specialisation |{os.path.basename(dest)}| ...',
|
yield Command(needs_build, f'Compiling specialisation |{os.path.basename(dest)}| ...',
|
||||||
list(slangc) + [dest, '-o', dest + '-module'])
|
list(slangc) + [dest, '-o', dest + '-module'])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user