|
49 | 49 | import com.google.devtools.build.lib.query2.query.aspectresolvers.AspectResolver; |
50 | 50 | import com.google.devtools.build.lib.rules.AliasConfiguredTarget; |
51 | 51 | import com.google.devtools.build.lib.server.FailureDetails.ConfigurableQuery; |
| 52 | +import com.google.devtools.build.lib.skyframe.BuildConfigurationKey; |
52 | 53 | import com.google.devtools.build.lib.skyframe.ConfiguredTargetKey; |
53 | 54 | import com.google.devtools.build.lib.skyframe.SkyframeExecutor; |
54 | 55 | import com.google.devtools.build.skyframe.SkyKey; |
|
59 | 60 | import java.util.Collection; |
60 | 61 | import java.util.Comparator; |
61 | 62 | import java.util.List; |
| 63 | +import java.util.Objects; |
62 | 64 | import java.util.Set; |
63 | 65 | import java.util.function.Function; |
64 | 66 | import java.util.function.Supplier; |
@@ -339,14 +341,22 @@ public QueryTaskFuture<Void> getTargetsMatchingPattern( |
339 | 341 | * null. |
340 | 342 | */ |
341 | 343 | @Nullable |
342 | | - private ConfiguredTarget getConfiguredTarget(Label label, BuildConfigurationValue configuration) |
343 | | - throws InterruptedException { |
344 | | - return getValueFromKey( |
345 | | - ConfiguredTargetKey.builder() |
346 | | - .setLabel(label) |
347 | | - .setConfiguration(configuration) |
348 | | - .build() |
349 | | - .toKey()); |
| 344 | + private ConfiguredTarget getConfiguredTarget( |
| 345 | + Label label, @Nullable BuildConfigurationValue configuration) throws InterruptedException { |
| 346 | + BuildConfigurationKey configurationKey = configuration == null ? null : configuration.getKey(); |
| 347 | + ConfiguredTarget target = |
| 348 | + getValueFromKey( |
| 349 | + ConfiguredTargetKey.builder() |
| 350 | + .setLabel(label) |
| 351 | + .setConfigurationKey(configurationKey) |
| 352 | + .build() |
| 353 | + .toKey()); |
| 354 | + // The configurations might not match if the target's configuration changed due to a transition |
| 355 | + // or trimming. Filters such targets. |
| 356 | + if (target == null || !Objects.equals(configurationKey, target.getConfigurationKey())) { |
| 357 | + return null; |
| 358 | + } |
| 359 | + return target; |
350 | 360 | } |
351 | 361 |
|
352 | 362 | @Override |
|
0 commit comments