mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-03 13:13:35 +02:00
Nicer validation integration
This commit is contained in:
@@ -474,8 +474,8 @@ def compile_builtin_shaders(build_dir: str, dest_dir: str, parallel_run: Paralle
|
||||
parallel_run(chain(spirv_commands, glsl_commands))
|
||||
fixup_opengl_files(*built_glsl_files)
|
||||
if shutil.which('glslangValidator'):
|
||||
from kitty.shaders.validate_shaders import validate_glsl_files
|
||||
validate_glsl_files(built_glsl_files)
|
||||
from kitty.shaders.validate_shaders import validation_command_for_file
|
||||
parallel_run((True, f'Validating |{os.path.basename(x)}| ...', validation_command_for_file(x)) for x in built_glsl_files)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
|
||||
@@ -13,17 +13,22 @@ stage_mapping = {
|
||||
}
|
||||
|
||||
|
||||
def validation_command_for_file(path: str | Path) -> list[str]:
|
||||
file_path = Path(path)
|
||||
matched_ext = next(ext for ext in stage_mapping if file_path.name.endswith(ext))
|
||||
stage = stage_mapping[matched_ext]
|
||||
return ['glslangValidator', '-S', stage, str(file_path)]
|
||||
|
||||
|
||||
def validate_glsl_files(shader_files: Iterable[str | Path], verbose: bool = False) -> None:
|
||||
error_count = 0
|
||||
|
||||
# Process each shader file
|
||||
for file_path in sorted(Path(f) for f in shader_files):
|
||||
# Identify extension matching suffix
|
||||
matched_ext = next(ext for ext in stage_mapping if file_path.name.endswith(ext))
|
||||
stage = stage_mapping[matched_ext]
|
||||
if verbose:
|
||||
print(f'Validating: {file_path.name}')
|
||||
result = subprocess.run(['glslangValidator', '-S', stage, str(file_path)],)
|
||||
result = subprocess.run(validation_command_for_file(file_path))
|
||||
|
||||
# Check exit code
|
||||
if result.returncode != 0:
|
||||
|
||||
Reference in New Issue
Block a user