aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/skyframe/AspectValue.java
diff options
context:
space:
mode:
authorGravatar Dmitry Lomov <dslomov@google.com>2015-10-30 15:50:01 +0000
committerGravatar Florian Weikert <fwe@google.com>2015-11-02 16:53:19 +0000
commitc15ba2e54d0e17fe894bfeadb21228e0a76e9e40 (patch)
treed555d4802586c654771f646d2a04e11d3385256f /src/main/java/com/google/devtools/build/lib/skyframe/AspectValue.java
parent1b175c478156b20c7e1a77200a5e7717a945d9f2 (diff)
Implement propagation along dependencies for Skylark aspects.
-- MOS_MIGRATED_REVID=106694515
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.java122
1 files changed, 61 insertions, 61 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 336056fad1..318b6683be 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
@@ -15,7 +15,6 @@
package com.google.devtools.build.lib.skyframe;
import com.google.common.base.Objects;
-import com.google.common.base.Preconditions;
import com.google.devtools.build.lib.actions.Action;
import com.google.devtools.build.lib.analysis.Aspect;
import com.google.devtools.build.lib.analysis.AspectWithParameters;
@@ -38,65 +37,59 @@ import javax.annotation.Nullable;
public final class AspectValue extends ActionLookupValue {
/**
- * A base class for a key representing an aspect applied to a particular target.
+ * A base class for keys that have AspectValue as a Sky value.
*/
- public abstract static class AspectKey extends ActionLookupKey {
- protected final Label label;
- protected final BuildConfiguration configuration;
-
- protected AspectKey(Label label, BuildConfiguration configuration) {
- this.label = label;
- this.configuration = configuration;
- }
-
- @Override
- public Label getLabel() {
- return label;
- }
-
- public abstract AspectParameters getParameters();
+ public abstract static class AspectValueKey extends ActionLookupKey {
public abstract String getDescription();
-
- public BuildConfiguration getConfiguration() {
- return configuration;
- }
}
/**
- * The key of an action that is generated by a native aspect.
+ * A base class for a key representing an aspect applied to a particular target.
*/
- public static final class NativeAspectKey extends AspectKey {
+ public static final class AspectKey extends AspectValueKey {
+ private final Label label;
+ private final BuildConfiguration configuration;
private final AspectWithParameters aspect;
+ private final String aspectName;
- private NativeAspectKey(
+ protected AspectKey(
Label label,
BuildConfiguration configuration,
- AspectClass aspectClass ,
+ AspectClass aspectClass,
AspectParameters parameters) {
- super(label, configuration);
- Preconditions.checkNotNull(parameters);
+ this.label = label;
+ this.configuration = configuration;
+ this.aspectName = aspectClass.getName();
this.aspect = new AspectWithParameters(aspectClass, parameters);
}
+ @Override
+ SkyFunctionName getType() {
+ return SkyFunctions.ASPECT;
+ }
+
+
+ @Override
+ public Label getLabel() {
+ return label;
+ }
+
public AspectClass getAspect() {
return aspect.getAspectClass();
}
- @Override
@Nullable
public AspectParameters getParameters() {
return aspect.getParameters();
}
- @Override
public String getDescription() {
return String.format("%s of %s", aspect.getAspectClass().getName(), getLabel());
}
- @Override
- SkyFunctionName getType() {
- return SkyFunctions.NATIVE_ASPECT;
+ public BuildConfiguration getConfiguration() {
+ return configuration;
}
@Override
@@ -110,11 +103,11 @@ public final class AspectValue extends ActionLookupValue {
return true;
}
- if (!(other instanceof NativeAspectKey)) {
+ if (!(other instanceof AspectKey)) {
return false;
}
- NativeAspectKey that = (NativeAspectKey) other;
+ AspectKey that = (AspectKey) other;
return Objects.equal(label, that.label)
&& Objects.equal(configuration, that.configuration)
&& Objects.equal(aspect, that.aspect);
@@ -129,20 +122,30 @@ public final class AspectValue extends ActionLookupValue {
}
/**
- * The key of an action that is generated by a skylark aspect.
+ * The key for a skylark aspect.
*/
- public static class SkylarkAspectKey extends AspectKey {
+ public static class SkylarkAspectLoadingKey extends AspectValueKey {
+
+ private final Label targetLabel;
+ private final BuildConfiguration targetConfiguration;
private final PackageIdentifier extensionFile;
- private final String skylarkFunctionName;
+ private final String skylarkValueName;
- private SkylarkAspectKey(
+ private SkylarkAspectLoadingKey(
Label targetLabel,
BuildConfiguration targetConfiguration,
PackageIdentifier extensionFile,
String skylarkFunctionName) {
- super(targetLabel, targetConfiguration);
+ this.targetLabel = targetLabel;
+ this.targetConfiguration = targetConfiguration;
+
this.extensionFile = extensionFile;
- this.skylarkFunctionName = skylarkFunctionName;
+ this.skylarkValueName = skylarkFunctionName;
+ }
+
+ @Override
+ SkyFunctionName getType() {
+ return SkyFunctions.LOAD_SKYLARK_ASPECT;
}
public PackageIdentifier getExtensionFile() {
@@ -150,24 +153,20 @@ public final class AspectValue extends ActionLookupValue {
}
public String getSkylarkValueName() {
- return skylarkFunctionName;
+ return skylarkValueName;
}
- @Override
- public AspectParameters getParameters() {
- return AspectParameters.EMPTY;
+ public Label getTargetLabel() {
+ return targetLabel;
}
- @Override
- public String getDescription() {
- // Skylark aspects are referred to on command line with <file>%<value name>
- return String.format(
- "%s%%%s of %s", extensionFile.toString(), skylarkFunctionName, getLabel());
+ public BuildConfiguration getTargetConfiguration() {
+ return targetConfiguration;
}
- @Override
- SkyFunctionName getType() {
- return SkyFunctions.SKYLARK_ASPECT;
+ public String getDescription() {
+ // Skylark aspects are referred to on command line with <file>%<value ame>
+ return String.format("%s%%%s of %s", extensionFile.toString(), skylarkValueName, targetLabel);
}
}
@@ -215,24 +214,25 @@ public final class AspectValue extends ActionLookupValue {
AspectClass aspectFactory,
AspectParameters additionalConfiguration) {
return new SkyKey(
- SkyFunctions.NATIVE_ASPECT,
- new NativeAspectKey(label, configuration, aspectFactory, additionalConfiguration));
+ SkyFunctions.ASPECT,
+ new AspectKey(label, configuration, aspectFactory, additionalConfiguration));
}
- public static SkyKey key(AspectKey aspectKey) {
+ public static SkyKey key(AspectValueKey aspectKey) {
return new SkyKey(aspectKey.getType(), aspectKey);
}
- public static NativeAspectKey createAspectKey(
+ public static AspectKey createAspectKey(
Label label, BuildConfiguration configuration, AspectClass aspectFactory) {
- return new NativeAspectKey(label, configuration, aspectFactory, AspectParameters.EMPTY);
+ return new AspectKey(label, configuration, aspectFactory, AspectParameters.EMPTY);
}
- public static SkylarkAspectKey createSkylarkAspectKey(
+ public static SkylarkAspectLoadingKey createSkylarkAspectKey(
Label targetLabel,
BuildConfiguration targetConfiguration,
- PackageIdentifier bzlFile,
- String skylarkFunctionName) {
- return new SkylarkAspectKey(targetLabel, targetConfiguration, bzlFile, skylarkFunctionName);
+ PackageIdentifier skylarkFile,
+ String skylarkExportName) {
+ return new SkylarkAspectLoadingKey(
+ targetLabel, targetConfiguration, skylarkFile, skylarkExportName);
}
}