From fd1a92847559054cd199b0bca27b6a5baa0511ea Mon Sep 17 00:00:00 2001 From: Alice Mikhaylenko Date: Sun, 22 Jun 2025 03:03:09 +0400 Subject: [PATCH] main: Skip unchanged blp files in batch-compile Don't invalidate everything every time, otherwise we rebuild everything even when no file has changed at all. With e.g. Vala this means more or less rebuilding the entire project with no incremental builds. --- blueprintcompiler/main.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/blueprintcompiler/main.py b/blueprintcompiler/main.py index 1c3a1c6..8c47d49 100644 --- a/blueprintcompiler/main.py +++ b/blueprintcompiler/main.py @@ -170,6 +170,18 @@ class BlueprintApp: add_typelib_search_path(typelib_path) for file in opts.inputs: + path = os.path.join( + opts.output_dir, + os.path.relpath(os.path.splitext(file.name)[0] + ".ui", opts.input_dir), + ) + + if os.path.isfile(path): + in_time = os.path.getmtime(file.name) + out_time = os.path.getmtime(path) + + if out_time >= in_time: + continue + data = file.read() file_abs = os.path.abspath(file.name) input_dir_abs = os.path.abspath(opts.input_dir) @@ -186,12 +198,6 @@ class BlueprintApp: for warning in warnings: warning.pretty_print(file.name, data, stream=sys.stderr) - path = os.path.join( - opts.output_dir, - os.path.relpath( - os.path.splitext(file.name)[0] + ".ui", opts.input_dir - ), - ) os.makedirs(os.path.dirname(path), exist_ok=True) with open(path, "w") as file: file.write(xml)