Skip to content

Commit f1be6a6

Browse files
stepanchegfacebook-github-bot
authored andcommitted
Remove dep on ExecutionPlatformConstraints from buck2_bxl
Summary: For D63929039. Reviewed By: JakobDegen Differential Revision: D63929038 fbshipit-source-id: 7f04253a907ce3f5b6d2ef15fed89573f31a3d3b
1 parent e6e9711 commit f1be6a6

File tree

4 files changed

+56
-17
lines changed

4 files changed

+56
-17
lines changed

app/buck2_bxl/src/bxl/starlark_defs/context/actions.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use buck2_build_api::analysis::registry::AnalysisRegistry;
1616
use buck2_build_api::interpreter::rule_defs::context::AnalysisActions;
1717
use buck2_build_api::interpreter::rule_defs::provider::dependency::Dependency;
1818
use buck2_configured::configuration::calculation::ConfigurationCalculation;
19-
use buck2_configured::nodes::calculation::ExecutionPlatformConstraints;
2019
use buck2_core::cells::name::CellName;
2120
use buck2_core::configuration::data::ConfigurationData;
2221
use buck2_core::configuration::pair::ConfigurationNoExec;
@@ -29,6 +28,7 @@ use buck2_interpreter::types::configured_providers_label::StarlarkProvidersLabel
2928
use buck2_node::attrs::configuration_context::AttrConfigurationContext;
3029
use buck2_node::attrs::configuration_context::AttrConfigurationContextImpl;
3130
use buck2_node::configuration::resolved::ConfigurationSettingKey;
31+
use buck2_node::execution::GET_EXECUTION_PLATFORMS;
3232
use derivative::Derivative;
3333
use derive_more::Display;
3434
use dice::DiceComputations;
@@ -107,19 +107,22 @@ pub(crate) async fn resolve_bxl_execution_platform(
107107
.map(|t| configuration_ctx.configure_toolchain_target(t))
108108
.collect();
109109

110-
let execution_constraints = ExecutionPlatformConstraints::new_constraints(
111-
exec_deps
112-
.iter()
113-
.map(|label| label.target().dupe())
114-
.collect(),
115-
toolchain_deps_configured
116-
.iter()
117-
.map(|dep| TargetConfiguredTargetLabel::new_without_exec_cfg(dep.target().dupe()))
118-
.collect(),
119-
exec_compatible_with,
120-
);
121-
122-
let resolved_execution = execution_constraints.one_for_cell(ctx, cell).await?;
110+
let resolved_execution = GET_EXECUTION_PLATFORMS
111+
.get()?
112+
.execution_platform_resolution_one_for_cell(
113+
ctx,
114+
exec_deps
115+
.iter()
116+
.map(|label| label.target().dupe())
117+
.collect(),
118+
toolchain_deps_configured
119+
.iter()
120+
.map(|dep| TargetConfiguredTargetLabel::new_without_exec_cfg(dep.target().dupe()))
121+
.collect(),
122+
exec_compatible_with,
123+
cell,
124+
)
125+
.await?;
123126

124127
let exec_deps_configured = exec_deps.try_map(|e| {
125128
let label =

app/buck2_configured/src/configuration/calculation.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ use buck2_build_api::analysis::calculation::RuleAnalysisCalculation;
4949
use buck2_build_api::interpreter::rule_defs::provider::builtin::configuration_info::FrozenConfigurationInfo;
5050
use buck2_build_api::interpreter::rule_defs::provider::builtin::execution_platform_registration_info::FrozenExecutionPlatformRegistrationInfo;
5151
use buck2_common::legacy_configs::key::BuckconfigKeyRef;
52+
use buck2_core::target::target_configured_target_label::TargetConfiguredTargetLabel;
5253
use buck2_node::execution::{GetExecutionPlatformsImpl, GET_EXECUTION_PLATFORMS, GetExecutionPlatforms, EXECUTION_PLATFORMS_BUCKCONFIG};
54+
use crate::nodes::calculation::ExecutionPlatformConstraints;
5355

5456
#[derive(Debug, buck2_error::Error)]
5557
#[buck2(input)]
@@ -759,6 +761,23 @@ impl GetExecutionPlatformsImpl for GetExecutionPlatformsInstance {
759761
) -> buck2_error::Result<Option<ExecutionPlatforms>> {
760762
ctx.compute(&ExecutionPlatformsKey).await?
761763
}
764+
765+
async fn execution_platform_resolution_one_for_cell(
766+
&self,
767+
dice: &mut DiceComputations<'_>,
768+
exec_deps: Arc<[TargetLabel]>,
769+
toolchain_deps: Arc<[TargetConfiguredTargetLabel]>,
770+
exec_compatible_with: Arc<[ConfigurationSettingKey]>,
771+
cell: CellName,
772+
) -> buck2_error::Result<ExecutionPlatformResolution> {
773+
ExecutionPlatformConstraints::new_constraints(
774+
exec_deps,
775+
toolchain_deps,
776+
exec_compatible_with,
777+
)
778+
.one_for_cell(dice, cell)
779+
.await
780+
}
762781
}
763782

764783
pub(crate) fn init_get_execution_platforms() {

app/buck2_configured/src/nodes/calculation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,14 @@ pub async fn find_execution_platform_by_configuration(
196196
}
197197
}
198198

199-
pub struct ExecutionPlatformConstraints {
199+
pub(crate) struct ExecutionPlatformConstraints {
200200
exec_deps: Arc<[TargetLabel]>,
201201
toolchain_deps: Arc<[TargetConfiguredTargetLabel]>,
202202
exec_compatible_with: Arc<[ConfigurationSettingKey]>,
203203
}
204204

205205
impl ExecutionPlatformConstraints {
206-
pub fn new_constraints(
206+
pub(crate) fn new_constraints(
207207
exec_deps: Arc<[TargetLabel]>,
208208
toolchain_deps: Arc<[TargetConfiguredTargetLabel]>,
209209
exec_compatible_with: Arc<[ConfigurationSettingKey]>,
@@ -285,7 +285,7 @@ impl ExecutionPlatformConstraints {
285285
.await
286286
}
287287

288-
pub async fn one_for_cell(
288+
pub(crate) async fn one_for_cell(
289289
self,
290290
ctx: &mut DiceComputations<'_>,
291291
cell: CellName,

app/buck2_node/src/execution.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,20 @@
77
* of this source tree.
88
*/
99

10+
use std::sync::Arc;
11+
1012
use async_trait::async_trait;
1113
use buck2_common::legacy_configs::key::BuckconfigKeyRef;
14+
use buck2_core::cells::name::CellName;
15+
use buck2_core::execution_types::execution::ExecutionPlatformResolution;
1216
use buck2_core::execution_types::execution_platforms::ExecutionPlatforms;
17+
use buck2_core::target::label::label::TargetLabel;
18+
use buck2_core::target::target_configured_target_label::TargetConfiguredTargetLabel;
1319
use buck2_util::late_binding::LateBinding;
1420
use dice::DiceComputations;
1521

22+
use crate::configuration::resolved::ConfigurationSettingKey;
23+
1624
pub const EXECUTION_PLATFORMS_BUCKCONFIG: BuckconfigKeyRef = BuckconfigKeyRef {
1725
section: "build",
1826
property: "execution_platforms",
@@ -24,6 +32,15 @@ pub trait GetExecutionPlatformsImpl: 'static + Send + Sync {
2432
&self,
2533
dice_computations: &mut DiceComputations<'_>,
2634
) -> buck2_error::Result<Option<ExecutionPlatforms>>;
35+
36+
async fn execution_platform_resolution_one_for_cell(
37+
&self,
38+
dice: &mut DiceComputations<'_>,
39+
exec_deps: Arc<[TargetLabel]>,
40+
toolchain_deps: Arc<[TargetConfiguredTargetLabel]>,
41+
exec_compatible_with: Arc<[ConfigurationSettingKey]>,
42+
cell: CellName,
43+
) -> buck2_error::Result<ExecutionPlatformResolution>;
2744
}
2845

2946
pub static GET_EXECUTION_PLATFORMS: LateBinding<&'static dyn GetExecutionPlatformsImpl> =

0 commit comments

Comments
 (0)