[buck] don't fail on empty list of targets found from query

Reviewed By: jvillard

Differential Revision: D16071738

fbshipit-source-id: 2cff0b931
master
Nikos Gorogiannis 5 years ago committed by Facebook Github Bot
parent 38e66d6f91
commit 2f21d223ac

@ -179,8 +179,7 @@ let resolve_pattern_targets ~filter_kind ~dep_depth targets =
|> (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)
|> die_if_empty (fun die -> die "*** buck query returned no targets.")
|> if Config.genrule_master_mode then List.rev_map ~f:(fun s -> s ^ genrule_suffix) else Fn.id
let resolve_alias_targets aliases =
@ -292,17 +291,11 @@ let add_flavors_to_buck_arguments ~filter_kind ~dep_depth ~extra_flavors origina
let command, rev_not_targets, targets =
parse_command_and_targets ~filter_kind ~dep_depth original_buck_args
in
match targets with
| [] ->
L.(die UserError)
"ERROR: no targets found in Buck command `%a`." (Pp.seq F.pp_print_string)
original_buck_args
| _ ->
let targets =
List.rev_map targets ~f:(fun t ->
Target.(t |> of_string |> add_flavor ~extra_flavors |> to_string) )
in
{command; rev_not_targets; targets}
let targets =
List.rev_map targets ~f:(fun t ->
Target.(t |> of_string |> add_flavor ~extra_flavors |> to_string) )
in
{command; rev_not_targets; targets}
let rec exceed_length ~max = function

@ -52,8 +52,10 @@ let capture build_cmd =
in
L.(debug Capture Quiet)
"Processed buck command '%a'@." (Pp.seq F.pp_print_string) updated_buck_cmd ;
let time0 = Mtime_clock.counter () in
run_buck_capture updated_buck_cmd ;
L.progress "Genrule capture took %a.@." Mtime.Span.pp (Mtime_clock.count time0) ;
RunState.set_merge_capture true ;
RunState.store ()
if List.is_empty targets then L.external_warning "WARNING: found no buck targets to analyze.@."
else
let time0 = Mtime_clock.counter () in
run_buck_capture updated_buck_cmd ;
L.progress "Genrule capture took %a.@." Mtime.Span.pp (Mtime_clock.count time0) ;
RunState.set_merge_capture true ;
RunState.store ()

