aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java
diff options
context:
space:
mode:
authorGravatar janakr <janakr@google.com>2018-01-18 07:45:12 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-01-18 07:47:19 -0800
commitf3e6f251d3823a826918ad762d1f69f84030ef8c (patch)
tree6913889c0eeb17dcc51d81faf871abde9ea69c93 /src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java
parentaad6304ad938cae6010c1d58f01d92a12a81ac1a (diff)
Start the process of getting Target out of ConfiguredTarget: add a new container, ConfiguredTargetAndTarget, that can be used to access Targets, and deprecate ConfiguredTarget#getTarget. ConfiguredAndTargetObjects are intended to be limited in scope, not being persisted to Skyframe.
The eventual plan is to remove the target field from ConfiguredTarget. This CL is mostly straightforward, except for dealing with AliasConfiguredTargets, which cause some complications. A significant cleanup is still needed before #getTarget can be removed, but I don't see any impossible blockers. We will may still need to store a Target-like object in ConfiguredTarget (that has the RuleClass, or at least a string representation of it, for instance), but that will let us avoid storing a full Target together with its associated Package. PiperOrigin-RevId: 182371566
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java43
1 files changed, 31 insertions, 12 deletions
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 56599c1ab8..630830dfd1 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
@@ -45,6 +45,7 @@ import com.google.devtools.build.lib.packages.AspectDescriptor;
import com.google.devtools.build.lib.packages.Attribute;
import com.google.devtools.build.lib.packages.BuildFileContainsErrorsException;
import com.google.devtools.build.lib.packages.NativeAspectClass;
+import com.google.devtools.build.lib.packages.NoSuchTargetException;
import com.google.devtools.build.lib.packages.NoSuchThingException;
import com.google.devtools.build.lib.packages.Package;
import com.google.devtools.build.lib.packages.RuleClassProvider;
@@ -244,13 +245,24 @@ public final class AspectFunction implements SkyFunction {
ConfiguredTarget associatedTarget = configuredTargetValue.getConfiguredTarget();
- Target target = associatedTarget.getTarget();
+ ConfiguredTargetAndTarget associatedConfiguredTargetAndTarget;
+ Package targetPkg =
+ ((PackageValue)
+ env.getValue(PackageValue.key(associatedTarget.getLabel().getPackageIdentifier())))
+ .getPackage();
+ try {
+ associatedConfiguredTargetAndTarget =
+ new ConfiguredTargetAndTarget(
+ associatedTarget, targetPkg.getTarget(associatedTarget.getLabel().getName()));
+ } catch (NoSuchTargetException e) {
+ throw new IllegalStateException("Name already verified", e);
+ }
if (configuredTargetValue.getConfiguredTarget().getProvider(AliasProvider.class) != null) {
return createAliasAspect(
env,
view.getActionKeyContext(),
- target,
+ associatedConfiguredTargetAndTarget.getTarget(),
aspect,
key,
configuredTargetValue.getConfiguredTarget());
@@ -286,6 +298,8 @@ public final class AspectFunction implements SkyFunction {
}
}
+ associatedConfiguredTargetAndTarget =
+ associatedConfiguredTargetAndTarget.fromConfiguredTarget(associatedTarget);
aspectPathBuilder.add(aspect);
SkyframeDependencyResolver resolver = view.createDependencyResolver(env);
@@ -299,13 +313,14 @@ public final class AspectFunction implements SkyFunction {
// required by all dependencies (both those of the aspect and those of the base target)
// will be present this way.
TargetAndConfiguration originalTargetAndAspectConfiguration =
- new TargetAndConfiguration(target, key.getAspectConfiguration());
+ new TargetAndConfiguration(
+ associatedConfiguredTargetAndTarget.getTarget(), key.getAspectConfiguration());
ImmutableList<Aspect> aspectPath = aspectPathBuilder.build();
try {
// Get the configuration targets that trigger this rule's configurable attributes.
ImmutableMap<Label, ConfigMatchingProvider> configConditions =
ConfiguredTargetFunction.getConfigConditions(
- target,
+ associatedConfiguredTargetAndTarget.getTarget(),
env,
resolver,
originalTargetAndAspectConfiguration,
@@ -325,7 +340,8 @@ public final class AspectFunction implements SkyFunction {
env,
String.format(
"aspect %s applied to %s",
- aspect.getDescriptor().getDescription(), target.toString()),
+ aspect.getDescriptor().getDescription(),
+ associatedConfiguredTargetAndTarget.getTarget().toString()),
requiredToolchains,
key.getAspectConfiguration());
} catch (ToolchainContextException e) {
@@ -336,7 +352,7 @@ public final class AspectFunction implements SkyFunction {
return null;
}
- OrderedSetMultimap<Attribute, ConfiguredTarget> depValueMap;
+ OrderedSetMultimap<Attribute, ConfiguredTargetAndTarget> depValueMap;
try {
depValueMap =
ConfiguredTargetFunction.computeDependencies(
@@ -368,7 +384,7 @@ public final class AspectFunction implements SkyFunction {
aspectPath,
aspect,
aspectFactory,
- associatedTarget,
+ associatedConfiguredTargetAndTarget,
key.getAspectConfiguration(),
configConditions,
toolchainContext,
@@ -496,11 +512,11 @@ public final class AspectFunction implements SkyFunction {
ImmutableList<Aspect> aspectPath,
Aspect aspect,
ConfiguredAspectFactory aspectFactory,
- ConfiguredTarget associatedTarget,
+ ConfiguredTargetAndTarget associatedTarget,
BuildConfiguration aspectConfiguration,
ImmutableMap<Label, ConfigMatchingProvider> configConditions,
ToolchainContext toolchainContext,
- OrderedSetMultimap<Attribute, ConfiguredTarget> directDeps,
+ OrderedSetMultimap<Attribute, ConfiguredTargetAndTarget> directDeps,
@Nullable NestedSetBuilder<Package> transitivePackagesForPackageRootResolution)
throws AspectFunctionException, InterruptedException {
@@ -540,8 +556,11 @@ public final class AspectFunction implements SkyFunction {
events.replayOn(env.getListener());
if (events.hasErrors()) {
analysisEnvironment.disable(associatedTarget.getTarget());
- throw new AspectFunctionException(new AspectCreationException(
- "Analysis of target '" + associatedTarget.getLabel() + "' failed; build aborted"));
+ throw new AspectFunctionException(
+ new AspectCreationException(
+ "Analysis of target '"
+ + associatedTarget.getTarget().getLabel()
+ + "' failed; build aborted"));
}
Preconditions.checkState(!analysisEnvironment.hasErrors(),
"Analysis environment hasError() but no errors reported");
@@ -556,7 +575,7 @@ public final class AspectFunction implements SkyFunction {
return new AspectValue(
key,
aspect,
- associatedTarget.getLabel(),
+ associatedTarget.getTarget().getLabel(),
associatedTarget.getTarget().getLocation(),
configuredAspect,
actionKeyContext,