From 64843736578cb4a77eb0bb6b2d9473f3675818b4 Mon Sep 17 00:00:00 2001 From: John Cater Date: Mon, 28 Feb 2022 15:58:45 -0800 Subject: [PATCH] Update RuleClass to use ToolchainTypeRequirement. A future change will update rules. Part of Optional Toolchains (#14726). Closes #14862. PiperOrigin-RevId: 431546477 --- .../build/lib/packages/RuleClass.java | 47 ++++++++--- .../google/devtools/build/lib/query2/BUILD | 1 + .../cquery/ConfiguredTargetAccessor.java | 6 +- .../skyframe/ConfiguredTargetFunction.java | 9 +- .../lib/skyframe/ToolchainContextKey.java | 15 ---- .../devtools/build/lib/analysis/testing/BUILD | 2 + .../analysis/testing/RuleClassSubject.java | 83 +++++++++++++++++++ .../lib/packages/RuleClassBuilderTest.java | 17 ++-- .../build/lib/packages/RuleClassTest.java | 17 ++-- .../devtools/build/lib/query2/testutil/BUILD | 1 + .../testutil/PostAnalysisQueryTest.java | 6 +- .../StarlarkRuleClassFunctionsTest.java | 6 +- .../google/devtools/build/lib/testutil/BUILD | 1 + .../lib/testutil/TestRuleClassProvider.java | 7 +- 14 files changed, 163 insertions(+), 55 deletions(-) create mode 100644 src/test/java/com/google/devtools/build/lib/analysis/testing/RuleClassSubject.java diff --git a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java index f1e9f524f72750..a21517a2421b4a 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java +++ b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java @@ -35,6 +35,7 @@ import com.google.common.collect.Maps; import com.google.common.collect.Ordering; import com.google.devtools.build.lib.analysis.config.Fragment; +import com.google.devtools.build.lib.analysis.config.ToolchainTypeRequirement; import com.google.devtools.build.lib.analysis.config.transitions.ConfigurationTransition; import com.google.devtools.build.lib.analysis.config.transitions.PatchTransition; import com.google.devtools.build.lib.analysis.config.transitions.SplitTransition; @@ -74,6 +75,7 @@ import java.util.Objects; import java.util.Set; import java.util.regex.Pattern; +import java.util.stream.Collectors; import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; import net.starlark.java.eval.EvalException; @@ -831,7 +833,7 @@ public enum ThirdPartyLicenseExistencePolicy { private ThirdPartyLicenseExistencePolicy thirdPartyLicenseExistencePolicy; private final Map attributes = new LinkedHashMap<>(); - private final Set