@ -71,6 +71,9 @@ let get_compilation_database_files_buck ~prog ~args =
Buck.add_flavors_to_buck_arguments ~filter_kind:`Yes ~dep_depth
~extra_flavors:Config.append_buck_flavors args
with
| {targets} when List.is_empty targets ->
L.external_warning "WARNING: found no buck targets to analyze.@." ;
[]
| {command= "build" as command; rev_not_targets; targets} ->
let targets_args = Buck.store_args_in_file targets in
let build_args =

@ -193,35 +193,37 @@ let capture_with_compilation_database db_files =
CaptureCompilationDatabase.capture_files_in_database compilation_database
let capture ~changed_files = function
| Analyze ->
()
| BuckCompilationDB (prog, args) ->
L.progress "Capturing using Buck's compilation database...@." ;
let json_cdb = CaptureCompilationDatabase.get_compilation_database_files_buck ~prog ~args in
capture_with_compilation_database ~changed_files json_cdb
| BuckGenrule path ->
L.progress "Capturing for Buck genrule compatibility...@." ;
JMain.from_arguments path
| BuckGenruleMaster build_cmd ->
L.progress "Capturing for BuckGenruleMaster integration...@." ;
BuckGenrule.capture build_cmd
| Clang (compiler, prog, args) ->
if CLOpt.is_originator then L.progress "Capturing in make/cc mode...@." ;
Clang.capture compiler ~prog ~args
| ClangCompilationDB db_files ->
L.progress "Capturing using compilation database...@." ;
capture_with_compilation_database ~changed_files db_files
| Javac (compiler, prog, args) ->
if CLOpt.is_originator then L.progress "Capturing in javac mode...@." ;
Javac.capture compiler ~prog ~args
| Maven (prog, args) ->
L.progress "Capturing in maven mode...@." ;
Maven.capture ~prog ~args
| PythonCapture (build_system, build_cmd) ->
register_perf_stats_report PerfStats.TotalFrontend ;
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 (
(* let children infer processes know that they are inside Buck *)
let infer_args_with_buck =
String.concat
~sep:(String.of_char CLOpt.env_var_sep)
(Option.to_list (Sys.getenv CLOpt.args_env_var) @ ["--buck"])
in
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_args
in
if List.is_empty targets then None
else
let all_args = List.rev_append rev_not_targets targets in
let updated_buck_cmd =
[prog; command]
@ List.rev_append Config.buck_build_args_no_inline (Buck.store_args_in_file all_args)
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
in
Option.iter build_cmd_opt ~f:(fun updated_build_cmd ->
L.progress "Capturing in %s mode...@." (Config.string_of_build_system build_system) ;
let in_buck_mode = Config.equal_build_system build_system BBuck in
let infer_py = Config.lib_dir ^/ "python" ^/ "infer.py" in
let args =
List.rev_append Config.anon_args
@ -261,31 +263,7 @@ let capture ~changed_files = function
[]
| Some d ->
["--xcode-developer-dir"; d] )
@ "--"
::
( if in_buck_mode && Config.flavors then (
(* let children infer processes know that they are inside Buck *)
let infer_args_with_buck =
String.concat
~sep:(String.of_char CLOpt.env_var_sep)
(Option.to_list (Sys.getenv CLOpt.args_env_var) @ ["--buck"])
in
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_args
in
let all_args = List.rev_append rev_not_targets targets in
let updated_buck_cmd =
[prog; command]
@ List.rev_append Config.buck_build_args_no_inline
(Buck.store_args_in_file all_args)
in
Logging.(debug Capture Quiet)
"Processed buck command '%a'@\n" (Pp.seq F.pp_print_string) updated_buck_cmd ;
updated_buck_cmd )
else build_cmd ) )
@ ("--" :: updated_build_cmd) )
in
if in_buck_mode && Config.flavors then ( RunState.set_merge_capture true ; RunState.store () ) ;
run_command ~prog:infer_py ~args
@ -297,7 +275,36 @@ let capture ~changed_files = function
| status ->
command_error_handling ~always_die:true ~prog:infer_py ~args status )
() ;
PerfStats.get_reporter PerfStats.TotalFrontend ()
PerfStats.get_reporter PerfStats.TotalFrontend () )
let capture ~changed_files = function
| Analyze ->
()
| BuckCompilationDB (prog, args) ->
L.progress "Capturing using Buck's compilation database...@." ;
let json_cdb = CaptureCompilationDatabase.get_compilation_database_files_buck ~prog ~args in
capture_with_compilation_database ~changed_files json_cdb
| BuckGenrule path ->
L.progress "Capturing for Buck genrule compatibility...@." ;
JMain.from_arguments path
| BuckGenruleMaster build_cmd ->
L.progress "Capturing for BuckGenruleMaster integration...@." ;
BuckGenrule.capture build_cmd
| Clang (compiler, prog, args) ->
if CLOpt.is_originator then L.progress "Capturing in make/cc mode...@." ;
Clang.capture compiler ~prog ~args
| ClangCompilationDB db_files ->
L.progress "Capturing using compilation database...@." ;
capture_with_compilation_database ~changed_files db_files
| Javac (compiler, prog, args) ->
if CLOpt.is_originator then L.progress "Capturing in javac mode...@." ;
Javac.capture compiler ~prog ~args
| Maven (prog, args) ->
L.progress "Capturing in maven mode...@." ;
Maven.capture ~prog ~args
| PythonCapture (build_system, build_cmd) ->
python_capture build_system build_cmd
| XcodeXcpretty (prog, args) ->
L.progress "Capturing using xcodebuild and xcpretty...@." ;
check_xcpretty () ;

Loading…
Cancel
Save