File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -314,10 +314,24 @@ def _collect_all_sources_and_headers(ctx):
314314 sources_and_headers = all_files + headers .to_list ()
315315 return sources_and_headers
316316
317+ def _merge_options (default , custom ):
318+ """
319+ Merge command line arguments so that default options can be overridden
320+ """
321+ final = []
322+ args_set = []
323+ for item in custom :
324+ args_set .append (item .split (" " )[0 ].split ("=" )[0 ])
325+ final .append (item )
326+ for option in default :
327+ if option .split (" " )[0 ].split ("=" )[0 ] not in args_set :
328+ final .append (option )
329+ return final
330+
317331def _per_file_impl (ctx ):
318332 compile_commands_json = _compile_commands_impl (ctx )
319333 sources_and_headers = _collect_all_sources_and_headers (ctx )
320- options = ctx .attr .default_options + ctx .attr .options
334+ options = _merge_options ( ctx .attr .default_options , ctx .attr .options )
321335 all_files = [compile_commands_json ]
322336 for target in ctx .attr .targets :
323337 if not CcInfo in target :
You can’t perform that action at this time.
0 commit comments