From 0df1851f0759279d84c79ea6731552437c95ce65 Mon Sep 17 00:00:00 2001 From: Brentley Jones Date: Wed, 9 Feb 2022 08:27:09 -0600 Subject: [PATCH] Support select() on constraint_value for aliases. (#14754) This implements approach #4 of https://github.com/bazelbuild/bazel/issues/13047#issuecomment-805309450. The basic change adds a new toolchain resolution mode: "resolve iff the target has a select()". It then sets alias() to that mode. We could remove this special casing if we ever ubiquitously provide platform info to *all* rules (https://github.com/bazelbuild/bazel/issues/12899#issuecomment-767759147). RELNOTES: alias() can now select() directly on constraint_value() Fixes https://github.com/bazelbuild/bazel/issues/13047. Closes #14310. PiperOrigin-RevId: 411868223 (cherry picked from commit 1c3a2456c95fd19974a5b2bd33c5ebdb2b2277e4) Co-authored-by: Greg Estren --- .../devtools/build/lib/packages/Rule.java | 26 +++++++++++ .../build/lib/packages/RuleClass.java | 30 +++++++++++-- .../cquery/ConfiguredTargetAccessor.java | 2 +- .../devtools/build/lib/rules/Alias.java | 5 ++- .../skyframe/ConfiguredTargetFunction.java | 2 +- .../lib/skyframe/PlatformLookupUtil.java | 12 +++--- .../analysis/ConfigurableAttributesTest.java | 43 +++++++++++++++++++ .../ProtoOutputFormatterCallbackTest.java | 4 +- 8 files changed, 111 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/packages/Rule.java b/src/main/java/com/google/devtools/build/lib/packages/Rule.java index 1c9ba345b37619..59598f282b89e2 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/Rule.java +++ b/src/main/java/com/google/devtools/build/lib/packages/Rule.java @@ -35,6 +35,7 @@ import com.google.devtools.build.lib.packages.ImplicitOutputsFunction.StarlarkImplicitOutputsFunction; import com.google.devtools.build.lib.packages.License.DistributionType; import com.google.devtools.build.lib.packages.Package.ConfigSettingVisibilityPolicy; +import com.google.devtools.build.lib.packages.RuleClass.ToolchainResolutionMode; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -942,6 +943,31 @@ public Collection