diff --git a/src/main/java/com/google/devtools/build/lib/analysis/AnalysisResult.java b/src/main/java/com/google/devtools/build/lib/analysis/AnalysisResult.java index c4aedce9ab7525..e7ecc37766aa2c 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/AnalysisResult.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/AnalysisResult.java @@ -33,6 +33,7 @@ public final class AnalysisResult { private final ImmutableSet targetsToBuild; @Nullable private final ImmutableList targetsToTest; private final ImmutableSet targetsToSkip; + private final ImmutableSet targetsToFail; @Nullable private final String error; private final ActionGraph actionGraph; private final ArtifactsToOwnerLabels topLevelArtifactsToOwnerLabels; @@ -51,6 +52,7 @@ public final class AnalysisResult { ImmutableSet aspects, @Nullable ImmutableList targetsToTest, ImmutableSet targetsToSkip, + ImmutableSet targetsToFail, @Nullable String error, ActionGraph actionGraph, ArtifactsToOwnerLabels topLevelArtifactsToOwnerLabels, @@ -66,6 +68,7 @@ public final class AnalysisResult { this.aspects = aspects; this.targetsToTest = targetsToTest; this.targetsToSkip = targetsToSkip; + this.targetsToFail = targetsToFail; this.error = error; this.actionGraph = actionGraph; this.topLevelArtifactsToOwnerLabels = topLevelArtifactsToOwnerLabels; @@ -123,6 +126,14 @@ public ImmutableSet getTargetsToSkip() { return targetsToSkip; } + /** + * Returns the incompatible targets that were explicitly requested on the command line. + */ + // TODO(phil): Document this properly. + public ImmutableSet getTargetsToFail() { + return targetsToFail; + } + public ArtifactsToOwnerLabels getTopLevelArtifactsToOwnerLabels() { return topLevelArtifactsToOwnerLabels; } @@ -180,6 +191,7 @@ public AnalysisResult withExclusiveTestsAsParallelTests() { aspects, targetsToTest, targetsToSkip, + targetsToFail, error, actionGraph, topLevelArtifactsToOwnerLabels, diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BaseRuleClasses.java b/src/main/java/com/google/devtools/build/lib/analysis/BaseRuleClasses.java index b7ffed1e55052a..af8ea819321ab5 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/BaseRuleClasses.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/BaseRuleClasses.java @@ -34,6 +34,7 @@ import com.google.devtools.build.lib.analysis.config.HostTransition; import com.google.devtools.build.lib.analysis.config.RunUnder; import com.google.devtools.build.lib.analysis.constraints.EnvironmentRule; +import com.google.devtools.build.lib.analysis.platform.ConstraintValueInfo; import com.google.devtools.build.lib.analysis.test.TestConfiguration; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.packages.Attribute; @@ -329,6 +330,15 @@ public static RuleClass.Builder commonCoreAndSkylarkAttributes(RuleClass.Builder .dontCheckConstraints() .nonconfigurable( "special logic for constraints and select: see ConstraintSemantics")) + /* + A list of constraint_values that must be satisfied by the target platform in + order for this toolchain to be selected for a target building for that platform. + */ + .add( + attr("target_compatible_with", LABEL_LIST) + .mandatoryProviders(ConstraintValueInfo.PROVIDER.id()) + .allowedFileTypes() + .nonconfigurable("Logic for target compatibility")) .add( attr(RuleClass.CONFIG_SETTING_DEPS_ATTRIBUTE, LABEL_LIST) .nonconfigurable("stores configurability keys")) diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java index f2ff1980590576..1f025322f6350e 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java @@ -206,6 +206,7 @@ public AnalysisResult update( TargetPatternPhaseValue loadingResult, BuildOptions targetOptions, Set multiCpu, + List requestedTargets, List aspects, AnalysisOptions viewOptions, boolean keepGoing, @@ -388,18 +389,18 @@ public AnalysisResult update( getArtifactFactory().noteAnalysisStarting(); SkyframeAnalysisResult skyframeAnalysisResult; - try { - Supplier> configurationLookupSupplier = - () -> { - Map result = new HashMap<>(); - for (TargetAndConfiguration node : topLevelTargetsWithConfigs) { - if (node.getConfiguration() != null) { - result.put( - BuildConfigurationValue.key(node.getConfiguration()), node.getConfiguration()); - } + Supplier> configurationLookupSupplier = + () -> { + Map result = new HashMap<>(); + for (TargetAndConfiguration node : topLevelTargetsWithConfigs) { + if (node.getConfiguration() != null) { + result.put( + BuildConfigurationValue.key(node.getConfiguration()), node.getConfiguration()); } - return result; - }; + } + return result; + }; + try { skyframeAnalysisResult = skyframeBuildView.configureTargets( eventHandler, @@ -425,10 +426,16 @@ public AnalysisResult update( Set targetsToSkip = new TopLevelConstraintSemantics( + skyframeBuildView, skyframeExecutor.getPackageManager(), input -> skyframeExecutor.getConfiguration(eventHandler, input), eventHandler) - .checkTargetEnvironmentRestrictions(skyframeAnalysisResult.getConfiguredTargets()); + .checkTargetEnvironmentRestrictions( + configurationLookupSupplier, + keepGoing, + loadingPhaseThreads, + eventBus, + skyframeAnalysisResult.getConfiguredTargets()); AnalysisResult result = createResult( @@ -440,6 +447,7 @@ public AnalysisResult update( viewOptions, skyframeAnalysisResult, targetsToSkip, + requestedTargets, topLevelTargetsWithConfigsResult); logger.atInfo().log("Finished analysis"); return result; @@ -454,6 +462,7 @@ private AnalysisResult createResult( AnalysisOptions viewOptions, SkyframeAnalysisResult skyframeAnalysisResult, Set targetsToSkip, + List requestedTargets, TopLevelTargetsAndConfigsResult topLevelTargetsWithConfigs) throws InterruptedException { Set