|
|
|
@ -17,6 +17,41 @@ type action_item =
|
|
|
|
|
| ClangError string
|
|
|
|
|
| ClangWarning string;
|
|
|
|
|
|
|
|
|
|
let clang_ignore_regex = Option.map f::Str.regexp Config.clang_ignore_regex;
|
|
|
|
|
|
|
|
|
|
let check_for_existing_file args =>
|
|
|
|
|
if (Option.is_some clang_ignore_regex && Option.is_none Config.buck_compilation_database) {
|
|
|
|
|
let (arg_files, args_list) = List.partition_tf f::(String.is_prefix prefix::"@") args;
|
|
|
|
|
let read_arg_files args_list arg_file_at => {
|
|
|
|
|
let file = String.slice arg_file_at 1 (String.length arg_file_at);
|
|
|
|
|
let args_list_file = In_channel.read_lines file;
|
|
|
|
|
List.append args_list args_list_file
|
|
|
|
|
};
|
|
|
|
|
let all_args_ = List.fold_left f::read_arg_files init::args_list arg_files;
|
|
|
|
|
let all_args = List.map f::String.strip all_args_;
|
|
|
|
|
let rec check_for_existing_file_arg args =>
|
|
|
|
|
switch args {
|
|
|
|
|
| [] => ()
|
|
|
|
|
| [option, ...rest] =>
|
|
|
|
|
if (String.equal option "-c") {
|
|
|
|
|
/* infer-capture-all flavour of buck produces path to generated file that doesn't exist.
|
|
|
|
|
Create empty file empty file and pass that to clang. This is to enable compilation to continue */
|
|
|
|
|
switch (clang_ignore_regex, List.hd rest) {
|
|
|
|
|
| (Some regexp, Some arg) =>
|
|
|
|
|
if (Str.string_match regexp arg 0 && Sys.file_exists arg != `Yes) {
|
|
|
|
|
Unix.mkdir_p (Filename.dirname arg);
|
|
|
|
|
let file = Unix.openfile mode::[Unix.O_CREAT, Unix.O_RDONLY] arg;
|
|
|
|
|
Unix.close file
|
|
|
|
|
}
|
|
|
|
|
| _ => ()
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
check_for_existing_file_arg rest
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
check_for_existing_file_arg all_args
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Given a list of arguments for clang [args], return a list of new commands to run according to
|
|
|
|
|
the results of `clang -### [args]`. */
|
|
|
|
@ -100,6 +135,7 @@ let exe ::prog ::args => {
|
|
|
|
|
let xx_suffix = String.is_suffix suffix::"++" prog ? "++" : "";
|
|
|
|
|
/* use clang in facebook-clang-plugins */
|
|
|
|
|
let clang_xx = CFrontend_config.clang_bin xx_suffix;
|
|
|
|
|
check_for_existing_file args;
|
|
|
|
|
let commands = normalize prog::clang_xx ::args;
|
|
|
|
|
/* xcodebuild projects may require the object files to be generated by the Apple compiler, eg to
|
|
|
|
|
generate precompiled headers compatible with Apple's clang. */
|
|
|
|
|