From ceddfb1ece1f8ed7ff81558fa1751e6526df031b Mon Sep 17 00:00:00 2001 From: Googler Date: Fri, 18 Aug 2023 15:25:03 -0700 Subject: [PATCH] Enable rule transition to inspect configurable attributes' value Fixes https://github.com/bazelbuild/bazel/issues/15157 PiperOrigin-RevId: 558262406 Change-Id: I514c95c0470a2d171a5b276f25b65a4adddf17e9 --- .../config/BuildConfigurationValue.java | 2 +- .../config/ConfigMatchingProvider.java | 6 +- .../config/RequiredFragmentsUtil.java | 11 +- .../StarlarkDefinedConfigTransition.java | 8 +- .../build/lib/analysis/producers/BUILD | 7 +- .../producers/ConfigConditionsProducer.java | 26 +- .../producers/DependencyContextProducer.java | 9 +- ...ContextProducerWithCompatibilityCheck.java | 8 +- .../producers/DependencyProducer.java | 3 +- .../producers/PrerequisitesProducer.java | 1 + .../TargetAndConfigurationProducer.java | 303 +++++++++++++++++- .../StarlarkRuleTransitionProvider.java | 71 +++- .../google/devtools/build/lib/packages/BUILD | 1 + .../lib/packages/RuleTransitionData.java | 14 +- .../TransitionsOutputFormatterCallback.java | 6 +- .../build/lib/skyframe/AspectFunction.java | 1 + .../google/devtools/build/lib/skyframe/BUILD | 3 +- .../ConfiguredTargetEvaluationExceptions.java | 1 + .../skyframe/ConfiguredTargetFunction.java | 18 +- .../ConfiguredValueCreationException.java | 58 +++- .../lib/skyframe/DependencyResolver.java | 43 ++- .../build/lib/skyframe/toolchains/BUILD | 5 + .../toolchains/ToolchainException.java | 38 ++- .../StarlarkRuleTransitionProviderTest.java | 8 +- ...onfigFeatureFlagTransitionFactoryTest.java | 32 +- .../config/FeatureFlagManualTrimmingTest.java | 2 +- .../skyframe/SkyframeErrorProcessorTest.java | 5 +- .../shell/integration/rule_transition_test.sh | 278 ++++++++++++++++ src/test/shell/integration/toolchain_test.sh | 7 +- 29 files changed, 862 insertions(+), 113 deletions(-) create mode 100755 src/test/shell/integration/rule_transition_test.sh diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationValue.java b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationValue.java index 4055f149704521..c18e4168b96211 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationValue.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationValue.java @@ -906,7 +906,7 @@ public ImmutableCollection getStarlarkFragmentNames() { return starlarkVisibleFragments.keySet(); } - private BuildEventId getEventId() { + public BuildEventId getEventId() { return BuildEventIdUtil.configurationId(checksum()); } diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigMatchingProvider.java b/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigMatchingProvider.java index 8a6a0a6037a9f5..b8878b480a79e2 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigMatchingProvider.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigMatchingProvider.java @@ -58,11 +58,11 @@ public static ConfigMatchingProvider create( /** The target's label. */ public abstract Label label(); - abstract ImmutableMultimap settingsMap(); + public abstract ImmutableMultimap settingsMap(); - abstract ImmutableMap flagSettingsMap(); + public abstract ImmutableMap flagSettingsMap(); - abstract ImmutableSet