diff options
author | 2016-11-15 13:22:36 +0000 | |
---|---|---|
committer | 2016-11-15 15:59:21 +0000 | |
commit | ca9bfa433a549a0828d0c711786217983c82f455 (patch) | |
tree | 4f6c47c5c5ad32606ca6b85f49a209c65bd63f47 /src/main/java/com/google/devtools/build/lib/skyframe/AspectValue.java | |
parent | 06662fe14ce23261bebd9f67df1976f7c2ed9f9d (diff) |
Aspects-on-aspects implementation.
--
MOS_MIGRATED_REVID=139189444
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/AspectValue.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/AspectValue.java | 77 |
1 files changed, 51 insertions, 26 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/AspectValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/AspectValue.java index 2db8a4d907..1d3b0fd44f 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/AspectValue.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/AspectValue.java @@ -16,6 +16,7 @@ package com.google.devtools.build.lib.skyframe; import com.google.common.base.Objects; import com.google.devtools.build.lib.actions.ActionAnalysisMetadata; +import com.google.devtools.build.lib.analysis.AspectDescriptor; import com.google.devtools.build.lib.analysis.ConfiguredAspect; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.cmdline.Label; @@ -27,7 +28,6 @@ import com.google.devtools.build.lib.packages.AspectParameters; import com.google.devtools.build.lib.packages.Package; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.skyframe.SkyFunctionName; -import com.google.devtools.build.skyframe.SkyKey; import javax.annotation.Nullable; @@ -40,7 +40,6 @@ public final class AspectValue extends ActionLookupValue { * A base class for keys that have AspectValue as a Sky value. */ public abstract static class AspectValueKey extends ActionLookupKey { - public abstract String getDescription(); } @@ -49,17 +48,19 @@ public final class AspectValue extends ActionLookupValue { */ public static final class AspectKey extends AspectValueKey { private final Label label; + private final AspectKey baseKey; private final BuildConfiguration aspectConfiguration; private final BuildConfiguration baseConfiguration; private final AspectClass aspectClass; private final AspectParameters parameters; - protected AspectKey( + private AspectKey( Label label, BuildConfiguration aspectConfiguration, BuildConfiguration baseConfiguration, AspectClass aspectClass, AspectParameters parameters) { + this.baseKey = null; this.label = label; this.aspectConfiguration = aspectConfiguration; this.baseConfiguration = baseConfiguration; @@ -67,6 +68,18 @@ public final class AspectValue extends ActionLookupValue { this.parameters = parameters; } + private AspectKey( + AspectKey baseKey, + AspectClass aspectClass, AspectParameters aspectParameters, + BuildConfiguration aspectConfiguration) { + this.baseKey = baseKey; + this.label = baseKey.label; + this.baseConfiguration = baseKey.getBaseConfiguration(); + this.aspectConfiguration = aspectConfiguration; + this.aspectClass = aspectClass; + this.parameters = aspectParameters; + } + @Override SkyFunctionName getType() { return SkyFunctions.ASPECT; @@ -87,9 +100,18 @@ public final class AspectValue extends ActionLookupValue { return parameters; } + @Nullable + public AspectKey getBaseKey() { + return baseKey; + } + @Override public String getDescription() { - return String.format("%s of %s", aspectClass.getName(), getLabel()); + if (baseKey == null) { + return String.format("%s of %s", aspectClass.getName(), getLabel()); + } else { + return String.format("%s on top of %s", aspectClass.getName(), baseKey.toString()); + } } /** @@ -132,6 +154,7 @@ public final class AspectValue extends ActionLookupValue { public int hashCode() { return Objects.hashCode( label, + baseKey, aspectConfiguration, baseConfiguration, aspectClass, @@ -150,6 +173,7 @@ public final class AspectValue extends ActionLookupValue { AspectKey that = (AspectKey) other; return Objects.equal(label, that.label) + && Objects.equal(baseKey, that.baseKey) && Objects.equal(aspectConfiguration, that.aspectConfiguration) && Objects.equal(baseConfiguration, that.baseConfiguration) && Objects.equal(aspectClass, that.aspectClass) @@ -161,7 +185,7 @@ public final class AspectValue extends ActionLookupValue { return "null"; } return String.format("%s with aspect %s%s", - label.toString(), + baseKey == null ? label.toString() : baseKey.prettyPrint(), aspectClass.getName(), (aspectConfiguration != null && aspectConfiguration.isHostConfiguration()) ? "(host) " : ""); @@ -169,7 +193,7 @@ public final class AspectValue extends ActionLookupValue { @Override public String toString() { - return label + return (baseKey == null ? label : baseKey.toString()) + "#" + aspectClass.getName() + " " @@ -179,6 +203,16 @@ public final class AspectValue extends ActionLookupValue { + " " + parameters; } + + public AspectKey withLabel(Label label) { + if (baseKey == null) { + return new AspectKey( + label, aspectConfiguration, baseConfiguration, aspectClass, parameters); + } else { + return new AspectKey( + baseKey.withLabel(label), aspectClass, parameters, aspectConfiguration); + } + } } /** @@ -293,34 +327,25 @@ public final class AspectValue extends ActionLookupValue { return transitivePackages; } - /** - * Constructs a new SkyKey containing an AspectKey. - */ - public static SkyKey key( - Label label, - BuildConfiguration aspectConfiguration, - BuildConfiguration baseConfiguration, - AspectClass aspectFactory, - AspectParameters additionalConfiguration) { - return SkyKey.create( - SkyFunctions.ASPECT, - new AspectKey( - label, aspectConfiguration, baseConfiguration, aspectFactory, additionalConfiguration)); + public static AspectKey createAspectKey(AspectKey baseKey, AspectDescriptor aspectDescriptor, + BuildConfiguration aspectConfiguration) { + return new AspectKey( + baseKey, aspectDescriptor.getAspectClass(), aspectDescriptor.getParameters(), + aspectConfiguration + ); } - public static SkyKey key(AspectValueKey aspectKey) { - return SkyKey.create(aspectKey.getType(), aspectKey); - } public static AspectKey createAspectKey( Label label, - BuildConfiguration aspectConfiguration, - BuildConfiguration baseConfiguration, - AspectClass aspectFactory) { + BuildConfiguration baseConfiguration, AspectDescriptor aspectDescriptor, + BuildConfiguration aspectConfiguration) { return new AspectKey( - label, aspectConfiguration, baseConfiguration, aspectFactory, AspectParameters.EMPTY); + label, aspectConfiguration, baseConfiguration, + aspectDescriptor.getAspectClass(), aspectDescriptor.getParameters()); } + public static SkylarkAspectLoadingKey createSkylarkAspectKey( Label targetLabel, BuildConfiguration aspectConfiguration, |