From 93939a5f79d7e76405642381fe8d0500f14d65eb Mon Sep 17 00:00:00 2001 From: stilscher <66023521+stilscher@users.noreply.github.com> Date: Mon, 7 Feb 2022 17:52:52 +0100 Subject: [PATCH] add -o handling also for command case --- src/util/compilationDatabase.ml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/util/compilationDatabase.ml b/src/util/compilationDatabase.ml index 6ffdf31872f..fcd0bcfe7c2 100644 --- a/src/util/compilationDatabase.ml +++ b/src/util/compilationDatabase.ml @@ -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 =