From e9654ca51d7f49dac04aae8bee1d8b07e1d95fdd Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Wed, 2 Nov 2016 16:52:36 -0700 Subject: [PATCH] [refactor] Separate InferPrint initialization code into separate Exe module Reviewed By: jvillard Differential Revision: D4114511 fbshipit-source-id: cdcf177 --- infer/src/Makefile | 4 ++-- infer/src/backend/InferPrint.re | 25 +++++-------------------- infer/src/backend/InferPrint.rei | 11 +++++++++++ infer/src/backend/InferPrintExe.re | 11 +++++++++++ infer/src/backend/InferPrintExe.rei | 9 +++++++++ infer/src/base/Config.ml | 2 +- 6 files changed, 39 insertions(+), 23 deletions(-) create mode 100644 infer/src/backend/InferPrint.rei create mode 100644 infer/src/backend/InferPrintExe.re create mode 100644 infer/src/backend/InferPrintExe.rei diff --git a/infer/src/Makefile b/infer/src/Makefile index e33aadf0f..80c007ff4 100644 --- a/infer/src/Makefile +++ b/infer/src/Makefile @@ -77,7 +77,7 @@ INFERPRINT_ATDGEN_STUB_BASE = backend/jsonbug INFERPRINT_ATDGEN_STUB_ATD = $(INFERPRINT_ATDGEN_STUB_BASE).atd INFERPRINT_ATDGEN_STUBS = $(addprefix $(INFERPRINT_ATDGEN_STUB_BASE), $(ATDGEN_SUFFIXES)) -INFERPRINT_MAIN = backend/InferPrint +INFERPRINT_MAIN = backend/InferPrintExe ### InferUnit declarations ### @@ -251,7 +251,7 @@ rei: %.rei : %.mli refmt -assume-explicit-arity -heuristics-file unary.txt -parse ml -print re $< > $*.rei -roots:=Infer InferAnalyze InferClang JMain InferPrint BuckCompilationDatabase +roots:=Infer InferAnalyze InferClang JMain InferPrintExe BuckCompilationDatabase clusters:=base clang java IR src_dirs:=$(shell find * -type d) diff --git a/infer/src/backend/InferPrint.re b/infer/src/backend/InferPrint.re index 4cd133eaa..6c5184822 100644 --- a/infer/src/backend/InferPrint.re +++ b/infer/src/backend/InferPrint.re @@ -740,19 +740,6 @@ let module IssuesXml = { let module CallsCsv = { - /** Print the header of the calls csv file, with column names */ - let pp_header fmt () => - Format.fprintf - fmt - "%s,%s,%s,%s,%s,%s,%s@\n" - Io_infer.Xml.tag_caller - Io_infer.Xml.tag_caller_id - Io_infer.Xml.tag_callee - Io_infer.Xml.tag_callee_id - Io_infer.Xml.tag_file - Io_infer.Xml.tag_line - Io_infer.Xml.tag_call_trace; - /** Write proc summary stats in csv format */ let pp_calls fmt summary => { let pp x => F.fprintf fmt x; @@ -1082,8 +1069,6 @@ type bug_format_kind = | Xml | Latex; -type bug_format = (bug_format_kind, outfile); - let pp_issues_in_format (format_kind, outf) => switch format_kind { | Json => IssuesJson.pp_issues_of_error_log outf.fmt @@ -1371,9 +1356,9 @@ let register_perf_stats_report () => { let mk_format format_kind fname => Option.map_default (fun out_file => [(format_kind, out_file)]) [] (create_outfile fname); -let init_issues_format_list () => { - let csv_format = Option.map_default (mk_format Csv) [] Config.bugs_csv; - let json_format = Option.map_default (mk_format Json) [] Config.bugs_json; +let init_issues_format_list report_csv report_json => { + let csv_format = Option.map_default (mk_format Csv) [] report_csv; + let json_format = Option.map_default (mk_format Json) [] report_json; let tests_format = Option.map_default (mk_format Tests) [] Config.bugs_tests; let txt_format = Option.map_default (mk_format Text) [] Config.bugs_txt; let xml_format = Option.map_default (mk_format Xml) [] Config.bugs_xml; @@ -1471,9 +1456,9 @@ let pp_summary_and_issues formats_by_report_kind => { finalize_and_close_files formats_by_report_kind stats pdflatex }; -let () = { +let main report_csv::report_csv report_json::report_json => { let formats_by_report_kind = [ - (Issues, init_issues_format_list ()), + (Issues, init_issues_format_list report_csv report_json), (Procs, init_procs_format_list ()), (Calls, init_calls_format_list ()), (Stats, init_stats_format_list ()), diff --git a/infer/src/backend/InferPrint.rei b/infer/src/backend/InferPrint.rei new file mode 100644 index 000000000..5e9ad87de --- /dev/null +++ b/infer/src/backend/InferPrint.rei @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2016 - 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. + */ +open! Utils; + +let main: report_csv::option string => report_json::option string => unit; diff --git a/infer/src/backend/InferPrintExe.re b/infer/src/backend/InferPrintExe.re new file mode 100644 index 000000000..47b9101b8 --- /dev/null +++ b/infer/src/backend/InferPrintExe.re @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2016 - 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. + */ +open! Utils; + +let () = InferPrint.main report_csv::Config.bugs_csv report_json::Config.bugs_json; diff --git a/infer/src/backend/InferPrintExe.rei b/infer/src/backend/InferPrintExe.rei new file mode 100644 index 000000000..e92b0aede --- /dev/null +++ b/infer/src/backend/InferPrintExe.rei @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2016 - 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. + */ +open! Utils; diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index d4ff34ac3..cc6a478c8 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -1081,7 +1081,7 @@ and progress_bar = "Show a progress bar" and quiet = - CLOpt.mk_bool ~long:"quiet" ~short:"q" + CLOpt.mk_bool ~long:"quiet" ~short:"q" ~default:(current_exe != CLOpt.Print) ~exes:CLOpt.[Print] "Do not print specs on standard output"