diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BUILD b/src/main/java/com/google/devtools/build/lib/analysis/BUILD index cd7e478c54c92d..238ed97f1b9044 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/BUILD +++ b/src/main/java/com/google/devtools/build/lib/analysis/BUILD @@ -292,6 +292,7 @@ java_library( ":buildinfo/build_info_key", ":config/build_configuration", ":config/build_options", + ":config/config_conditions", ":config/config_matching_provider", ":config/core_options", ":config/execution_transition_factory", @@ -1596,6 +1597,20 @@ java_library( ], ) +java_library( + name = "config/config_conditions", + srcs = ["config/ConfigConditions.java"], + deps = [ + ":config/config_matching_provider", + ":configured_target", + "//src/main/java/com/google/devtools/build/lib/analysis/platform", + "//src/main/java/com/google/devtools/build/lib/cmdline", + "//src/main/java/com/google/devtools/build/lib/skyframe:configured_target_and_data", + "//third_party:auto_value", + "//third_party:guava", + ], +) + java_library( name = "config/core_option_converters", srcs = ["config/CoreOptionConverters.java"], diff --git a/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredTargetFactory.java b/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredTargetFactory.java index aea0a0a63bb712..2892050bc118df 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredTargetFactory.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredTargetFactory.java @@ -27,7 +27,7 @@ import com.google.devtools.build.lib.actions.MutableActionGraph.ActionConflictException; import com.google.devtools.build.lib.analysis.RuleContext.InvalidExecGroupException; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; -import com.google.devtools.build.lib.analysis.config.ConfigMatchingProvider; +import com.google.devtools.build.lib.analysis.config.ConfigConditions; import com.google.devtools.build.lib.analysis.config.Fragment; import com.google.devtools.build.lib.analysis.config.RequiredFragmentsUtil; import com.google.devtools.build.lib.analysis.configuredtargets.EnvironmentGroupConfiguredTarget; @@ -186,7 +186,7 @@ public final ConfiguredTarget createConfiguredTarget( BuildConfiguration hostConfig, ConfiguredTargetKey configuredTargetKey, OrderedSetMultimap prerequisiteMap, - ImmutableMap configConditions, + ConfigConditions configConditions, @Nullable ToolchainCollection toolchainContexts) throws InterruptedException, ActionConflictException, InvalidExecGroupException { if (target instanceof Rule) { @@ -292,7 +292,7 @@ private ConfiguredTarget createRule( BuildConfiguration hostConfiguration, ConfiguredTargetKey configuredTargetKey, OrderedSetMultimap prerequisiteMap, - ImmutableMap configConditions, + ConfigConditions configConditions, @Nullable ToolchainCollection toolchainContexts) throws InterruptedException, ActionConflictException, InvalidExecGroupException { ConfigurationFragmentPolicy configurationFragmentPolicy = @@ -323,7 +323,7 @@ private ConfiguredTarget createRule( configuration, ruleClassProvider.getUniversalFragments(), configurationFragmentPolicy, - configConditions, + configConditions.asProviders(), prerequisiteMap.values())) .build(); @@ -500,7 +500,7 @@ public ConfiguredAspect createAspect( ConfiguredAspectFactory aspectFactory, Aspect aspect, OrderedSetMultimap prerequisiteMap, - ImmutableMap configConditions, + ConfigConditions configConditions, @Nullable ResolvedToolchainContext toolchainContext, BuildConfiguration aspectConfiguration, BuildConfiguration hostConfiguration, @@ -545,7 +545,7 @@ public ConfiguredAspect createAspect( aspectConfiguration, ruleClassProvider.getUniversalFragments(), aspect.getDefinition().getConfigurationFragmentPolicy(), - configConditions, + configConditions.asProviders(), prerequisiteMap.values())) .build(); diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java index 27913ecfa63650..792bef339d4b13 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java @@ -46,6 +46,7 @@ import com.google.devtools.build.lib.analysis.actions.ActionConstructionContext; import com.google.devtools.build.lib.analysis.buildinfo.BuildInfoKey; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; +import com.google.devtools.build.lib.analysis.config.ConfigConditions; import com.google.devtools.build.lib.analysis.config.ConfigMatchingProvider; import com.google.devtools.build.lib.analysis.config.CoreOptions; import com.google.devtools.build.lib.analysis.config.CoreOptions.IncludeConfigFragmentsEnum; @@ -1764,7 +1765,7 @@ public static final class Builder implements RuleErrorConsumer { private final PrerequisiteValidator prerequisiteValidator; private final RuleErrorConsumer reporter; private OrderedSetMultimap prerequisiteMap; - private ImmutableMap configConditions = ImmutableMap.of(); + private ConfigConditions configConditions; private String toolsRepository; private StarlarkSemantics starlarkSemantics; private Mutability mutability; @@ -1813,11 +1814,15 @@ public RuleContext build() throws InvalidExecGroupException { Preconditions.checkNotNull(visibility); Preconditions.checkNotNull(constraintSemantics); AttributeMap attributes = - ConfiguredAttributeMapper.of(target.getAssociatedRule(), configConditions); + ConfiguredAttributeMapper.of(target.getAssociatedRule(), configConditions.asProviders()); checkAttributesNonEmpty(attributes); ListMultimap targetMap = createTargetMap(); + Attribute configSettingAttr = attributes.getAttributeDefinition("$config_dependencies"); + for (ConfiguredTargetAndData condition : configConditions.asConfiguredTargets().values()) { + validateDirectPrerequisite(configSettingAttr, condition); + } ListMultimap filesetEntryMap = - createFilesetEntryMap(target.getAssociatedRule(), configConditions); + createFilesetEntryMap(target.getAssociatedRule(), configConditions.asProviders()); if (rawExecProperties == null) { if (!attributes.has(RuleClass.EXEC_PROPERTIES, Type.STRING_DICT)) { rawExecProperties = ImmutableMap.of(); @@ -1831,7 +1836,7 @@ public RuleContext build() throws InvalidExecGroupException { attributes, targetMap, filesetEntryMap, - configConditions, + configConditions.asProviders(), universalFragments, getRuleClassNameForLogging(), actionOwnerSymbol, @@ -1906,11 +1911,10 @@ public Builder setAspectAttributes(Map aspectAttributes) { } /** - * Sets the configuration conditions needed to determine which paths to follow for this - * rule's configurable attributes. + * Sets the configuration conditions needed to determine which paths to follow for this rule's + * configurable attributes. */ - public Builder setConfigConditions( - ImmutableMap configConditions) { + public Builder setConfigConditions(ConfigConditions configConditions) { this.configConditions = Preconditions.checkNotNull(configConditions); return this; } diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigConditions.java b/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigConditions.java new file mode 100644 index 00000000000000..3228ffb987fee2 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigConditions.java @@ -0,0 +1,81 @@ +// Copyright 2021 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.google.devtools.build.lib.analysis.config; + +import com.google.auto.value.AutoValue; +import com.google.common.collect.ImmutableMap; +import com.google.devtools.build.lib.analysis.ConfiguredTarget; +import com.google.devtools.build.lib.analysis.platform.ConstraintValueInfo; +import com.google.devtools.build.lib.analysis.platform.PlatformInfo; +import com.google.devtools.build.lib.cmdline.Label; +import com.google.devtools.build.lib.skyframe.ConfiguredTargetAndData; + +/** + * Utility class for temporarily tracking {@code select()} keys' {@link ConfigMatchingProvider}s and + * {@link ConfiguredTarget}s. + * + *

This is a utility class because its only purpose is to maintain {@link ConfiguredTarget} long + * enough for {@link RuleContext.Builder} to do prerequisite validation on it (like visibility + * checking). + * + *

Once {@link RuleContext} is instantiated, it should only have access to {@link + * ConfigMatchingProvider}, on the principle that providers are the correct interfaces for storing + * and sharing target metadata. {@link ConfiguredTarget} isn't meant to persist that long. + */ +@AutoValue +public abstract class ConfigConditions { + public abstract ImmutableMap asConfiguredTargets(); + + public abstract ImmutableMap asProviders(); + + public static ConfigConditions create( + ImmutableMap asConfiguredTargets, + ImmutableMap asProviders) { + return new AutoValue_ConfigConditions(asConfiguredTargets, asProviders); + } + + public static ConfigConditions EMPTY = + ConfigConditions.create(ImmutableMap.of(), ImmutableMap.of()); + + /** Exception for when a {@code select()} has an invalid key (like wrong target type). */ + public static class InvalidConditionException extends Exception {} + + /** + * Returns a {@link ConfigMatchingProvider} from the given configured target if appropriate, else + * triggers a {@link InvalidConditionException}. + * + *

This is the canonical place to extract {@link ConfigMatchingProvider}s from configured + * targets. It's not as simple as {@link ConfiguredTarget#getProvider}. + */ + public static ConfigMatchingProvider fromConfiguredTarget( + ConfiguredTargetAndData selectKey, PlatformInfo targetPlatform) + throws InvalidConditionException { + ConfiguredTarget selectable = selectKey.getConfiguredTarget(); + // The below handles config_setting (which natively provides ConfigMatchingProvider) and + // constraint_value (which needs a custom-built ConfigMatchingProvider). + ConfigMatchingProvider matchingProvider = selectable.getProvider(ConfigMatchingProvider.class); + ConstraintValueInfo constraintValueInfo = selectable.get(ConstraintValueInfo.PROVIDER); + if (matchingProvider != null) { + return matchingProvider; + } + if (constraintValueInfo != null && targetPlatform != null) { + // If platformInfo == null, that means the owning target doesn't invoke toolchain + // resolution, in which case depending on a constraint_value is nonsensical. + return constraintValueInfo.configMatchingProvider(targetPlatform); + } + + // Not a valid provider for configuration conditions. + throw new InvalidConditionException(); + } +} diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java index ca082924cec535..385c111eed5343 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java @@ -37,7 +37,7 @@ import com.google.devtools.build.lib.analysis.ToolchainCollection; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.analysis.config.BuildOptions; -import com.google.devtools.build.lib.analysis.config.ConfigMatchingProvider; +import com.google.devtools.build.lib.analysis.config.ConfigConditions; import com.google.devtools.build.lib.analysis.config.DependencyEvaluationException; import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException; import com.google.devtools.build.lib.analysis.configuredtargets.MergedConfiguredTarget; @@ -403,7 +403,7 @@ public SkyValue compute(SkyKey skyKey, Environment env) } // Get the configuration targets that trigger this rule's configurable attributes. - ImmutableMap configConditions = + ConfigConditions configConditions = ConfiguredTargetFunction.getConfigConditions( env, originalTargetAndAspectConfiguration, @@ -423,7 +423,7 @@ public SkyValue compute(SkyKey skyKey, Environment env) resolver, originalTargetAndAspectConfiguration, aspectPath, - configConditions, + configConditions.asProviders(), unloadedToolchainContext == null ? null : ToolchainCollection.builder() @@ -640,7 +640,7 @@ private AspectValue createAspect( ConfiguredAspectFactory aspectFactory, ConfiguredTargetAndData associatedTarget, BuildConfiguration aspectConfiguration, - ImmutableMap configConditions, + ConfigConditions configConditions, ResolvedToolchainContext toolchainContext, OrderedSetMultimap directDeps, @Nullable NestedSetBuilder transitivePackagesForPackageRootResolution) diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/BUILD b/src/main/java/com/google/devtools/build/lib/skyframe/BUILD index 9631f082571b12..5183d7d27783fd 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/BUILD +++ b/src/main/java/com/google/devtools/build/lib/skyframe/BUILD @@ -234,6 +234,7 @@ java_library( "//src/main/java/com/google/devtools/build/lib/analysis:buildinfo/build_info_key", "//src/main/java/com/google/devtools/build/lib/analysis:config/build_configuration", "//src/main/java/com/google/devtools/build/lib/analysis:config/build_options", + "//src/main/java/com/google/devtools/build/lib/analysis:config/config_conditions", "//src/main/java/com/google/devtools/build/lib/analysis:config/config_matching_provider", "//src/main/java/com/google/devtools/build/lib/analysis:config/core_options", "//src/main/java/com/google/devtools/build/lib/analysis:config/fragment", diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java index 84e41d14b50cb5..39beef507dfeea 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java @@ -48,13 +48,13 @@ import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.analysis.config.BuildOptionsView; +import com.google.devtools.build.lib.analysis.config.ConfigConditions; import com.google.devtools.build.lib.analysis.config.ConfigMatchingProvider; import com.google.devtools.build.lib.analysis.config.ConfigurationResolver; import com.google.devtools.build.lib.analysis.config.DependencyEvaluationException; import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException; import com.google.devtools.build.lib.analysis.config.transitions.PatchTransition; import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget; -import com.google.devtools.build.lib.analysis.platform.ConstraintValueInfo; import com.google.devtools.build.lib.analysis.platform.PlatformInfo; import com.google.devtools.build.lib.analysis.starlark.StarlarkTransition.TransitionException; import com.google.devtools.build.lib.causes.AnalysisFailedCause; @@ -116,9 +116,6 @@ public final class ConfiguredTargetFunction implements SkyFunction { private static final GoogleLogger logger = GoogleLogger.forEnclosingClass(); - private static final ImmutableMap NO_CONFIG_CONDITIONS = - ImmutableMap.of(); - /** * Attempt to find a {@link ConfiguredValueCreationException} in a {@link ToolchainException}, or * its causes. @@ -287,7 +284,7 @@ public SkyValue compute(SkyKey key, Environment env) throws ConfiguredTargetFunc } // Get the configuration targets that trigger this rule's configurable attributes. - ImmutableMap configConditions = + ConfigConditions configConditions = getConfigConditions( env, ctgValue, @@ -307,7 +304,7 @@ public SkyValue compute(SkyKey key, Environment env) throws ConfiguredTargetFunc // Note that this doesn't apply to AspectFunction, because aspects can't have configurable // attributes. if (!transitiveRootCauses.isEmpty() - && !Objects.equals(configConditions, NO_CONFIG_CONDITIONS)) { + && !Objects.equals(configConditions, ConfigConditions.EMPTY)) { NestedSet causes = transitiveRootCauses.build(); throw new ConfiguredTargetFunctionException( new ConfiguredValueCreationException( @@ -324,7 +321,7 @@ public SkyValue compute(SkyKey key, Environment env) throws ConfiguredTargetFunc resolver, ctgValue, ImmutableList.of(), - configConditions, + configConditions.asProviders(), unloadedToolchainContexts == null ? null : unloadedToolchainContexts.asToolchainContexts(), @@ -712,14 +709,13 @@ static OrderedSetMultimap computeDepend } /** - * Returns the set of {@link ConfigMatchingProvider}s that key the configurable attributes used by - * this rule. + * Returns the targets that key the configurable attributes used by this rule. * *

>If the configured targets supplying those providers aren't yet resolved by the dependency * resolver, returns null. */ @Nullable - static ImmutableMap getConfigConditions( + static ConfigConditions getConfigConditions( Environment env, TargetAndConfiguration ctgValue, @Nullable NestedSetBuilder transitivePackagesForPackageRootResolution, @@ -728,11 +724,11 @@ static ImmutableMap getConfigConditions( throws DependencyEvaluationException, InterruptedException { Target target = ctgValue.getTarget(); if (!(target instanceof Rule)) { - return NO_CONFIG_CONDITIONS; + return ConfigConditions.EMPTY; } RawAttributeMapper attrs = RawAttributeMapper.of(((Rule) target)); if (!attrs.has(RuleClass.CONFIG_SETTING_DEPS_ATTRIBUTE)) { - return NO_CONFIG_CONDITIONS; + return ConfigConditions.EMPTY; } // Collect the labels of the configured targets we need to resolve. @@ -741,7 +737,7 @@ static ImmutableMap getConfigConditions( .map(configLabel -> target.getLabel().resolveRepositoryRelative(configLabel)) .collect(Collectors.toList()); if (configLabels.isEmpty()) { - return NO_CONFIG_CONDITIONS; + return ConfigConditions.EMPTY; } else if (ctgValue.getConfiguration().trimConfigurationsRetroactively()) { String message = target.getLabel() @@ -795,33 +791,23 @@ static ImmutableMap getConfigConditions( throw e; } - Map configConditions = new LinkedHashMap<>(); + Map asConfiguredTargets = new LinkedHashMap<>(); + Map asConfigConditions = new LinkedHashMap<>(); // Get the configured targets as ConfigMatchingProvider interfaces. for (Dependency entry : configConditionDeps) { SkyKey baseKey = entry.getConfiguredTargetKey(); - // The code above guarantees that value is non-null here. - ConfiguredTarget value = configValues.get(baseKey).getConfiguredTarget(); - // The below handles config_setting (which nativly provides ConfigMatchingProvider) and - // constraint_value (which needs a custom-built ConfigMatchingProvider). If we ever add - // support for more rules we should move resolution logic to ConfigMatchingProvider and - // simplify the logic here. - ConfigMatchingProvider matchingProvider = value.getProvider(ConfigMatchingProvider.class); - ConstraintValueInfo constraintValueInfo = value.get(ConstraintValueInfo.PROVIDER); - - if (matchingProvider != null) { - configConditions.put(entry.getLabel(), matchingProvider); - } else if (constraintValueInfo != null && platformInfo != null) { - // If platformInfo == null, that means the owning target doesn't invoke toolchain - // resolution, in which case depending on a constraint_value is non-sensical. - configConditions.put( - entry.getLabel(), constraintValueInfo.configMatchingProvider(platformInfo)); - } else { - // Not a valid provider for configuration conditions. + // The code above guarantees that selectKeyTarget is non-null here. + ConfiguredTargetAndData selectKeyTarget = configValues.get(baseKey); + asConfiguredTargets.put(entry.getLabel(), selectKeyTarget); + try { + asConfigConditions.put( + entry.getLabel(), ConfigConditions.fromConfiguredTarget(selectKeyTarget, platformInfo)); + } catch (ConfigConditions.InvalidConditionException e) { String message = String.format( "%s is not a valid select() condition for %s.\n", - entry.getLabel(), target.getLabel()) + selectKeyTarget.getTarget().getLabel(), target.getLabel()) + String.format( "To inspect the select(), run: bazel query --output=build %s.\n", target.getLabel()) @@ -833,7 +819,8 @@ static ImmutableMap getConfigConditions( } } - return ImmutableMap.copyOf(configConditions); + return ConfigConditions.create( + ImmutableMap.copyOf(asConfiguredTargets), ImmutableMap.copyOf(asConfigConditions)); } /** @@ -992,7 +979,7 @@ private ConfiguredTargetValue createConfiguredTarget( BuildConfiguration configuration, ConfiguredTargetKey configuredTargetKey, OrderedSetMultimap depValueMap, - ImmutableMap configConditions, + ConfigConditions configConditions, @Nullable ToolchainCollection toolchainContexts, @Nullable NestedSetBuilder transitivePackagesForPackageRootResolution) throws ConfiguredTargetFunctionException, InterruptedException { diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeBuildView.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeBuildView.java index fdc005789aa82c..49a62c03baaa42 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeBuildView.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeBuildView.java @@ -55,7 +55,7 @@ import com.google.devtools.build.lib.analysis.config.BuildConfigurationCollection; import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.analysis.config.BuildOptions.OptionsDiff; -import com.google.devtools.build.lib.analysis.config.ConfigMatchingProvider; +import com.google.devtools.build.lib.analysis.config.ConfigConditions; import com.google.devtools.build.lib.analysis.config.CoreOptions; import com.google.devtools.build.lib.analysis.config.FragmentClassSet; import com.google.devtools.build.lib.bugreport.BugReport; @@ -929,7 +929,7 @@ ConfiguredTarget createConfiguredTarget( CachingAnalysisEnvironment analysisEnvironment, ConfiguredTargetKey configuredTargetKey, OrderedSetMultimap prerequisiteMap, - ImmutableMap configConditions, + ConfigConditions configConditions, @Nullable ToolchainCollection toolchainContexts) throws InterruptedException, ActionConflictException, InvalidExecGroupException { Preconditions.checkState( diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BUILD b/src/test/java/com/google/devtools/build/lib/analysis/util/BUILD index 53ed528afeeb6f..2ec092345d183b 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/BUILD +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BUILD @@ -49,6 +49,7 @@ java_library( "//src/main/java/com/google/devtools/build/lib/analysis:buildinfo/build_info_key", "//src/main/java/com/google/devtools/build/lib/analysis:config/build_configuration", "//src/main/java/com/google/devtools/build/lib/analysis:config/build_options", + "//src/main/java/com/google/devtools/build/lib/analysis:config/config_conditions", "//src/main/java/com/google/devtools/build/lib/analysis:config/config_matching_provider", "//src/main/java/com/google/devtools/build/lib/analysis:config/fragment", "//src/main/java/com/google/devtools/build/lib/analysis:config/fragment_options", diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewForTesting.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewForTesting.java index a71e381ad6b318..8d10729b589a24 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewForTesting.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewForTesting.java @@ -49,6 +49,7 @@ import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.analysis.config.BuildConfigurationCollection; import com.google.devtools.build.lib.analysis.config.BuildOptions; +import com.google.devtools.build.lib.analysis.config.ConfigConditions; import com.google.devtools.build.lib.analysis.config.ConfigMatchingProvider; import com.google.devtools.build.lib.analysis.config.ConfigurationResolver; import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException; @@ -608,7 +609,7 @@ public RuleContext getRuleContextForTesting( .setPrerequisites( ConfiguredTargetFactory.transformPrerequisiteMap( prerequisiteMap, target.getAssociatedRule())) - .setConfigConditions(ImmutableMap.of()) + .setConfigConditions(ConfigConditions.EMPTY) .setUniversalFragments(ruleClassProvider.getUniversalFragments()) .setToolchainContexts(resolvedToolchainContext.build()) .setConstraintSemantics(ruleClassProvider.getConstraintSemantics())