Skip to content

Commit 65c643b

Browse files
committed
Only remove gyb-generated files that don't exist anymore
If we delete all files, we are touching every file, causing a rebuild after every gyb-generation even if no file was changed.
1 parent 6d0e3a1 commit 65c643b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

build-script.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ def generate_gyb_files(verbose, add_source_locations, tar_path):
110110
# Clear any *.swift files that are relics from the previous run.
111111
for previous_gyb_gen_file in os.listdir(generated_files_dir):
112112
if previous_gyb_gen_file.endswith('.swift'):
113-
check_call(['rm', previous_gyb_gen_file], cwd=generated_files_dir)
113+
gyb_file = os.path.join(swiftsyntax_sources_dir,
114+
previous_gyb_gen_file + '.gyb')
115+
if not os.path.exists(gyb_file):
116+
check_call(['rm', previous_gyb_gen_file], cwd=generated_files_dir,
117+
verbose=verbose)
114118

115119
# Generate the new .swift files in a temporary directory and only copy them
116120
# to Sources/SwiftSyntax/gyb_generated if they are different than the files

0 commit comments

Comments
 (0)