Skip to content

Commit

Permalink
add -o handling also for command case
Browse files Browse the repository at this point in the history
  • Loading branch information
stilscher committed Feb 7, 2022
1 parent f58c105 commit 93939a5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/util/compilationDatabase.ml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,14 @@ let load_and_preprocess ~all_cppflags filename =
(* TODO: extract o_file *)
let command = reroot command in
let preprocess_command = Str.replace_first command_program_regexp ("\\1 " ^ String.join " " (List.map Filename.quote all_cppflags) ^ " -E -MMD -MT " ^ file) command in
let preprocess_command = Str.replace_first command_o_regexp ("-o " ^ preprocessed_file) preprocess_command in
if preprocess_command = command then (* easier way to check if match was found (and replaced) *)
failwith "CompilationDatabase.preprocess: no -o argument found for " ^ file
failwith "CompilationDatabase.preprocess: no program found for " ^ file
else
preprocess_command
let preprocess_command_o = Str.replace_first command_o_regexp ("-o " ^ preprocessed_file) preprocess_command in
if preprocess_command_o = preprocess_command then (* easier way to check if match was found (and replaced) *)
preprocess_command ^ " -o " ^ preprocessed_file
else
preprocess_command_o
| None, Some arguments ->
let arguments = List.map reroot arguments in
let preprocess_arguments =
Expand Down

0 comments on commit 93939a5

Please sign in to comment.