Skip to content

Commit 615f4a8

Browse files
committed
add -o handling also for command case
1 parent dfda270 commit 615f4a8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/util/compilationDatabase.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,14 @@ let load_and_preprocess ~all_cppflags filename =
6161
(* TODO: extract o_file *)
6262
let command = reroot command in
6363
let preprocess_command = Str.replace_first command_program_regexp ("\\1 " ^ String.join " " (List.map Filename.quote all_cppflags) ^ " -E -MMD -MT " ^ file) command in
64-
let preprocess_command = Str.replace_first command_o_regexp ("-o " ^ preprocessed_file) preprocess_command in
6564
if preprocess_command = command then (* easier way to check if match was found (and replaced) *)
66-
failwith "CompilationDatabase.preprocess: no -o argument found for " ^ file
65+
failwith "CompilationDatabase.preprocess: no program found for " ^ file
6766
else
68-
preprocess_command
67+
let preprocess_command_o = Str.replace_first command_o_regexp ("-o " ^ preprocessed_file) preprocess_command in
68+
if preprocess_command_o = preprocess_command then (* easier way to check if match was found (and replaced) *)
69+
preprocess_command ^ " -o " ^ preprocessed_file
70+
else
71+
preprocess_command_o
6972
| None, Some arguments ->
7073
let arguments = List.map reroot arguments in
7174
let preprocess_arguments =

0 commit comments

Comments
 (0)