[buck] one buck mode datatype to rule them all

Summary:
This changes how we select amongst our (currently) 4 Buck integrations
for Java and clang, as well as how the user's choice is reflected by the
Config module.

The old command line interface is still supported but is now deprecated.
The changes in how to select each integration are:
- clang via "flavors", activated with `--flavors`, now with `--buck-clang`
- clang via "compilation DB", activated with `--buck-compilation-database`, unchanged
- Java via "genrule", activated with `--genrule-master-mode`, now with `--buck-java`
- Java "without genrules", used to be activated by *not specifying any other Buck mode*, unchanged

Instead of various `Config` flags corresponding to the previous CLI that
are allowed in any combination of `flavors`,
`buck_compilation_database`, `genrule_master_mode`, `Config` now exposes
a single `buck_mode` datatype. This allows, eg, `flavors` to override
`buck_compilation_database` if needed. It will also make it easier to
get rid of the old "Java without genrules" integration in a later diff
(see inline comments).

Reviewed By: ngorogiannis

Differential Revision: D19175686

fbshipit-source-id: 29b3831be
master
Jules Villard 5 years ago committed by Facebook Github Bot
parent b49f39b80e
commit e4dd2bbd8c

@ -27,7 +27,7 @@ MODULE_DESCRIPTION = '''Run analysis of code built with a command like:
buck [options] [target]
Analysis examples:
infer -- buck build HelloWorld'''
infer --buck-clang -- buck build HelloWorld'''
LANG = ['clang', 'java']
KEEP_GOING_OPTION = "--keep-going"

@ -349,10 +349,10 @@ BIABDUCTION CHECKER OPTIONS
--biabduction-fallback-model-free-pattern string
Regex of methods that should be modelled as free if definition is
missing
BUCK FLAVORS OPTIONS
BUCK OPTIONS
--merge
Activates: Merge the captured results directories specified in the
dependency file (Conversely: --no-merge)
dependency file. (Conversely: --no-merge)
BUFFER OVERRUN OPTIONS
--bo-debug int
Debug level for buffer-overrun checker (0-4)

@ -2,8 +2,8 @@ NAME
infer-capture - capture source files for later analysis
SYNOPSIS
infer capture [options] -- buck ...
infer capture --flavors [options] -- buck ...
infer capture --buck-java [options] -- buck ...
infer capture --buck-clang [options] -- buck ...
infer capture --buck-compilation-database [no-]deps [options] -- buck ...
infer capture [options] --compilation-database file
infer capture [options] --compilation-database-escaped file
@ -107,51 +107,59 @@ OPTIONS
-- Stop argument processing, use remaining arguments as a build
command
BUCK COMPILATION DATABASE OPTIONS
BUCK OPTIONS
--append-buck-flavors +string
Additional Buck flavors to append to targets discovered by the
--buck-compilation-database option.
--buck-blacklist +regex
Skip capture of files matched by the specified regular expression.
Only the clang, non-compilation-database Buck integration is supported, not Java.
--buck-clang
Activates: Buck integration for clang-based targets
(C/C++/Objective-C/Objective-C++). (Conversely: --no-buck-clang)
--buck-compilation-database { no-deps | deps }
Buck integration using the compilation database, with or without
dependencies.
dependencies. Only includes clang targets, as per Buck's
#compilation-database flavor.
--buck-compilation-database-depth int
Depth of dependencies used by the --buck-compilation-database deps
option. By default, all recursive dependencies are captured.
--buck-targets-blacklist +regex
Skip capture of buck targets matched by the specified regular
expression.
BUCK FLAVORS OPTIONS
--append-buck-flavors +string
Additional Buck flavors to append to targets discovered by the
--buck-compilation-database option.
--buck-blacklist +regex
Skip capture of files matched by the specified regular expression
(only the "flavors (C++)" Buck integration is supported, not
Java).
--buck-java
Activates: Make the master Infer process merge capture artefacts
generated by the genrule integration, and report after analysis.
(Conversely: --no-buck-java)
--buck-merge-all-deps
Activates: Find and merge all infer dependencies produced by buck.
Use this flag if infer doesn't find any files to analyze after a
successful capture. (Conversely: --no-buck-merge-all-deps)
successful capture. Only valid for --buck-clang. (Conversely:
--no-buck-merge-all-deps)
--flavors
Activates: Buck integration using the infer-capture-all Buck
flavor (clang only). Use for clang-based Buck projects (as opposed
to Java). (Conversely: --no-flavors)
--buck-out dir
Specify the root directory of buck-out. Only valid for
--buck-java.
--buck-targets-blacklist +regex
Skip capture of buck targets matched by the specified regular
expression. Only valid for --buck-compilation-database.
--Xbuck +string
Pass values as command-line arguments to invocations of `buck
build`
build`. Only valid for --buck-clang.
--Xbuck-no-inline +string
Pass values as command-line arguments to invocations of `buck
build`, don't inline any args starting with '@'
build`, don't inline any args starting with '@'. Only valid for
--buck-clang.
--xcode-developer-dir XCODE_DEVELOPER_DIR
Specify the path to Xcode developer directory
BUCK FOR JAVA OPTIONS
--buck-out dir
Specify the root directory of buck-out
Specify the path to Xcode developer directory, to use for Buck
clang targets
CLANG LINTERS OPTIONS
--debug-level-linters int
Debug level for the linters. See --debug-level for accepted

@ -133,31 +133,44 @@ OPTIONS
Specify the Java bootclasspath See also infer-capture(1).
--buck-blacklist +regex
Skip capture of files matched by the specified regular expression
(only the "flavors (C++)" Buck integration is supported, not
Java). See also infer-capture(1) and infer-run(1).
Skip capture of files matched by the specified regular expression.
Only the clang, non-compilation-database Buck integration is supported, not Java.
See also infer-capture(1) and infer-run(1).
--buck-clang
Activates: Buck integration for clang-based targets
(C/C++/Objective-C/Objective-C++). (Conversely: --no-buck-clang)
See also infer-capture(1).
--buck-compilation-database { no-deps | deps }
Buck integration using the compilation database, with or without
dependencies. See also infer-capture(1).
dependencies. Only includes clang targets, as per Buck's
#compilation-database flavor. See also infer-capture(1).
--buck-compilation-database-depth int
Depth of dependencies used by the --buck-compilation-database deps
option. By default, all recursive dependencies are captured.
See also infer-capture(1).
--buck-java
Activates: Make the master Infer process merge capture artefacts
generated by the genrule integration, and report after analysis.
(Conversely: --no-buck-java) See also infer-capture(1).
--buck-merge-all-deps
Activates: Find and merge all infer dependencies produced by buck.
Use this flag if infer doesn't find any files to analyze after a
successful capture. (Conversely: --no-buck-merge-all-deps)
See also infer-capture(1).
successful capture. Only valid for --buck-clang. (Conversely:
--no-buck-merge-all-deps) See also infer-capture(1).
--buck-out dir
Specify the root directory of buck-out See also infer-capture(1).
Specify the root directory of buck-out. Only valid for
--buck-java. See also infer-capture(1).
--buck-targets-blacklist +regex
Skip capture of buck targets matched by the specified regular
expression. See also infer-capture(1) and infer-run(1).
expression. Only valid for --buck-compilation-database.
See also infer-capture(1) and infer-run(1).
--bufferoverrun
Activates: the buffer overrun analysis (Conversely:
@ -545,11 +558,6 @@ OPTIONS
Deactivates: Do not show the experimental and blacklisted issue
types (Conversely: --filtering | -f) See also infer-report(1).
--flavors
Activates: Buck integration using the infer-capture-all Buck
flavor (clang only). Use for clang-based Buck projects (as opposed
to Java). (Conversely: --no-flavors) See also infer-capture(1).
--force-delete-results-dir
Activates: Do not refuse to delete the results directory if it
doesn't look like an infer results directory. (Conversely:
@ -776,7 +784,7 @@ OPTIONS
--merge
Activates: Merge the captured results directories specified in the
dependency file (Conversely: --no-merge) See also infer-analyze(1).
dependency file. (Conversely: --no-merge) See also infer-analyze(1).
--ml-buckets ,-separated sequence of { all | cf | arc | narc | cpp |
unknown_origin }
@ -1111,18 +1119,20 @@ OPTIONS
--Xbuck +string
Pass values as command-line arguments to invocations of `buck
build` See also infer-capture(1).
build`. Only valid for --buck-clang. See also infer-capture(1).
--Xbuck-no-inline +string
Pass values as command-line arguments to invocations of `buck
build`, don't inline any args starting with '@' See also infer-capture(1).
build`, don't inline any args starting with '@'. Only valid for
--buck-clang. See also infer-capture(1).
--Xclang +string
Pass values as command-line arguments to invocations of clang
See also infer-capture(1).
--xcode-developer-dir XCODE_DEVELOPER_DIR
Specify the path to Xcode developer directory See also infer-capture(1).
Specify the path to Xcode developer directory, to use for Buck
clang targets See also infer-capture(1).
--xcpretty
Activates: Infer will use xcpretty together with xcodebuild to
@ -1196,6 +1206,11 @@ INTERNAL OPTIONS
--buck-compilation-database-reset
Cancel the effect of --buck-compilation-database.
--buck-java-deprecated
Activates: [DO NOT USE] old Buck Java integration. Used to be the
default. Going away imminently (Conversely:
--no-buck-java-deprecated)
--buck-out-reset
Cancel the effect of --buck-out.
@ -1405,11 +1420,6 @@ INTERNAL OPTIONS
--generated-classes-reset
Cancel the effect of --generated-classes.
--genrule-master-mode
Activates: Make the master Infer process merge capture artefacts
generated by the genrule integration, and report after analysis.
(Conversely: --no-genrule-master-mode)
--genrule-mode
Activates: Enable the genrule compatibility mode used for the Buck
integration (Conversely: --no-genrule-mode)

@ -170,15 +170,14 @@ OPTIONS
-- Stop argument processing, use remaining arguments as a build
command
BUCK COMPILATION DATABASE OPTIONS
BUCK OPTIONS
--buck-blacklist +regex
Skip capture of files matched by the specified regular expression.
Only the clang, non-compilation-database Buck integration is supported, not Java.
--buck-targets-blacklist +regex
Skip capture of buck targets matched by the specified regular
expression.
BUCK FLAVORS OPTIONS
--buck-blacklist +regex
Skip capture of files matched by the specified regular expression
(only the "flavors (C++)" Buck integration is supported, not
Java).
expression. Only valid for --buck-compilation-database.
CLANG OPTIONS
--compute-analytics
Activates: Emit analytics as info-level issues, like component kit

@ -133,31 +133,44 @@ OPTIONS
Specify the Java bootclasspath See also infer-capture(1).
--buck-blacklist +regex
Skip capture of files matched by the specified regular expression
(only the "flavors (C++)" Buck integration is supported, not
Java). See also infer-capture(1) and infer-run(1).
Skip capture of files matched by the specified regular expression.
Only the clang, non-compilation-database Buck integration is supported, not Java.
See also infer-capture(1) and infer-run(1).
--buck-clang
Activates: Buck integration for clang-based targets
(C/C++/Objective-C/Objective-C++). (Conversely: --no-buck-clang)
See also infer-capture(1).
--buck-compilation-database { no-deps | deps }
Buck integration using the compilation database, with or without
dependencies. See also infer-capture(1).
dependencies. Only includes clang targets, as per Buck's
#compilation-database flavor. See also infer-capture(1).
--buck-compilation-database-depth int
Depth of dependencies used by the --buck-compilation-database deps
option. By default, all recursive dependencies are captured.
See also infer-capture(1).
--buck-java
Activates: Make the master Infer process merge capture artefacts
generated by the genrule integration, and report after analysis.
(Conversely: --no-buck-java) See also infer-capture(1).
--buck-merge-all-deps
Activates: Find and merge all infer dependencies produced by buck.
Use this flag if infer doesn't find any files to analyze after a
successful capture. (Conversely: --no-buck-merge-all-deps)
See also infer-capture(1).
successful capture. Only valid for --buck-clang. (Conversely:
--no-buck-merge-all-deps) See also infer-capture(1).
--buck-out dir
Specify the root directory of buck-out See also infer-capture(1).
Specify the root directory of buck-out. Only valid for
--buck-java. See also infer-capture(1).
--buck-targets-blacklist +regex
Skip capture of buck targets matched by the specified regular
expression. See also infer-capture(1) and infer-run(1).
expression. Only valid for --buck-compilation-database.
See also infer-capture(1) and infer-run(1).
--bufferoverrun
Activates: the buffer overrun analysis (Conversely:
@ -545,11 +558,6 @@ OPTIONS
Deactivates: Do not show the experimental and blacklisted issue
types (Conversely: --filtering | -f) See also infer-report(1).
--flavors
Activates: Buck integration using the infer-capture-all Buck
flavor (clang only). Use for clang-based Buck projects (as opposed
to Java). (Conversely: --no-flavors) See also infer-capture(1).
--force-delete-results-dir
Activates: Do not refuse to delete the results directory if it
doesn't look like an infer results directory. (Conversely:
@ -776,7 +784,7 @@ OPTIONS
--merge
Activates: Merge the captured results directories specified in the
dependency file (Conversely: --no-merge) See also infer-analyze(1).
dependency file. (Conversely: --no-merge) See also infer-analyze(1).
--ml-buckets ,-separated sequence of { all | cf | arc | narc | cpp |
unknown_origin }
@ -1111,18 +1119,20 @@ OPTIONS
--Xbuck +string
Pass values as command-line arguments to invocations of `buck
build` See also infer-capture(1).
build`. Only valid for --buck-clang. See also infer-capture(1).
--Xbuck-no-inline +string
Pass values as command-line arguments to invocations of `buck
build`, don't inline any args starting with '@' See also infer-capture(1).
build`, don't inline any args starting with '@'. Only valid for
--buck-clang. See also infer-capture(1).
--Xclang +string
Pass values as command-line arguments to invocations of clang
See also infer-capture(1).
--xcode-developer-dir XCODE_DEVELOPER_DIR
Specify the path to Xcode developer directory See also infer-capture(1).
Specify the path to Xcode developer directory, to use for Buck
clang targets See also infer-capture(1).
--xcpretty
Activates: Infer will use xcpretty together with xcodebuild to

@ -0,0 +1,43 @@
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
module F = Format
(** dependencies to include in the compilation database *)
type clang_compilation_db_deps = NoDependencies | DepsUpToDepth of int | DepsAllDepths
let pp_clang_compilation_db_deps fmt = function
| NoDependencies ->
F.pp_print_string fmt "NoDependencies"
| DepsUpToDepth depth ->
F.fprintf fmt "DepsUpToDepth %d" depth
| DepsAllDepths ->
F.pp_print_string fmt "DepsAllDepths"
type t = ClangFlavors | ClangCompilationDB of clang_compilation_db_deps | JavaGenruleMaster
let is_java_genrule_master = function
| JavaGenruleMaster ->
true
| ClangFlavors | ClangCompilationDB _ ->
false
let is_clang_compilation_db = function
| ClangCompilationDB _ ->
true
| ClangFlavors | JavaGenruleMaster ->
false
let is_clang_flavors = function
| ClangFlavors ->
true
| ClangCompilationDB _ | JavaGenruleMaster ->
false

@ -0,0 +1,22 @@
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
module F = Format
(** dependencies to include in the compilation database *)
type clang_compilation_db_deps = NoDependencies | DepsUpToDepth of int | DepsAllDepths
val pp_clang_compilation_db_deps : F.formatter -> clang_compilation_db_deps -> unit
type t = ClangFlavors | ClangCompilationDB of clang_compilation_db_deps | JavaGenruleMaster
val is_java_genrule_master : t -> bool
val is_clang_compilation_db : t -> bool
val is_clang_flavors : t -> bool

@ -58,8 +58,8 @@ let capture =
mk_command_doc ~title:"Infer Compilation Capture"
~short_description:"capture source files for later analysis"
~synopsis:
{|$(b,infer) $(b,capture) $(i,[options]) $(b,--) $(b,buck) $(i,...)
$(b,infer) $(b,capture) $(b,--flavors) $(i,[options]) $(b,--) $(b,buck) $(i,...)
{|$(b,infer) $(b,capture) $(b,--buck-java) $(i,[options]) $(b,--) $(b,buck) $(i,...)
$(b,infer) $(b,capture) $(b,--buck-clang) $(i,[options]) $(b,--) $(b,buck) $(i,...)
$(b,infer) $(b,capture) $(b,--buck-compilation-database) $(i,[no-]deps) $(i,[options]) $(b,--) $(b,buck) $(i,...)
$(b,infer) $(b,capture) $(i,[options]) $(b,--compilation-database) $(i,file)
$(b,infer) $(b,capture) $(i,[options]) $(b,--compilation-database-escaped) $(i,file)

@ -79,13 +79,6 @@ let issues_fields_symbols =
type os_type = Unix | Win32 | Cygwin
type compilation_database_dependencies =
| Deps of int option
(* get the compilation database of the dependencies up to depth n
by [Deps (Some n)], or all by [Deps None] *)
| NoDeps
[@@deriving compare]
type build_system =
| BAnt
| BBuck
@ -213,11 +206,7 @@ let lint_issues_dir_name = "lint_issues"
let manual_biabduction = "BIABDUCTION CHECKER OPTIONS"
let manual_buck_compilation_db = "BUCK COMPILATION DATABASE OPTIONS"
let manual_buck_flavors = "BUCK FLAVORS OPTIONS"
let manual_buck_java = "BUCK FOR JAVA OPTIONS"
let manual_buck = "BUCK OPTIONS"
let manual_buffer_overrun = "BUFFER OVERRUN OPTIONS"
@ -825,7 +814,7 @@ Example format: for custom annotations com.my.annotation.{Source1,Source2,Sink1}
and append_buck_flavors =
CLOpt.mk_string_list ~long:"append-buck-flavors"
~in_help:InferCommand.[(Capture, manual_buck_flavors)]
~in_help:InferCommand.[(Capture, manual_buck)]
"Additional Buck flavors to append to targets discovered by the \
$(b,--buck-compilation-database) option."
@ -864,57 +853,91 @@ and buck_blacklist =
CLOpt.mk_string_list
~deprecated:["-blacklist-regex"; "-blacklist"]
~long:"buck-blacklist"
~in_help:InferCommand.[(Run, manual_buck_flavors); (Capture, manual_buck_flavors)]
~in_help:InferCommand.[(Run, manual_buck); (Capture, manual_buck)]
~meta:"regex"
"Skip capture of files matched by the specified regular expression (only the \"flavors (C++)\" \
Buck integration is supported, not Java)."
"Skip capture of files matched by the specified regular expression. Only the clang, \
non-compilation-database\n\
\ Buck integration is supported, not Java."
and buck_build_args =
CLOpt.mk_string_list ~long:"Xbuck"
~in_help:InferCommand.[(Capture, manual_buck_flavors)]
"Pass values as command-line arguments to invocations of $(i,`buck build`)"
~in_help:InferCommand.[(Capture, manual_buck)]
"Pass values as command-line arguments to invocations of $(i,`buck build`). Only valid for \
$(b,--buck-clang)."
and buck_build_args_no_inline =
CLOpt.mk_string_list ~long:"Xbuck-no-inline"
~in_help:InferCommand.[(Capture, manual_buck_flavors)]
~in_help:InferCommand.[(Capture, manual_buck)]
"Pass values as command-line arguments to invocations of $(i,`buck build`), don't inline any \
args starting with '@'"
args starting with '@'. Only valid for $(b,--buck-clang)."
and buck_compilation_database_depth =
CLOpt.mk_int_opt ~long:"buck-compilation-database-depth"
~in_help:InferCommand.[(Capture, manual_buck_compilation_db)]
~in_help:InferCommand.[(Capture, manual_buck)]
"Depth of dependencies used by the $(b,--buck-compilation-database deps) option. By default, \
all recursive dependencies are captured."
~meta:"int"
and buck_compilation_database =
CLOpt.mk_symbol_opt ~long:"buck-compilation-database" ~deprecated:["-use-compilation-database"]
~in_help:InferCommand.[(Capture, manual_buck_compilation_db)]
"Buck integration using the compilation database, with or without dependencies."
~symbols:[("no-deps", `NoDeps); ("deps", `DepsTmp)]
and buck_merge_all_deps =
CLOpt.mk_bool ~long:"buck-merge-all-deps" ~default:false
~in_help:InferCommand.[(Capture, manual_buck_flavors)]
~in_help:InferCommand.[(Capture, manual_buck)]
"Find and merge all infer dependencies produced by buck. Use this flag if infer doesn't find \
any files to analyze after a successful capture."
any files to analyze after a successful capture. Only valid for $(b,--buck-clang)."
and buck_mode =
let buck_mode = ref `None in
let set_mode mode b =
if b then buck_mode := mode
else (* TODO: change to [`None] when we kill [`JavaDeprecated] *) buck_mode := `JavaDeprecated ;
b
in
CLOpt.mk_bool ~deprecated:["-flavors"; "-use-flavors"] ~long:"buck-clang"
~deprecated_no:["-no-flavors"]
~in_help:InferCommand.[(Capture, manual_buck)]
~f:(set_mode `ClangFlavors)
"Buck integration for clang-based targets (C/C++/Objective-C/Objective-C++)."
|> ignore ;
CLOpt.mk_bool ~long:"buck-java" ~deprecated:["-genrule-master-mode"]
~deprecated_no:["-no-genrule-master-mode"]
~in_help:InferCommand.[(Capture, manual_buck)]
~f:(set_mode `Java)
"Make the master Infer process merge capture artefacts generated by the genrule integration, \
and report after analysis."
|> ignore ;
CLOpt.mk_symbol_opt ~long:"buck-compilation-database" ~deprecated:["-use-compilation-database"]
~in_help:InferCommand.[(Capture, manual_buck)]
~f:(fun s ->
buck_mode := `ClangCompilationDB s ;
s )
"Buck integration using the compilation database, with or without dependencies. Only includes \
clang targets, as per Buck's $(i,#compilation-database) flavor."
~symbols:[("no-deps", `NoDeps); ("deps", `DepsTmp)]
|> ignore ;
(* TOOD: kill this *)
CLOpt.mk_bool ~long:"buck-java-deprecated"
~f:(set_mode `JavaDeprecated)
"[DO NOT USE] old Buck Java integration. Used to be the default. Going away imminently"
|> ignore ;
buck_mode
and buck_out =
CLOpt.mk_path_opt ~long:"buck-out"
~in_help:InferCommand.[(Capture, manual_buck_java)]
~meta:"dir" "Specify the root directory of buck-out"
~in_help:InferCommand.[(Capture, manual_buck)]
~meta:"dir" "Specify the root directory of buck-out. Only valid for $(b,--buck-java)."
and buck_targets_blacklist =
CLOpt.mk_string_list ~long:"buck-targets-blacklist"
~in_help:InferCommand.[(Run, manual_buck_compilation_db); (Capture, manual_buck_compilation_db)]
~meta:"regex" "Skip capture of buck targets matched by the specified regular expression."
~in_help:InferCommand.[(Run, manual_buck); (Capture, manual_buck)]
~meta:"regex"
"Skip capture of buck targets matched by the specified regular expression. Only valid for \
$(b,--buck-compilation-database)."
and call_graph_schedule =
@ -1409,13 +1432,6 @@ and filter_paths =
CLOpt.mk_bool ~long:"filter-paths" ~default:true "Filters specified in .inferconfig"
and flavors =
CLOpt.mk_bool ~deprecated:["-use-flavors"] ~long:"flavors"
~in_help:InferCommand.[(Capture, manual_buck_flavors)]
"Buck integration using the infer-capture-all Buck flavor (clang only). Use for clang-based \
Buck projects (as opposed to Java)."
and force_delete_results_dir =
CLOpt.mk_bool ~long:"force-delete-results-dir" ~default:false
~in_help:
@ -1458,12 +1474,6 @@ and generated_classes =
"Specify where to load the generated class files"
and genrule_master_mode =
CLOpt.mk_bool ~default:false ~long:"genrule-master-mode"
"Make the master Infer process merge capture artefacts generated by the genrule integration, \
and report after analysis."
and genrule_mode =
CLOpt.mk_bool ~default:false ~long:"genrule-mode"
"Enable the genrule compatibility mode used for the Buck integration"
@ -1700,8 +1710,8 @@ and method_decls_info =
and merge =
CLOpt.mk_bool ~deprecated:["merge"] ~long:"merge"
~in_help:InferCommand.[(Analyze, manual_buck_flavors)]
"Merge the captured results directories specified in the dependency file"
~in_help:InferCommand.[(Analyze, manual_buck)]
"Merge the captured results directories specified in the dependency file."
and ml_buckets =
@ -2461,8 +2471,9 @@ and worklist_mode =
and xcode_developer_dir =
CLOpt.mk_path_opt ~long:"xcode-developer-dir"
~in_help:InferCommand.[(Capture, manual_buck_flavors)]
~meta:"XCODE_DEVELOPER_DIR" "Specify the path to Xcode developer directory"
~in_help:InferCommand.[(Capture, manual_buck)]
~meta:"XCODE_DEVELOPER_DIR"
"Specify the path to Xcode developer directory, to use for Buck clang targets"
and xcpretty =
@ -2751,18 +2762,26 @@ and buck_build_args_no_inline = !buck_build_args_no_inline
and buck_cache_mode = (!buck || !genrule_mode) && not !debug
and buck_compilation_database =
match !buck_compilation_database with
| Some `DepsTmp ->
Some (Deps !buck_compilation_database_depth)
| Some `NoDeps ->
Some NoDeps
| None ->
and buck_merge_all_deps = !buck_merge_all_deps
and buck_mode : BuckMode.t option =
match (!buck_mode, !buck_compilation_database_depth) with
| `None, _ ->
None
| `ClangFlavors, _ ->
Some ClangFlavors
| `Java, _ ->
Some JavaGenruleMaster
| `ClangCompilationDB `NoDeps, _ ->
Some (ClangCompilationDB NoDependencies)
| `ClangCompilationDB `DepsTmp, None ->
Some (ClangCompilationDB DepsAllDepths)
| `ClangCompilationDB `DepsTmp, Some depth ->
Some (ClangCompilationDB (DepsUpToDepth depth))
| `JavaDeprecated, _ ->
None
and buck_merge_all_deps = !buck_merge_all_deps
and buck_out = !buck_out
and buck_targets_blacklist = !buck_targets_blacklist
@ -2884,8 +2903,6 @@ and filter_paths = !filter_paths
and filtering = !filtering
and flavors = !flavors
and force_delete_results_dir = !force_delete_results_dir
and fragment_retains_view = !fragment_retains_view
@ -2902,8 +2919,6 @@ and frontend_tests = !frontend_tests
and generated_classes = !generated_classes
and genrule_master_mode = !genrule_master_mode
and genrule_mode = !genrule_mode
and get_linter_doc_url = process_linters_doc_url !linters_doc_url

@ -13,12 +13,6 @@ open! IStd
type os_type = Unix | Win32 | Cygwin
type compilation_database_dependencies =
| Deps of int option
(** get the compilation database of the dependencies up to depth n by [Deps (Some n)], or all
by [Deps None] *)
| NoDeps
type build_system =
| BAnt
| BBuck
@ -243,10 +237,10 @@ val buck_build_args_no_inline : string list
val buck_cache_mode : bool
val buck_compilation_database : compilation_database_dependencies option
val buck_merge_all_deps : bool
val buck_mode : BuckMode.t option
val buck_out : string option
val buck_targets_blacklist : string list
@ -356,8 +350,6 @@ val filter_paths : bool
val filtering : bool
val flavors : bool
val force_delete_results_dir : bool
val force_integration : build_system option
@ -374,8 +366,6 @@ val function_pointer_specialization : bool
val generated_classes : string option
val genrule_master_mode : bool
val genrule_mode : bool
val get_linter_doc_url : linter_id:string -> string option

@ -201,7 +201,7 @@ let capture clang_cmd =
(* this command compiles some code; replace the invocation of clang with our own clang and
plugin *)
cc1_capture clang_cmd
else if Option.is_some Config.buck_compilation_database then
else if Option.exists Config.buck_mode ~f:BuckMode.is_clang_compilation_db then
(* when running with buck's compilation-database, skip commands where frontend cannot be
attached, as they may cause unnecessary compilation errors *)
()

@ -163,7 +163,8 @@ let clang_cc1_cmd_sanitizer cmd =
(* compilation-database Buck integration produces path to `dep.tmp` file that doesn't exist. Create it *)
Unix.mkdir_p (Filename.dirname arg) ;
arg
| "-dependency-file" :: _, _ when Option.is_some Config.buck_compilation_database ->
| "-dependency-file" :: _, _
when Option.exists Config.buck_mode ~f:BuckMode.is_clang_compilation_db ->
(* In compilation database mode, dependency files are not assumed to exist *)
"/dev/null"
| "-idirafter" :: _, arg ->

@ -21,7 +21,8 @@ type action_item =
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 then
match (Config.buck_mode, clang_ignore_regex) with
| Some (ClangCompilationDB _), Some clang_ignore_regex ->
let arg_files, args_list = List.partition_tf ~f:(String.is_prefix ~prefix:"@") args in
let read_arg_files args_list arg_file_at =
let file = String.slice arg_file_at 1 (String.length arg_file_at) in
@ -38,17 +39,19 @@ let check_for_existing_file args =
if String.equal option "-c" then
(* 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 *)
match (clang_ignore_regex, List.hd rest) with
| Some regexp, Some arg ->
if Str.string_match regexp arg 0 && Sys.file_exists arg <> `Yes then (
match List.hd rest with
| Some arg ->
if Str.string_match clang_ignore_regex arg 0 && Sys.file_exists arg <> `Yes then (
Unix.mkdir_p (Filename.dirname arg) ;
let file = Unix.openfile ~mode:[Unix.O_CREAT; Unix.O_RDONLY] arg in
Unix.close file )
| _ ->
| None ->
()
else check_for_existing_file_arg rest
in
check_for_existing_file_arg all_args
| _ ->
()
(** Given a clang command, return a list of new commands to run according to the results of `clang
@ -149,8 +152,8 @@ let exec_action_item ~prog ~args = function
Capture.capture clang_cmd
| DriverCommand clang_cmd ->
if
Option.is_none Config.buck_compilation_database
|| Config.skip_analysis_in_path_skips_compilation
Config.skip_analysis_in_path_skips_compilation
|| Option.exists Config.buck_mode ~f:BuckMode.is_clang_compilation_db
then Capture.run_clang clang_cmd Utils.echo_in
else
L.debug Capture Quiet "Skipping seemingly uninteresting clang driver command %s@\n"

@ -45,7 +45,7 @@ let setup () =
(* In Buck mode, delete infer-out directories inside buck-out to start fresh and to
avoid getting errors because some of their contents is missing (removed by
[Driver.clean_results_dir ()]). *)
(buck && flavors) || genrule_mode)
(buck && Option.exists buck_mode ~f:BuckMode.is_clang_flavors) || genrule_mode)
|| not
( Driver.is_analyze_mode driver_mode
|| Config.(

@ -32,14 +32,14 @@ module Target = struct
else {target with flavors= flavor :: target.flavors}
let add_flavor ~extra_flavors target =
let add_flavor (mode : BuckMode.t) (command : InferCommand.t) ~extra_flavors target =
let target = List.fold_left ~f:add_flavor_internal ~init:target extra_flavors in
match (Config.buck_compilation_database, Config.command) with
| Some _, _ ->
match (mode, command) with
| ClangCompilationDB _, _ ->
add_flavor_internal target "compilation-database"
| None, Compile ->
| ClangFlavors, Compile | JavaGenruleMaster, _ ->
target
| None, _ ->
| ClangFlavors, _ ->
add_flavor_internal target "infer-capture-all"
end
@ -87,7 +87,7 @@ module Query = struct
let kind ~pattern expr = Kind {pattern= quote_if_needed pattern; expr}
let deps ?depth expr = Deps {depth; expr}
let deps depth expr = Deps {depth; expr}
let set exprs =
match List.rev_map exprs ~f:(function Target t -> t | _ -> raise NotATarget) with
@ -147,37 +147,50 @@ let parameters_with_argument =
; "--verbose" ]
let get_accepted_buck_kinds_pattern () =
if Option.is_some Config.buck_compilation_database then "^(apple|cxx)_(binary|library|test)$"
else if Config.genrule_master_mode then "^(java|android)_library$"
else "^(apple|cxx)_(binary|library)$"
let get_accepted_buck_kinds_pattern (mode : BuckMode.t) =
match mode with
| ClangCompilationDB _ ->
"^(apple|cxx)_(binary|library|test)$"
| JavaGenruleMaster ->
"^(java|android)_library$"
| ClangFlavors ->
"^(apple|cxx)_(binary|library)$"
let max_command_line_length = 50
let die_if_empty f = function [] -> f L.(die UserError) | l -> l
let buck_config =
lazy
( if Config.genrule_master_mode then
["infer.version=" ^ Version.versionString; "infer.mode=capture"]
|> List.fold ~init:[] ~f:(fun acc f -> "--config" :: f :: acc)
else [] )
(** for genrule_master_mode, this is the label expected on the capture genrules *)
let infer_enabled_label = "infer_enabled"
(** for genrule_master_mode, this is the target name suffix for the capture genrules *)
let genrule_suffix = "_infer"
let resolve_pattern_targets ~filter_kind ~dep_depth targets =
let buck_config buck_mode =
if BuckMode.is_java_genrule_master buck_mode then
["infer.version=" ^ Version.versionString; "infer.mode=capture"]
|> List.fold ~init:[] ~f:(fun acc f -> "--config" :: f :: acc)
else []
let resolve_pattern_targets (buck_mode : BuckMode.t) ~filter_kind targets =
targets |> List.rev_map ~f:Query.target |> Query.set
|> (match dep_depth with None -> Fn.id | Some depth -> Query.deps ?depth)
|> (if filter_kind then Query.kind ~pattern:(get_accepted_buck_kinds_pattern ()) else Fn.id)
|> (if Config.genrule_master_mode then Query.label_filter ~label:infer_enabled_label else Fn.id)
|> Query.exec ~buck_config:(Lazy.force buck_config)
|> if Config.genrule_master_mode then List.rev_map ~f:(fun s -> s ^ genrule_suffix) else Fn.id
|> ( match buck_mode with
| ClangFlavors | ClangCompilationDB NoDependencies ->
Fn.id
| JavaGenruleMaster | ClangCompilationDB DepsAllDepths ->
Query.deps None
| ClangCompilationDB (DepsUpToDepth depth) ->
Query.deps (Some depth) )
|> (if filter_kind then Query.kind ~pattern:(get_accepted_buck_kinds_pattern buck_mode) else Fn.id)
|> ( if BuckMode.is_java_genrule_master buck_mode then
Query.label_filter ~label:infer_enabled_label
else Fn.id )
|> Query.exec ~buck_config:(buck_config buck_mode)
|>
if BuckMode.is_java_genrule_master buck_mode then List.rev_map ~f:(fun s -> s ^ genrule_suffix)
else Fn.id
let resolve_alias_targets aliases =
@ -233,7 +246,7 @@ let inline_argument_files buck_args =
List.concat_map ~f:expand_buck_arg buck_args
let parse_command_and_targets ~filter_kind ~dep_depth original_buck_args =
let parse_command_and_targets (buck_mode : BuckMode.t) ~filter_kind original_buck_args =
let expanded_buck_args = inline_argument_files original_buck_args in
let command, args = split_buck_command expanded_buck_args in
let buck_targets_blacklist_regexp =
@ -265,15 +278,18 @@ let parse_command_and_targets ~filter_kind ~dep_depth original_buck_args =
in
let parsed_args = parse_cmd_args empty_parsed_args args in
let targets =
match (filter_kind, dep_depth, parsed_args) with
| (`No | `Auto), None, {pattern_targets= []; alias_targets= []; normal_targets} ->
match (filter_kind, buck_mode, parsed_args) with
| ( (`No | `Auto)
, (ClangFlavors | JavaGenruleMaster)
, {pattern_targets= []; alias_targets= []; normal_targets} ) ->
normal_targets
| `No, None, {pattern_targets= []; alias_targets; normal_targets} ->
| `No, (ClangFlavors | JavaGenruleMaster), {pattern_targets= []; alias_targets; normal_targets}
->
alias_targets |> resolve_alias_targets |> List.rev_append normal_targets
| (`Yes | `No | `Auto), _, {pattern_targets; alias_targets; normal_targets} ->
let filter_kind = match filter_kind with `No -> false | `Yes | `Auto -> true in
pattern_targets |> List.rev_append alias_targets |> List.rev_append normal_targets
|> resolve_pattern_targets ~filter_kind ~dep_depth
|> resolve_pattern_targets buck_mode ~filter_kind
in
let targets =
Option.value_map ~default:targets
@ -285,13 +301,14 @@ let parse_command_and_targets ~filter_kind ~dep_depth original_buck_args =
type flavored_arguments = {command: string; rev_not_targets: string list; targets: string list}
let add_flavors_to_buck_arguments ~filter_kind ~dep_depth ~extra_flavors original_buck_args =
let add_flavors_to_buck_arguments buck_mode ~filter_kind ~extra_flavors original_buck_args =
let command, rev_not_targets, targets =
parse_command_and_targets ~filter_kind ~dep_depth original_buck_args
parse_command_and_targets buck_mode ~filter_kind original_buck_args
in
let targets =
List.rev_map targets ~f:(fun t ->
Target.(t |> of_string |> add_flavor ~extra_flavors |> to_string) )
Target.(t |> of_string |> add_flavor ~extra_flavors buck_mode Config.command |> to_string)
)
in
{command; rev_not_targets; targets}

@ -7,19 +7,19 @@
open! IStd
val buck_config : string list Lazy.t
val buck_config : BuckMode.t -> string list
val parse_command_and_targets :
filter_kind:[< `Yes | `No | `Auto]
-> dep_depth:int option option
BuckMode.t
-> filter_kind:[< `Yes | `No | `Auto]
-> string list
-> string * string list * string list
type flavored_arguments = {command: string; rev_not_targets: string list; targets: string list}
val add_flavors_to_buck_arguments :
filter_kind:[< `Yes | `No | `Auto]
-> dep_depth:int option option
BuckMode.t
-> filter_kind:[< `Yes | `No | `Auto]
-> extra_flavors:string list
-> string list
-> flavored_arguments

@ -57,14 +57,14 @@ let capture build_cmd =
L.progress "Querying buck for genrule capture targets...@." ;
let time0 = Mtime_clock.counter () in
let command, args, targets =
Buck.parse_command_and_targets ~filter_kind:`Yes ~dep_depth:(Some None) buck_cmd
Buck.parse_command_and_targets JavaGenruleMaster ~filter_kind:`Yes buck_cmd
in
L.progress "Found %d genrule capture targets in %a.@." (List.length targets) Mtime.Span.pp
(Mtime_clock.count time0) ;
let all_args = List.rev_append args targets in
let updated_buck_cmd =
(* make buck tell us where in buck-out are the capture directories for merging *)
(prog :: command :: "--show-output" :: Lazy.force Buck.buck_config)
(prog :: command :: "--show-output" :: Buck.buck_config JavaGenruleMaster)
@ List.rev_append Config.buck_build_args_no_inline (Buck.store_args_in_file all_args)
in
L.(debug Capture Quiet)

@ -66,12 +66,9 @@ let run_compilation_database compilation_database should_capture_file =
(** Computes the compilation database files. *)
let get_compilation_database_files_buck ~prog ~args =
let dep_depth =
match Config.buck_compilation_database with Some (Deps depth) -> Some depth | _ -> None
in
let get_compilation_database_files_buck db_deps ~prog ~args =
match
Buck.add_flavors_to_buck_arguments ~filter_kind:`Yes ~dep_depth
Buck.add_flavors_to_buck_arguments (ClangCompilationDB db_deps) ~filter_kind:`Yes
~extra_flavors:Config.append_buck_flavors args
with
| {targets} when List.is_empty targets ->

@ -14,7 +14,8 @@ val capture_files_in_database :
val capture_file_in_database : CompilationDatabase.t -> SourceFile.t -> unit
val get_compilation_database_files_buck : prog:string -> args:string list -> [> `Raw of string] list
val get_compilation_database_files_buck :
BuckMode.clang_compilation_db_deps -> prog:string -> args:string list -> [> `Raw of string] list
(** Get the compilation database files that contain the compilation given by the buck command. It
will be the compilation of the passed targets only or also the dependencies according to the
flag --buck-compilation-database deps | no-deps *)

@ -18,7 +18,7 @@ type mode =
| Analyze
| BuckGenrule of string
| BuckGenruleMaster of string list
| BuckCompilationDB of string * string list
| BuckCompilationDB of BuckMode.clang_compilation_db_deps * string * string list
| Clang of Clang.compiler * string * string list
| ClangCompilationDB of [`Escaped of string | `Raw of string] list
| Javac of Javac.compiler * string * string list
@ -35,8 +35,9 @@ let pp_mode fmt = function
F.fprintf fmt "BuckGenRule driver mode:@\nprog = '%s'" prog
| BuckGenruleMaster build_cmd ->
F.fprintf fmt "BuckGenrule driver mode:@\nbuild command = %a" Pp.cli_args build_cmd
| BuckCompilationDB (prog, args) ->
F.fprintf fmt "BuckCompilationDB driver mode:@\nprog = '%s'@\nargs = %a" prog Pp.cli_args args
| BuckCompilationDB (deps, prog, args) ->
F.fprintf fmt "BuckCompilationDB driver mode:@\nprog = '%s'@\nargs = %a@\ndeps = %a" prog
Pp.cli_args args BuckMode.pp_clang_compilation_db_deps deps
| ClangCompilationDB _ ->
F.fprintf fmt "ClangCompilationDB driver mode"
| PythonCapture (bs, args) ->
@ -57,7 +58,7 @@ let pp_mode fmt = function
in case nothing got captured. *)
let clean_compilation_command mode =
match mode with
| BuckCompilationDB (prog, _) | Clang (_, prog, _) ->
| BuckCompilationDB (_, prog, _) | Clang (_, prog, _) ->
Some (prog ^ " clean")
| XcodeXcpretty (prog, args) ->
Some (String.concat ~sep:" " (List.append (prog :: args) ["clean"]))
@ -70,10 +71,12 @@ let register_perf_stats_report stats_type =
PerfStats.register_report (PerfStats.Time (rtime_span, initial_times)) stats_type
(* Clean up the results dir to select only what's relevant to go in the Buck cache. In particular,
(** Clean up the results dir to select only what's relevant to go in the Buck cache. In particular,
get rid of non-deterministic outputs.*)
let clean_results_dir () =
let cache_capture = Config.(flavors || genrule_mode) in
let cache_capture =
Config.genrule_mode || Option.exists Config.buck_mode ~f:BuckMode.is_clang_flavors
in
if cache_capture then DBWriter.canonicalize () ;
(* make sure we are done with the database *)
ResultsDatabase.db_close () ;
@ -188,7 +191,8 @@ let python_capture build_system build_cmd =
register_perf_stats_report PerfStats.TotalFrontend ;
let in_buck_mode = Config.equal_build_system build_system BBuck in
let build_cmd_opt =
if in_buck_mode && Config.flavors then (
match Config.buck_mode with
| Some ClangFlavors when in_buck_mode ->
(* let children infer processes know that they are inside Buck *)
let infer_args_with_buck =
String.concat
@ -198,7 +202,7 @@ let python_capture build_system build_cmd =
Unix.putenv ~key:CLOpt.args_env_var ~data:infer_args_with_buck ;
let prog, buck_args = (List.hd_exn build_cmd, List.tl_exn build_cmd) in
let {Buck.command; rev_not_targets; targets} =
Buck.add_flavors_to_buck_arguments ~filter_kind:`Auto ~dep_depth:None ~extra_flavors:[]
Buck.add_flavors_to_buck_arguments ClangFlavors ~filter_kind:`Auto ~extra_flavors:[]
buck_args
in
if List.is_empty targets then None
@ -210,8 +214,9 @@ let python_capture build_system build_cmd =
in
Logging.(debug Capture Quiet)
"Processed buck command '%a'@\n" (Pp.seq F.pp_print_string) updated_buck_cmd ;
Some updated_buck_cmd )
else Some build_cmd
Some updated_buck_cmd
| _ ->
Some build_cmd
in
Option.iter build_cmd_opt ~f:(fun updated_build_cmd ->
L.progress "Capturing in %s mode...@." (Config.string_of_build_system build_system) ;
@ -237,7 +242,11 @@ let python_capture build_system build_cmd =
[] )
@ (if not Config.debug_mode then [] else ["--debug"])
@ (if Config.filtering then [] else ["--no-filtering"])
@ (if (not Config.flavors) || not in_buck_mode then [] else ["--use-flavors"])
@ ( if
(not (Option.exists ~f:BuckMode.is_clang_flavors Config.buck_mode))
|| not in_buck_mode
then []
else ["--use-flavors"] )
@ "-j" :: string_of_int Config.jobs
:: (match Config.load_average with None -> [] | Some l -> ["-l"; string_of_float l])
@ (if not Config.pmd_xml then [] else ["--pmd-xml"])
@ -253,7 +262,8 @@ let python_capture build_system build_cmd =
@ (if not Config.buck_merge_all_deps then [] else ["--buck-merge-all-deps"])
@ ("--" :: updated_build_cmd) )
in
if in_buck_mode && Config.flavors then (RunState.set_merge_capture true ; RunState.store ()) ;
if in_buck_mode && Option.exists ~f:BuckMode.is_clang_flavors Config.buck_mode then (
RunState.set_merge_capture true ; RunState.store () ) ;
run_command ~prog:infer_py ~args
~cleanup:(function
| Error (`Exit_non_zero exit_code)
@ -269,9 +279,11 @@ let python_capture build_system build_cmd =
let capture ~changed_files = function
| Analyze ->
()
| BuckCompilationDB (prog, args) ->
| BuckCompilationDB (deps, prog, args) ->
L.progress "Capturing using Buck's compilation database...@." ;
let json_cdb = CaptureCompilationDatabase.get_compilation_database_files_buck ~prog ~args in
let json_cdb =
CaptureCompilationDatabase.get_compilation_database_files_buck deps ~prog ~args
in
capture_with_compilation_database ~changed_files json_cdb
| BuckGenrule path ->
L.progress "Capturing for Buck genrule compatibility...@." ;
@ -384,7 +396,8 @@ let error_nothing_to_analyze mode =
let analyze_and_report ?suppress_console_report ~changed_files mode =
let should_analyze, should_report =
match (Config.command, mode) with
| _, PythonCapture (BBuck, _) when not Config.flavors ->
| _, PythonCapture (BBuck, _)
when not (Option.exists ~f:BuckMode.is_clang_flavors Config.buck_mode) ->
(* In Buck mode when compilation db is not used, analysis is invoked from capture if buck flavors are not used *)
(false, false)
| _ when Config.infer_is_clang || Config.infer_is_javac ->
@ -401,7 +414,9 @@ let analyze_and_report ?suppress_console_report ~changed_files mode =
| _ when Config.merge ->
(* [--merge] overrides other behaviors *)
true
| PythonCapture (BBuck, _) when Config.flavors && InferCommand.equal Run Config.command ->
| PythonCapture (BBuck, _)
when Option.exists ~f:BuckMode.is_clang_flavors Config.buck_mode
&& InferCommand.equal Run Config.command ->
(* if doing capture + analysis of buck with flavors, we always need to merge targets before the analysis phase *)
true
| Analyze | BuckGenruleMaster _ ->
@ -477,20 +492,20 @@ let assert_supported_build_system build_system =
Config.string_of_build_system build_system |> assert_supported_mode `Xcode
| BBuck ->
let analyzer, build_string =
if Config.flavors then (`Clang, "buck with flavors")
else if Option.is_some Config.buck_compilation_database then
match Config.buck_mode with
| None ->
(`Java, "buck default java integration")
| Some ClangFlavors ->
(`Clang, "buck with flavors")
| Some (ClangCompilationDB _) ->
(`Clang, "buck compilation database")
else (
if Config.reactive_mode then
L.user_error
"WARNING: The reactive analysis mode is not compatible with the Buck integration for \
Java" ;
(`Java, Config.string_of_build_system build_system) )
| Some JavaGenruleMaster ->
(`Java, Config.string_of_build_system build_system)
in
assert_supported_mode analyzer build_string
let mode_of_build_command build_cmd =
let mode_of_build_command build_cmd (buck_mode : BuckMode.t option) =
match build_cmd with
| [] ->
if not (List.is_empty !Config.clang_compilation_dbs) then (
@ -506,32 +521,30 @@ let mode_of_build_command build_cmd =
Config.build_system_of_exe_name (Filename.basename prog)
in
assert_supported_build_system build_system ;
match (build_system : Config.build_system) with
| BBuck when Option.is_some Config.buck_compilation_database ->
BuckCompilationDB (prog, List.append args (List.rev Config.buck_build_args))
| BClang ->
match ((build_system : Config.build_system), buck_mode) with
| BBuck, Some (ClangCompilationDB deps) ->
BuckCompilationDB (deps, prog, List.append args (List.rev Config.buck_build_args))
| BBuck, Some ClangFlavors when Config.linters ->
L.user_warning
"WARNING: the linters require --buck-compilation-database to be set.@ Alternatively, \
set --no-linters to disable them and this warning.@." ;
PythonCapture (BBuck, build_cmd)
| BBuck, Some JavaGenruleMaster ->
BuckGenruleMaster build_cmd
| BClang, _ ->
Clang (Clang.Clang, prog, args)
| BMake ->
| BMake, _ ->
Clang (Clang.Make, prog, args)
| BJava ->
| BJava, _ ->
Javac (Javac.Java, prog, args)
| BJavac ->
| BJavac, _ ->
Javac (Javac.Javac, prog, args)
| BMvn ->
| BMvn, _ ->
Maven (prog, args)
| BXcode when Config.xcpretty ->
| BXcode, _ when Config.xcpretty ->
XcodeXcpretty (prog, args)
| BBuck when (not Config.flavors) && Config.reactive_mode ->
L.die UserError "The Buck Java integration does not support --reactive@."
| BBuck
when Option.is_none Config.buck_compilation_database && Config.flavors && Config.linters ->
L.user_warning
"WARNING: the linters require --buck-compilation-database to be set.@ Alternatively, \
set --no-linters to disable them and this warning.@." ;
PythonCapture (BBuck, build_cmd)
| BBuck when Config.genrule_master_mode ->
BuckGenruleMaster build_cmd
| (BAnt | BBuck | BGradle | BNdk | BXcode) as build_system ->
| (BBuck as build_system), (None | Some ClangFlavors)
| ((BAnt | BGradle | BNdk | BXcode) as build_system), _ ->
PythonCapture (build_system, build_cmd) )
@ -551,7 +564,7 @@ let mode_from_command_line =
assert_supported_mode `Java "Buck genrule" ;
BuckGenrule path
| None ->
mode_of_build_command (List.rev Config.rest) )
mode_of_build_command (List.rev Config.rest) Config.buck_mode )
let run_prologue mode =

@ -15,7 +15,7 @@ type mode =
| Analyze
| BuckGenrule of string
| BuckGenruleMaster of string list
| BuckCompilationDB of string * string list
| BuckCompilationDB of BuckMode.clang_compilation_db_deps * string * string list
| Clang of Clang.compiler * string * string list
| ClangCompilationDB of [`Escaped of string | `Raw of string] list
| Javac of Javac.compiler * string * string list

@ -6,12 +6,11 @@
TESTS_DIR = ../..
BUCK_TARGET = //module2:module2
INFER_OPTIONS = --eradicate --no-linters
INFER_OPTIONS = --eradicate --no-linters --buck-java-deprecated
INFERPRINT_OPTIONS = --issues-tests
CLEAN_EXTRA = buck-out
SOURCES = $(shell find . -name '*.java')
include $(TESTS_DIR)/java.make
include $(TESTS_DIR)/infer.make

@ -23,7 +23,7 @@ $(OBJECTS): $(JAVA_SOURCE_FILES)
infer-out/report.json: $(CLANG_DEPS) $(SOURCES) $(MAKEFILE_LIST)
$(QUIET)$(REMOVE_DIR) buck-out && \
$(call silent_on_success,Testing Buck flavors integration,\
$(INFER_BIN) $(INFER_OPTIONS) capture --flavors --results-dir $(CURDIR)/infer-out \
$(INFER_BIN) $(INFER_OPTIONS) capture --buck-clang --results-dir $(CURDIR)/infer-out \
@blacklist.txt --buck-blacklist '.*src/hello2\.c' \
-- $(BUCK) build --no-cache $(BUCK_TARGET) &&\
$(INFER_BIN) $(INFER_OPTIONS) --merge analyze)

@ -17,5 +17,5 @@ infer-out/report.json: $(JAVA_DEPS) $(JAVA_SOURCE_FILES)
$(QUIET)$(REMOVE_DIR) buck-out && \
$(call silent_on_success,Testing Buck Java cross module integration,\
INFER_BIN=$(INFER_BIN) \
$(INFER_BIN) --results-dir $(CURDIR)/infer-out -- \
$(INFER_BIN) --buck-java-deprecated --results-dir $(CURDIR)/infer-out -- \
$(BUCK) build --no-cache $(BUCK_TARGET))

@ -11,7 +11,7 @@ B_CPP = src/b.cpp
BUCK_TARGET = //src:test
TEST_DETERMINATOR_RESULT = infer-out/changed_functions.json
DIFF_OUTPUT = diff.mod.test
INFER_OPTIONS = --flavors --process-clang-ast --no-linters --no-capture --export-changed-functions --modified-lines $(DIFF_OUTPUT)
INFER_OPTIONS = --buck-clang --process-clang-ast --no-linters --no-capture --export-changed-functions --modified-lines $(DIFF_OUTPUT)
$(DIFF_OUTPUT):
$(QUIET)echo -n '$(A_CPP):' > diff.mod.test

@ -22,6 +22,6 @@ $(OBJECTS): $(JAVA_SOURCE_FILES)
infer-out/report.json: $(CLANG_DEPS) $(SOURCES) $(MAKEFILE_LIST)
$(QUIET)$(REMOVE_DIR) buck-out && \
$(call silent_on_success,Testing Buck flavors integration,\
$(INFER_BIN) $(INFER_OPTIONS) capture --flavors --results-dir $(CURDIR)/infer-out -- \
$(INFER_BIN) $(INFER_OPTIONS) capture --buck-clang --results-dir $(CURDIR)/infer-out -- \
$(BUCK) build --no-cache $(BUCK_TARGET) &&\
$(INFER_BIN) $(INFER_OPTIONS) --merge analyze)

@ -22,12 +22,12 @@ $(OBJECTS): $(JAVA_SOURCE_FILES)
differences.exp.test: $(CLANG_DEPS) $(SOURCES) $(MAKEFILE_LIST)
$(QUIET)$(REMOVE_DIR) buck-out && \
$(call silent_on_success,Running Buck flavors capture a first time,\
$(INFER_BIN) $(INFER_OPTIONS) capture --flavors --results-dir $(CURDIR)/infer-out -- \
$(INFER_BIN) $(INFER_OPTIONS) capture --buck-clang --results-dir $(CURDIR)/infer-out -- \
$(BUCK) build --no-cache $(BUCK_TARGET) && \
find buck-out/gen/src/infer-out-* -type f | xargs cat | $(SHASUM) > capture_hash-1.sha)
$(QUIET)$(REMOVE_DIR) buck-out && \
$(call silent_on_success,Running Buck flavors capture a second time,\
$(INFER_BIN) $(INFER_OPTIONS) capture --flavors --results-dir $(CURDIR)/infer-out -- \
$(INFER_BIN) $(INFER_OPTIONS) capture --buck-clang --results-dir $(CURDIR)/infer-out -- \
$(BUCK) build --no-cache $(BUCK_TARGET) && \
find buck-out/gen/src/infer-out-* -type f | xargs cat | $(SHASUM) > capture_hash-2.sha)
$(QUIET)$(call silent_on_success,Computing difference,\

@ -14,7 +14,7 @@ include $(TESTS_DIR)/differential.make
$(CURRENT_REPORT) $(PREVIOUS_REPORT): $(CLANG_DEPS)
BUCK_TARGET = //src:hello
INFER_OPTIONS = $(DIFFERENTIAL_ARGS) --flavors --reactive --debug-exceptions --no-linters
INFER_OPTIONS = $(DIFFERENTIAL_ARGS) --buck-clang --reactive --debug-exceptions --no-linters
.PHONY: compare_reports
compare_reports: current.exp.test previous.exp.test

@ -9,7 +9,7 @@ ROOT_DIR = $(TESTS_DIR)/../..
BUCK_TARGET = //src:hello
SOURCES = src/hello.c src/hello2.c
OBJECTS = buck-out/gen/src/hello\#compile-hello.c.o1f717d69,default/hello.c.o
INFER_OPTIONS = --report-custom-error --developer-mode --no-linters
INFER_OPTIONS = --report-custom-error --developer-mode --no-linters --buck-clang
INFERPRINT_OPTIONS = --issues-tests
CLEAN_EXTRA = buck-out
@ -22,5 +22,5 @@ $(OBJECTS): $(SOURCES)
infer-out/report.json: $(CLANG_DEPS) $(SOURCES) $(MAKEFILE_LIST)
$(QUIET)$(REMOVE_DIR) buck-out && \
$(call silent_on_success,Testing infer-run Buck flavors integration,\
$(INFER_BIN) $(INFER_OPTIONS) run --flavors --results-dir $(CURDIR)/infer-out --reactive -- \
$(INFER_BIN) $(INFER_OPTIONS) run --results-dir $(CURDIR)/infer-out --reactive -- \
$(BUCK) build --no-cache $(BUCK_TARGET))

@ -10,7 +10,7 @@ TARGET = //src:target
SOURCES = src/UsingJavacJar.java
OBJECTS = buck-out/gen/src/lib__target__output/target.jar
BUCKCONFIG = .buckconfig
INFER_OPTIONS = --eradicate-only
INFER_OPTIONS = --eradicate-only --buck-java-deprecated
INFERPRINT_OPTIONS = --issues-tests
CLEAN_EXTRA = buck-out

@ -12,7 +12,7 @@ CLEAN_EXTRA = buck-out
SOURCES = $(shell find . -name '*.java')
INFERPRINT_OPTIONS = --issues-tests
INFER_OPTIONS = --genrule-master-mode --debug-exceptions
INFER_OPTIONS = --buck-java --debug-exceptions
include $(TESTS_DIR)/infer.make

@ -16,5 +16,5 @@ ignore (Ident.create_fresh Ident.knormal) ;
let ident = Ident.create_fresh Ident.knormal in
let e = Exp.Var ident in
print_endline (Exp.to_string e) ;
(* pass --flavors flag to change the value *)
print_endline (string_of_bool Config.flavors)
(* pass --debug to change the value *)
print_endline (string_of_bool Config.debug_mode)

Loading…
Cancel
Save