From 7cb66de14a94fe18a69a25327ab4f758f2a55a54 Mon Sep 17 00:00:00 2001 From: Ulf Adams Date: Thu, 14 Jan 2016 08:46:43 +0000 Subject: Remove some dead code. The ConfiguredTargetFunction can only throw a NoSuch{Target,Package}Exception if it's run for a non-existent target. However, it will never request a CT for a non-existent target: all labels are run through DependencyResolver in order to determine the configuration transition, which requires loading the target. If it doesn't exist, the label is never returned from the DependencyResolver, and errors are swallowed (we rely on the loading phase to report the error). -- MOS_MIGRATED_REVID=112127012 --- .../lib/skyframe/ConfiguredTargetFunction.java | 74 ++++------------------ 1 file changed, 13 insertions(+), 61 deletions(-) (limited to 'src/main') 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 9c9e5ac1b0..bd698d9cb8 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 @@ -13,8 +13,6 @@ // limitations under the License. package com.google.devtools.build.lib.skyframe; -import static com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; - import com.google.common.base.Function; import com.google.common.base.Verify; import com.google.common.collect.ArrayListMultimap; @@ -23,6 +21,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.ListMultimap; +import com.google.common.collect.Maps; import com.google.common.collect.Multimap; import com.google.devtools.build.lib.actions.Action; import com.google.devtools.build.lib.actions.Actions; @@ -44,6 +43,7 @@ import com.google.devtools.build.lib.analysis.config.InvalidConfigurationExcepti import com.google.devtools.build.lib.analysis.config.PatchTransition; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; +import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.events.Event; import com.google.devtools.build.lib.events.StoredEventHandler; import com.google.devtools.build.lib.packages.Aspect; @@ -51,7 +51,6 @@ import com.google.devtools.build.lib.packages.AspectDefinition; import com.google.devtools.build.lib.packages.Attribute; import com.google.devtools.build.lib.packages.BuildFileContainsErrorsException; import com.google.devtools.build.lib.packages.BuildType; -import com.google.devtools.build.lib.packages.NoSuchPackageException; import com.google.devtools.build.lib.packages.NoSuchTargetException; import com.google.devtools.build.lib.packages.NoSuchThingException; import com.google.devtools.build.lib.packages.Package; @@ -70,7 +69,6 @@ import com.google.devtools.build.skyframe.SkyFunctionException.Transience; import com.google.devtools.build.skyframe.SkyKey; import com.google.devtools.build.skyframe.SkyValue; import com.google.devtools.build.skyframe.ValueOrException; -import com.google.devtools.build.skyframe.ValueOrException2; import com.google.devtools.build.skyframe.ValueOrException3; import java.util.Collection; @@ -259,7 +257,7 @@ final class ConfiguredTargetFunction implements SkyFunction { // Resolve configured target dependencies and handle errors. Map depValues = resolveConfiguredTargetDependencies(env, - depValueNames.values(), ctgValue.getTarget(), transitivePackages); + depValueNames.values(), transitivePackages); if (depValues == null) { return null; } @@ -672,8 +670,8 @@ final class ConfiguredTargetFunction implements SkyFunction { configValueNames = staticConfigs.build(); } - Map configValues = - resolveConfiguredTargetDependencies(env, configValueNames, target, transitivePackages); + Map configValues = resolveConfiguredTargetDependencies( + env, configValueNames, transitivePackages); if (configValues == null) { return null; } @@ -698,76 +696,30 @@ final class ConfiguredTargetFunction implements SkyFunction { } /*** - * Resolves the targets referenced in depValueNames and returns their ConfiguredTarget - * instances. + * Resolves the targets referenced in depValueNames and returns their ConfiguredTarget instances. * *

Returns null if not all instances are available yet. - * */ @Nullable private static Map resolveConfiguredTargetDependencies( - Environment env, Collection deps, Target target, - NestedSetBuilder transitivePackages) - throws DependencyEvaluationException { + Environment env, Collection deps, NestedSetBuilder transitivePackages) { boolean ok = !env.valuesMissing(); - String message = null; Iterable depKeys = Iterables.transform(deps, TO_KEYS); - Map> depValuesOrExceptions = env.getValuesOrThrow(depKeys, - NoSuchTargetException.class, NoSuchPackageException.class); - Map depValues = new HashMap<>(depValuesOrExceptions.size()); - SkyKey childKey = null; - NoSuchThingException transitiveChildException = null; - for (Map.Entry> entry - : depValuesOrExceptions.entrySet()) { - ConfiguredTargetKey depKey = (ConfiguredTargetKey) entry.getKey().argument(); - LabelAndConfiguration depLabelAndConfiguration = LabelAndConfiguration.of( - depKey.getLabel(), depKey.getConfiguration()); - Label depLabel = depLabelAndConfiguration.getLabel(); - ConfiguredTargetValue depValue = null; - NoSuchThingException directChildException = null; - try { - depValue = (ConfiguredTargetValue) entry.getValue().get(); - } catch (NoSuchTargetException e) { - if (depLabel.equals(e.getLabel())) { - directChildException = e; - } else { - childKey = entry.getKey(); - transitiveChildException = e; - } - } catch (NoSuchPackageException e) { - if (depLabel.getPackageIdentifier().equals(e.getPackageId())) { - directChildException = e; - } else { - childKey = entry.getKey(); - transitiveChildException = e; - } - } - // If an exception wasn't caused by a direct child target value, we'll treat it the same - // as any other missing dep by setting ok = false below, and returning null at the end. - if (directChildException != null) { - // Only update messages for missing targets we depend on directly. - message = TargetUtils.formatMissingEdge(target, depLabel, directChildException); - env.getListener().handle(Event.error(TargetUtils.getLocationMaybe(target), message)); - } - + Map depValues = env.getValues(depKeys); + Map result = Maps.newHashMapWithExpectedSize(depValues.size()); + for (Map.Entry entry : depValues.entrySet()) { + ConfiguredTargetValue depValue = (ConfiguredTargetValue) entry.getValue(); if (depValue == null) { ok = false; } else { - depValues.put(entry.getKey(), depValue.getConfiguredTarget()); + result.put(entry.getKey(), depValue.getConfiguredTarget()); transitivePackages.addTransitive(depValue.getTransitivePackages()); } } - if (message != null) { - throw new DependencyEvaluationException(new NoSuchTargetException(message)); - } - if (childKey != null) { - throw new DependencyEvaluationException(childKey, transitiveChildException); - } if (!ok) { return null; } else { - return depValues; + return result; } } -- cgit v1.2.3