[infer][java] for the buck integration, remove the files that are invalidating the Buck cache

Summary:
Sevel auxiliary files made it to the output directory of the analysis of individual targets when analyzing Java projects build with Buck. However, these files are then taken into account= to compute the target rule key and then to decide whether to analyze the dependent targets. Since these auxiliary files were containing time sentive information, every cach miss on a given target would then invalitate the cache entries for all the dependent targets.

This diff cleans up the output directory to only keep the specs files, the `global.tenv` and the `report.json` files which are the only artifacts needed to analyze the dependent targets

This diff makes a minimal number of changes to see how it behaves in prod, but I intend to refoctor this more when continuing to add support for running Infer with genrules

Reviewed By: sblackshear

Differential Revision: D4562615

fbshipit-source-id: 4628420
master
Jeremy Dubreil 8 years ago committed by Facebook Github Bot
parent 19022144ad
commit 4ed185e557

@ -1401,6 +1401,8 @@ let main report_csv::report_csv report_json::report_json => {
(Stats, init_stats_format_list ()),
(Summary, init_summary_format_list ())
];
register_perf_stats_report ();
if (not Config.buck_cache_mode) {
register_perf_stats_report ()
};
print_issues formats_by_report_kind
};

@ -120,8 +120,9 @@ let create_results_dir () =
Unix.mkdir_p (Config.results_dir ^/ Config.specs_dir_name)
let clean_results_dir () =
let dirs = ["classnames"; "filelists"; "multicore"; "sources"] in
let suffixes = [".cfg"; ".cg"] in
let dirs = ["classnames"; "filelists"; "multicore"; "sources"; "log";
"attributes"; "backend_stats"; "reporting_stats"; "frontend_stats"] in
let suffixes = [".cfg"; ".cg"; ".txt"; ".csv"; ".json"] in
let rec clean name =
match Unix.opendir name with
| dir -> (
@ -139,8 +140,13 @@ let clean_results_dir () =
Unix.closedir dir in
cleandir dir
)
| exception Unix.Unix_error (Unix.ENOTDIR, _, _)
when String.equal (Filename.basename name) "report.json" ->
(* Keep the JSON report *)
()
| exception Unix.Unix_error (Unix.ENOTDIR, _, _) ->
if List.exists ~f:(Filename.check_suffix name) suffixes then
if not (String.equal (Filename.basename name) "report.json")
&& List.exists ~f:(Filename.check_suffix name) suffixes then
Unix.unlink name
| exception Unix.Unix_error (Unix.ENOENT, _, _) ->
() in
@ -395,7 +401,7 @@ let () =
remove_results_dir () ;
create_results_dir () ;
(* re-set log files, as default files were in results_dir removed above *)
L.set_log_file_identifier CLOpt.(Infer Driver) None ;
if not Config.buck_cache_mode then L.set_log_file_identifier CLOpt.(Infer Driver) None;
if Config.print_builtins then Builtin.print_and_exit () ;
if CLOpt.is_originator then L.do_out "%s@\n" Config.version_string ;
if Config.debug_mode || Config.stats_mode then log_infer_args driver_mode ;
@ -404,17 +410,19 @@ let () =
anyway, pretend that we are not called from another make to prevent make falling back to a
mono-threaded execution. *)
Unix.unsetenv "MAKEFLAGS";
register_perf_stats_report () ;
touch_start_file () ;
if not Config.buck_cache_mode then register_perf_stats_report () ;
if Config.buck_cache_mode && Config.reactive_mode then
failwith "The reactive analysis mode is not compatible with the Buck integration for Java";
if not Config.buck_cache_mode then touch_start_file () ;
capture driver_mode ;
analyze driver_mode ;
if CLOpt.is_originator then (
StatsAggregator.generate_files () ;
let in_buck_mode = match driver_mode with | PythonCapture (BBuck, _) -> true | _ -> false in
StatsAggregator.generate_files () ;
if Config.equal_analyzer Config.analyzer Config.Crashcontext then
Crashcontext.crashcontext_epilogue ~in_buck_mode;
if in_buck_mode then
clean_results_dir () ;
if Config.fail_on_bug then
fail_on_issue_epilogue () ;
)
);
if Config.buck_cache_mode then
clean_results_dir ()

@ -1466,6 +1466,7 @@ and bootclasspath = !bootclasspath
and bo_debug = !bo_debug
and buck = !buck
and buck_build_args = !buck_build_args
and buck_cache_mode = !buck && not !debug
and buck_out = !buck_out
and bufferoverrun = !bufferoverrun
and bugs_csv = !bugs_csv

@ -156,6 +156,7 @@ val bootclasspath : string option
val bo_debug : int
val buck : bool
val buck_build_args : string list
val buck_cache_mode : bool
val buck_out : string option
val bufferoverrun : bool
val bugs_csv : string option

@ -26,7 +26,7 @@ let register_perf_stats_report source_file =
let init_global_state source_file =
register_perf_stats_report source_file ;
if not Config.buck_cache_mode then register_perf_stats_report source_file ;
Config.curr_language := Config.Java;
DB.Results_dir.init source_file;
Ident.NameGenerator.reset ();

@ -1,3 +1,12 @@
/*
* Copyright (c) 2017 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package genrule.module1;
import genrule.annotations.Nullable;

@ -1,3 +1,12 @@
/*
* Copyright (c) 2017 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package genrule.module2;
import genrule.module1.Class1;

Loading…
Cancel
Save