Skip to content

Commit 384b25c

Browse files
committed
fix preprocess command composition
1 parent 615f4a8 commit 384b25c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/util/compilationDatabase.ml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,23 @@ let load_and_preprocess ~all_cppflags filename =
7070
else
7171
preprocess_command_o
7272
| None, Some arguments ->
73-
let arguments = List.map reroot arguments in
73+
let arguments_program, arguments =
74+
begin match List.map reroot arguments with
75+
| arguments_program::arguments -> arguments_program, arguments
76+
| _ -> failwith ("CompilationDatabase.preprocess: no program found for " ^ file)
77+
end in
7478
let preprocess_arguments =
7579
let suf =
7680
begin match List.findi (fun i e -> e = "-o") arguments with
7781
| (o_i, _) ->
7882
begin match List.split_at o_i arguments with
79-
| (arguments_init, o_file :: arguments_tl) -> arguments_init @ preprocessed_file :: arguments_tl
83+
| (arguments_init, _ :: o_file :: arguments_tl) -> arguments_init @ "-o" :: preprocessed_file :: arguments_tl
8084
| _ -> failwith ("CompilationDatabase.preprocess: no argument found for -o option for " ^ file)
8185
end
8286
| exception Not_found -> arguments @ "-o" :: [preprocessed_file]
8387
end in
8488
all_cppflags @ "-E" :: "-MMD" :: "-MT" :: file :: suf in
85-
begin match arguments with
86-
| (arguments_program :: arguments) -> Filename.quote_command arguments_program preprocess_arguments
87-
| _ -> failwith "CompilationDatabase.preprocess: no program found for " ^ file
88-
end
89+
Filename.quote_command arguments_program preprocess_arguments
8990
| Some _, Some _ ->
9091
failwith "CompilationDatabase.preprocess: both command and arguments specified for " ^ file
9192
| None, None ->

0 commit comments

Comments
 (0)