File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -1065,6 +1065,17 @@ def _ensure_cwd_is_workspace_root():
1065
1065
for (target , flags ) in target_flag_pairs :
1066
1066
compile_command_entries .extend (_get_commands (target , flags ))
1067
1067
1068
+ should_merge = any (arg .startswith ('--file' ) for arg in sys .argv [1 :])
1069
+ if should_merge and os .path .isfile ('compile_commands.json' ):
1070
+ origin_compile_command_entries = []
1071
+ with open ('compile_commands.json' ) as fd :
1072
+ try :
1073
+ origin_compile_command_entries = json .load (fd )
1074
+ except :
1075
+ log_warning (">>> Failed to merge compile_commands.json the file seems has broken" )
1076
+ files_index = set (entry ['file' ] for entry in compile_command_entries )
1077
+ compile_command_entries += [entry for entry in origin_compile_command_entries if entry ['file' ] not in files_index ]
1078
+
1068
1079
# Chain output into compile_commands.json
1069
1080
with open ('compile_commands.json' , 'w' ) as output_file :
1070
1081
json .dump (
You can’t perform that action at this time.
0 commit comments