Add paths to specs through file list

Summary: public
With this change, it will be possible to pass to InferAnalyze a list of folders to be
searched for spec files, through a file containing those paths, separated by the newline
character.
For example, if there's a `PathList.txt` file containing
  /path/to/specs/folder1
  /path/to/specs/folder2
  /path/to/specs/folder3
Then invoking `infer --specs-dir-list-file PathList.txt [--other_args, ...] -- <build_cmd>`
will instruct the analyzer to lookup to those three folders whenever it searches for specs.

It's important to note that since the analyzer runs in parallel from different locations, it's necessary to pass **absolute** paths, or the analyzer will fail with an error.

Reviewed By: jvillard

Differential Revision: D2668700

fb-gh-sync-id: b407a57
master
martinoluca 9 years ago committed by facebook-github-bot-7
parent 369de5880e
commit 64189548b0

@ -156,6 +156,11 @@ infer_group.add_argument('--specs-dir',
help='add dir to the list of directories to be '
'searched for spec files. Repeat the argument '
'in case multiple folders are needed')
infer_group.add_argument('--specs-dir-list-file',
metavar='<file>',
help='add the newline-separated directories listed '
'in <file> to the list of directories to be '
'searched for spec files')
def detect_javac(args):
for index, arg in enumerate(args):
@ -279,6 +284,14 @@ class Infer:
(['-lib', os.path.abspath(path)] for path in
self.args.specs_dirs)
for item in argument]
if self.args.specs_dir_list_file:
# Convert the path to the file list to an absolute path, because
# the analyzer will run from different paths and may not find the
# file otherwise.
self.args.specs_dir_list_file = \
['-specs-dir-list-file',
os.path.abspath(self.args.specs_dir_list_file)]
def clean_exit(self):
if os.path.isdir(self.args.infer_out):
@ -376,6 +389,9 @@ class Infer:
if self.args.specs_dirs:
infer_options += self.args.specs_dirs
if self.args.specs_dir_list_file:
infer_options += self.args.specs_dir_list_file
exit_status = os.EX_OK
if self.args.buck:

@ -622,6 +622,17 @@ type arg_list = (string * Arg.spec * string option * string) list
let arg_desc_filter options_to_keep =
IList.filter (function (option_name, _, _, _) -> IList.mem string_equal option_name options_to_keep)
(* Given a filename with a list of paths, convert it into a list of string iff they are absolute *)
let read_specs_dir_list_file fname =
let validate_path path =
if Filename.is_relative path then
failwith ("Failing because path " ^ path ^ " is not absolute") in
match read_file fname with
| Some pathlist ->
IList.iter validate_path pathlist;
pathlist
| None -> failwith ("cannot read file " ^ fname)
let base_arg_desc =
[
"-results_dir",
@ -636,6 +647,11 @@ let base_arg_desc =
Arg.String (fun s -> Config.specs_library := filename_to_absolute s :: !Config.specs_library),
Some "dir",
"add dir to the list of directories to be searched for spec files";
"-specs-dir-list-file",
Arg.String (fun s -> Config.specs_library := (read_specs_dir_list_file s) @ !Config.specs_library),
Some "file",
"add the newline-separated directories listed in <file> to the list of directories to \
be searched for spec files";
"-models",
Arg.String (fun s -> Config.add_models (filename_to_absolute s)),
Some "zip file",

Loading…
Cancel
Save