Skip to content

Commit

Permalink
Merge branch 'facebook:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
cbarrete authored Jun 18, 2024
2 parents 40c6108 + 026c8a0 commit 7399264
Show file tree
Hide file tree
Showing 32 changed files with 171 additions and 149 deletions.
7 changes: 2 additions & 5 deletions app/buck2_audit_server/src/analysis_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ use async_trait::async_trait;
use buck2_analysis::analysis::calculation::resolve_queries;
use buck2_audit::analysis_queries::AuditAnalysisQueriesCommand;
use buck2_cli_proto::ClientContext;
use buck2_common::pattern::parse_from_cli::parse_and_resolve_patterns_from_cli_args;
use buck2_core::pattern::pattern_type::TargetPatternExtra;
use buck2_core::target::label::label::TargetLabel;
use buck2_node::nodes::configured_frontend::ConfiguredTargetNodeCalculation;
use buck2_server_ctx::ctx::ServerCommandContextTrait;
use buck2_server_ctx::ctx::ServerCommandDiceContext;
use buck2_server_ctx::partial_result_dispatcher::PartialResultDispatcher;
use buck2_server_ctx::pattern::parse_and_resolve_patterns_from_cli_args;
use dupe::Dupe;
use gazebo::prelude::*;

use crate::common::target_resolution_config::audit_command_target_resolution_config;
use crate::ServerAuditSubcommand;
Expand All @@ -43,9 +42,7 @@ impl ServerAuditSubcommand for AuditAnalysisQueriesCommand {
let resolved_pattern =
parse_and_resolve_patterns_from_cli_args::<TargetPatternExtra>(
&mut ctx,
&self
.patterns
.map(|pat| buck2_data::TargetPattern { value: pat.clone() }),
&self.patterns,
server_ctx.working_dir(),
)
.await?;
Expand Down
7 changes: 2 additions & 5 deletions app/buck2_audit_server/src/classpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ use buck2_build_api::actions::artifact::get_artifact_fs::GetArtifactFs;
use buck2_build_api::configure_targets::load_compatible_patterns;
use buck2_build_api::query::analysis::CLASSPATH_FOR_TARGETS;
use buck2_cli_proto::ClientContext;
use buck2_common::pattern::parse_from_cli::parse_patterns_from_cli_args;
use buck2_core::pattern::pattern_type::TargetPatternExtra;
use buck2_node::load_patterns::MissingTargetBehavior;
use buck2_server_ctx::ctx::ServerCommandContextTrait;
use buck2_server_ctx::ctx::ServerCommandDiceContext;
use buck2_server_ctx::global_cfg_options::global_cfg_options_from_client_context;
use buck2_server_ctx::partial_result_dispatcher::PartialResultDispatcher;
use buck2_server_ctx::pattern::parse_patterns_from_cli_args;
use dupe::Dupe;
use futures::FutureExt;
use gazebo::prelude::SliceExt;
use indexmap::IndexMap;

use crate::ServerAuditSubcommand;
Expand All @@ -42,9 +41,7 @@ impl ServerAuditSubcommand for AuditClasspathCommand {
let cwd = server_ctx.working_dir();
let parsed_patterns = parse_patterns_from_cli_args::<TargetPatternExtra>(
&mut ctx,
&self
.patterns
.map(|pat| buck2_data::TargetPattern { value: pat.clone() }),
&self.patterns,
cwd,
)
.await?;
Expand Down
5 changes: 2 additions & 3 deletions app/buck2_audit_server/src/common/configured_target_labels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ use buck2_core::pattern::pattern_type::ConfigurationPredicate;
use buck2_core::pattern::pattern_type::ConfiguredTargetPatternExtra;
use buck2_core::target::configured_target_label::ConfiguredTargetLabel;
use buck2_server_ctx::ctx::ServerCommandContextTrait;
use buck2_server_ctx::pattern::parse_and_resolve_patterns_to_targets_from_cli_args;
use buck2_server_ctx::pattern_parse_and_resolve::parse_and_resolve_patterns_to_targets_from_cli_args;
use buck2_server_ctx::target_resolution_config::TargetResolutionConfig;
use dice::DiceComputations;
use gazebo::prelude::SliceExt;

use crate::common::target_resolution_config::audit_command_target_resolution_config;

Expand All @@ -40,7 +39,7 @@ pub(crate) async fn audit_command_configured_target_labels(
let targets =
parse_and_resolve_patterns_to_targets_from_cli_args::<ConfiguredTargetPatternExtra>(
ctx,
&patterns.map(|pat| buck2_data::TargetPattern { value: pat.clone() }),
&patterns,
server_ctx.working_dir(),
)
.await?;
Expand Down
6 changes: 2 additions & 4 deletions app/buck2_audit_server/src/dep_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ use async_trait::async_trait;
use buck2_audit::dep_files::AuditDepFilesCommand;
use buck2_build_api::audit_dep_files::AUDIT_DEP_FILES;
use buck2_cli_proto::ClientContext;
use buck2_common::pattern::parse_from_cli::parse_patterns_from_cli_args;
use buck2_core::category::Category;
use buck2_core::pattern::pattern_type::TargetPatternExtra;
use buck2_node::target_calculation::ConfiguredTargetCalculation;
use buck2_server_ctx::ctx::ServerCommandContextTrait;
use buck2_server_ctx::ctx::ServerCommandDiceContext;
use buck2_server_ctx::global_cfg_options::global_cfg_options_from_client_context;
use buck2_server_ctx::partial_result_dispatcher::PartialResultDispatcher;
use buck2_server_ctx::pattern::parse_patterns_from_cli_args;

use crate::ServerAuditSubcommand;

Expand All @@ -42,9 +42,7 @@ impl ServerAuditSubcommand for AuditDepFilesCommand {

let label = parse_patterns_from_cli_args::<TargetPatternExtra>(
&mut ctx,
&[buck2_data::TargetPattern {
value: self.pattern.clone(),
}],
&[self.pattern.clone()],
server_ctx.working_dir(),
)
.await?
Expand Down
7 changes: 2 additions & 5 deletions app/buck2_audit_server/src/providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ use buck2_cli_proto::ClientContext;
use buck2_server_ctx::ctx::ServerCommandContextTrait;
use buck2_server_ctx::ctx::ServerCommandDiceContext;
use buck2_server_ctx::partial_result_dispatcher::PartialResultDispatcher;
use buck2_server_ctx::pattern::parse_and_resolve_provider_labels_from_cli_args;
use buck2_server_ctx::pattern_parse_and_resolve::parse_and_resolve_provider_labels_from_cli_args;
use buck2_util::indent::indent;
use dice::DiceComputations;
use dice::DiceTransaction;
use futures::stream::FuturesOrdered;
use futures::FutureExt;
use futures::StreamExt;
use gazebo::prelude::*;

use crate::common::target_resolution_config::audit_command_target_resolution_config;
use crate::ServerAuditSubcommand;
Expand Down Expand Up @@ -63,9 +62,7 @@ async fn server_execute_with_dice(

let provider_labels = parse_and_resolve_provider_labels_from_cli_args(
&mut ctx,
&command
.patterns
.map(|pat| buck2_data::TargetPattern { value: pat.clone() }),
&command.patterns,
server_ctx.working_dir(),
)
.await?;
Expand Down
8 changes: 2 additions & 6 deletions app/buck2_audit_server/src/subtargets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ use buck2_core::provider::label::ConfiguredProvidersLabel;
use buck2_server_ctx::ctx::ServerCommandContextTrait;
use buck2_server_ctx::ctx::ServerCommandDiceContext;
use buck2_server_ctx::partial_result_dispatcher::PartialResultDispatcher;
use buck2_server_ctx::pattern::parse_and_resolve_provider_labels_from_cli_args;
use buck2_server_ctx::pattern_parse_and_resolve::parse_and_resolve_provider_labels_from_cli_args;
use buck2_server_ctx::stdout_partial_output::StdoutPartialOutput;
use buck2_util::indent::indent;
use dice::DiceTransaction;
use futures::stream::FuturesOrdered;
use futures::StreamExt;
use gazebo::prelude::*;

use crate::common::target_resolution_config::audit_command_target_resolution_config;
use crate::ServerAuditSubcommand;
Expand Down Expand Up @@ -59,10 +58,7 @@ async fn server_execute_with_dice(

let provider_labels = parse_and_resolve_provider_labels_from_cli_args(
&mut ctx,
command
.patterns
.map(|pat| buck2_data::TargetPattern { value: pat.clone() })
.as_slice(),
&command.patterns,
server_ctx.working_dir(),
)
.await?;
Expand Down
7 changes: 2 additions & 5 deletions app/buck2_audit_server/src/visibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use async_trait::async_trait;
use buck2_audit::visibility::AuditVisibilityCommand;
use buck2_cli_proto::ClientContext;
use buck2_common::pattern::parse_from_cli::parse_patterns_from_cli_args;
use buck2_core::pattern::pattern_type::TargetPatternExtra;
use buck2_node::load_patterns::load_patterns;
use buck2_node::load_patterns::MissingTargetBehavior;
Expand All @@ -22,10 +23,8 @@ use buck2_query::query::traversal::async_depth_first_postorder_traversal;
use buck2_server_ctx::ctx::ServerCommandContextTrait;
use buck2_server_ctx::ctx::ServerCommandDiceContext;
use buck2_server_ctx::partial_result_dispatcher::PartialResultDispatcher;
use buck2_server_ctx::pattern::parse_patterns_from_cli_args;
use dice::DiceTransaction;
use dupe::Dupe;
use gazebo::prelude::SliceExt;

use crate::ServerAuditSubcommand;

Expand Down Expand Up @@ -110,9 +109,7 @@ impl ServerAuditSubcommand for AuditVisibilityCommand {
.with_dice_ctx(|server_ctx, mut ctx| async move {
let parsed_patterns = parse_patterns_from_cli_args::<TargetPatternExtra>(
&mut ctx,
&self
.patterns
.map(|pat| buck2_data::TargetPattern { value: pat.clone() }),
&self.patterns,
server_ctx.working_dir(),
)
.await?;
Expand Down
19 changes: 10 additions & 9 deletions app/buck2_cli_proto/daemon.proto
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ message ClientContext {
}

message TargetsRequest {
reserved 3 to 16, 18, 4242000;
reserved 2, 3 to 16, 18, 4242000;

enum TargetHashFileMode {
PATHS_ONLY = 0;
Expand Down Expand Up @@ -193,7 +193,7 @@ message TargetsRequest {
}

ClientContext context = 1;
repeated buck.data.TargetPattern target_patterns = 2;
repeated string target_patterns = 102;
TargetCfg target_cfg = 201;

optional string output = 17;
Expand Down Expand Up @@ -221,9 +221,9 @@ message TargetsShowOutputsResponse {

// `buck2 ctargets` command
message ConfiguredTargetsRequest {
reserved 10;
reserved 2, 10;
ClientContext context = 1;
repeated buck.data.TargetPattern target_patterns = 2;
repeated string target_patterns = 12;
TargetCfg target_cfg = 201;
bool skip_missing_targets = 11;
}
Expand Down Expand Up @@ -373,10 +373,10 @@ message CommonBuildOptions {
}

message BuildRequest {
reserved 5, 4242001;
reserved 2, 5, 4242001;

ClientContext context = 1;
repeated buck.data.TargetPattern target_patterns = 2;
repeated string target_patterns = 10;
TargetCfg target_cfg = 201;
repeated string target_universe = 8;

Expand Down Expand Up @@ -426,10 +426,10 @@ message TestSessionOptions {
}

message TestRequest {
reserved 10;
reserved 2, 10;

ClientContext context = 1;
repeated buck.data.TargetPattern target_patterns = 2;
repeated string target_patterns = 14;
TargetCfg target_cfg = 201;

repeated string test_executor_args = 3;
Expand Down Expand Up @@ -491,8 +491,9 @@ message BxlResponse {
}

message InstallRequest {
reserved 2;
ClientContext context = 1;
repeated buck.data.TargetPattern target_patterns = 2;
repeated string target_patterns = 12;
TargetCfg target_cfg = 201;
CommonBuildOptions build_opts = 3;
repeated string installer_run_args = 4;
Expand Down
5 changes: 1 addition & 4 deletions app/buck2_client/src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use buck2_client_ctx::output_destination_arg::OutputDestinationArg;
use buck2_client_ctx::path_arg::PathArg;
use buck2_client_ctx::streaming::StreamingCommand;
use dupe::Dupe;
use gazebo::prelude::*;

use crate::commands::build::out::copy_to_out;
use crate::print::PrintOutputs;
Expand Down Expand Up @@ -207,9 +206,7 @@ impl StreamingCommand for BuildCommand {
.build(
BuildRequest {
context: Some(context),
target_patterns: self
.patterns
.map(|p| buck2_data::TargetPattern { value: p.clone() }),
target_patterns: self.patterns.clone(),
target_cfg: Some(self.target_cfg.target_cfg.target_cfg()),
build_providers: Some(BuildProviders {
default_info: self.default_info() as i32,
Expand Down
5 changes: 1 addition & 4 deletions app/buck2_client/src/commands/ctargets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use buck2_client_ctx::daemon::client::BuckdClientConnector;
use buck2_client_ctx::daemon::client::NoPartialResultHandler;
use buck2_client_ctx::exit_result::ExitResult;
use buck2_client_ctx::streaming::StreamingCommand;
use gazebo::prelude::SliceExt;

/// Resolve target patterns to configured targets.
#[derive(Debug, clap::Parser)]
Expand Down Expand Up @@ -62,9 +61,7 @@ impl StreamingCommand for ConfiguredTargetsCommand {
.ctargets(
ConfiguredTargetsRequest {
context,
target_patterns: self.patterns.map(|pat| buck2_data::TargetPattern {
value: pat.to_owned(),
}),
target_patterns: self.patterns,
target_cfg: Some(self.target_cfg.target_cfg()),
skip_missing_targets: self.skip_missing_targets,
},
Expand Down
5 changes: 1 addition & 4 deletions app/buck2_client/src/commands/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use buck2_client_ctx::daemon::client::BuckdClientConnector;
use buck2_client_ctx::daemon::client::NoPartialResultHandler;
use buck2_client_ctx::exit_result::ExitResult;
use buck2_client_ctx::streaming::StreamingCommand;
use gazebo::prelude::*;

#[derive(Debug, clap::Parser)]
#[clap(name = "install", about = "Build and install an application")]
Expand Down Expand Up @@ -184,9 +183,7 @@ impl StreamingCommand for InstallCommand {
.install(
InstallRequest {
context: Some(context),
target_patterns: self.patterns.map(|pat| buck2_data::TargetPattern {
value: pat.to_owned(),
}),
target_patterns: self.patterns.clone(),
target_cfg: Some(self.target_cfg.target_cfg()),
build_opts: Some(self.build_opts.to_proto()),
installer_run_args: extra_run_args,
Expand Down
4 changes: 1 addition & 3 deletions app/buck2_client/src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ impl StreamingCommand for RunCommand {
BuildRequest {
context: Some(context),
// TODO(wendyy): glob patterns should be prohibited, and command should fail before the build event happens.
target_patterns: vec![buck2_data::TargetPattern {
value: self.target.clone(),
}],
target_patterns: vec![self.target.clone()],
target_cfg: Some(self.target_cfg.target_cfg()),
build_providers: Some(BuildProviders {
default_info: build_providers::Action::Skip as i32,
Expand Down
4 changes: 1 addition & 3 deletions app/buck2_client/src/commands/targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,7 @@ impl StreamingCommand for TargetsCommand {

let target_request = TargetsRequest {
context,
target_patterns: self.patterns.map(|pat| buck2_data::TargetPattern {
value: pat.to_owned(),
}),
target_patterns: self.patterns,
output_format: output_format as i32,
targets: Some(if self.resolve_alias {
targets_request::Targets::ResolveAlias(targets_request::ResolveAlias {})
Expand Down
5 changes: 1 addition & 4 deletions app/buck2_client/src/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ use buck2_client_ctx::subscribers::superconsole::test::span_from_build_failure_c
use buck2_client_ctx::subscribers::superconsole::test::TestCounterColumn;
use buck2_core::fs::fs_util;
use buck2_core::fs::working_dir::WorkingDir;
use gazebo::prelude::*;
use superconsole::Line;
use superconsole::Span;

Expand Down Expand Up @@ -201,9 +200,7 @@ impl StreamingCommand for TestCommand {
.test(
TestRequest {
context: Some(context),
target_patterns: self
.patterns
.map(|pat| buck2_data::TargetPattern { value: pat.clone() }),
target_patterns: self.patterns.clone(),
target_cfg: Some(self.target_cfg.target_cfg()),
test_executor_args: self.test_executor_args,
excluded_labels: self.exclude,
Expand Down
1 change: 1 addition & 0 deletions app/buck2_common/src/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
*/

pub mod package_roots;
pub mod parse_from_cli;
pub mod resolve;
Loading

0 comments on commit 7399264

Please sign in to comment.