Add support for specifying the list of files to be analyzed in on-demand mode.

Reviewed By: jvillard

Differential Revision: D2604299

fb-gh-sync-id: 866ba5b
master
Cristiano Calcagno 9 years ago committed by facebook-github-bot-1
parent 00e97afdf8
commit 4300d1bf62

@ -21,12 +21,31 @@ let source_file_from_pname pname =
let source_file_to_pname fname =
Procname.from_string_c_fun (DB.source_file_to_string fname)
let pp_prolog fmt num_clusters =
let pp_prolog fmt clusters =
F.fprintf fmt "INFERANALYZE= %s $(INFER_OPTIONS) -results_dir '%s'\n@."
Sys.executable_name
(Escape.escape_map (fun c -> if c = '#' then Some "\\#" else None) !Config.results_dir);
F.fprintf fmt "OBJECTS=";
for i = 1 to num_clusters do F.fprintf fmt "%a " Cluster.pp_cl i done;
let filter cl = match cl with
[ce] ->
begin
match Cluster.get_ondemand_info ce with
| Some source_dir ->
let in_ondemand_config = match Ondemand.read_dirs_to_analyze () with
| None ->
true
| Some set ->
StringSet.mem (DB.source_dir_to_string source_dir) set in
in_ondemand_config
| None ->
true
end
| _ ->
true in
IList.iteri
(fun i cl ->
if filter cl then F.fprintf fmt "%a " Cluster.pp_cl (i+1))
clusters;
F.fprintf fmt "@.@.default: test@.@.all: test@.@.";
F.fprintf fmt "test: $(OBJECTS)@.\techo \"Analysis done\"@.@."
@ -74,7 +93,7 @@ let create_cluster_makefile_and_exit
!cluster_nr tot_clusters_nr cluster print_files fmt (IntSet.elements !dependent_clusters);
(* L.err "cluster %d has %d dependencies@."
!cluster_nr (IntSet.cardinal !dependent_clusters) *) in
pp_prolog fmt tot_clusters_nr;
pp_prolog fmt clusters;
IList.iter do_cluster clusters;
pp_epilog fmt ();
exit 0

@ -27,6 +27,12 @@ let from_env_variable var_name =
let _ = Sys.getenv var_name in true
with Not_found -> false
let get_env_variable var_name =
try
let v = Sys.getenv var_name in
if v = "" then None else Some v
with Not_found -> None
let attributes_dir_name = "attributes"
let captured_dir_name = "captured"
let sources_dir_name = "sources"

@ -17,6 +17,7 @@ let for_all2 = List.for_all2
let hd = List.hd
let iter = List.iter
let iter2 = List.iter2
let iteri = List.iteri
let length = List.length
let nth = List.nth
let partition = List.partition

@ -36,6 +36,7 @@ val for_all2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val hd : 'a list -> 'a
val iter : ('a -> unit) -> 'a list -> unit
val iter2 : ('a -> 'b -> unit) -> 'a list -> 'b list -> unit
val iteri : (int -> 'a -> unit) -> 'a list -> unit
val length : 'a list -> int
(** tail-recursive variant of List.fold_right *)

@ -22,6 +22,25 @@ let () = Config.ondemand_enabled :=
let across_files () = true
(** Name of the ondemand file *)
let ondemand_file () = Config.get_env_variable "INFER_ONDEMAND_FILE"
(** Read the directories to analyze from the ondemand file. *)
let read_dirs_to_analyze () =
let lines_opt = match ondemand_file () with
| None -> None
| Some fname -> Utils.read_file fname in
match lines_opt with
| None ->
None
| Some lines ->
let res = ref StringSet.empty in
let do_line line =
let source_dir = DB.source_dir_from_source_file (DB.source_file_from_string line) in
res := StringSet.add (DB.source_dir_to_string source_dir) !res in
IList.iter do_line lines;
Some !res
type analyze_ondemand = Procname.t -> unit
type get_proc_desc = Procname.t -> Cfg.Procdesc.t option

@ -9,6 +9,11 @@
(** Module for on-demand analysis. *)
open Utils
(** Optional set of source dirs to analyze in on-demand mode. *)
val read_dirs_to_analyze : unit -> StringSet.t option
type analyze_ondemand = Procname.t -> unit
type get_proc_desc = Procname.t -> Cfg.Procdesc.t option

Loading…
Cancel
Save