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-20 10:03:14 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2015-10-20 16:38:08 +0000
commit0b832ce8971e28b9e8587ffe436ea6d3046851a9 (patch)
tree036c75824ada47578916a4738eb756f04c6af0bd /src/main/java/com/google/devtools/build/lib/skyframe/AspectValue.java
parent50e7db642e301002642a8237a2452b52a7792216 (diff)
Implement aspect(...) Skylark function.
-- MOS_MIGRATED_REVID=105844221
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.java99
1 files changed, 81 insertions, 18 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 16277c7a47..5a4052fb8c 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
@@ -22,6 +22,7 @@ import com.google.devtools.build.lib.analysis.AspectWithParameters;
import com.google.devtools.build.lib.analysis.ConfiguredAspectFactory;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.cmdline.Label;
+import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.events.Location;
import com.google.devtools.build.lib.packages.AspectParameters;
@@ -35,21 +36,17 @@ import javax.annotation.Nullable;
* An aspect in the context of the Skyframe graph.
*/
public final class AspectValue extends ActionLookupValue {
+
/**
- * The key of an action that is generated by an aspect.
+ * A base class for a key representing an aspect applied to a particular target.
*/
- public static final class AspectKey extends ActionLookupKey {
- private final Label label;
- private final BuildConfiguration configuration;
- private final AspectWithParameters aspect;
+ public abstract static class AspectKey extends ActionLookupKey {
+ protected final Label label;
+ protected final BuildConfiguration configuration;
- private AspectKey(Label label, BuildConfiguration configuration,
- Class<? extends ConfiguredAspectFactory> aspectFactory,
- AspectParameters parameters) {
- Preconditions.checkNotNull(parameters);
+ protected AspectKey(Label label, BuildConfiguration configuration) {
this.label = label;
this.configuration = configuration;
- this.aspect = new AspectWithParameters(aspectFactory, parameters);
}
@Override
@@ -57,14 +54,34 @@ public final class AspectValue extends ActionLookupValue {
return label;
}
+ public abstract AspectParameters getParameters();
+
public BuildConfiguration getConfiguration() {
return configuration;
}
+ }
+
+ /**
+ * The key of an action that is generated by a native aspect.
+ */
+ public static final class NativeAspectKey extends AspectKey {
+ private final AspectWithParameters aspect;
+
+ private NativeAspectKey(
+ Label label,
+ BuildConfiguration configuration,
+ Class<? extends ConfiguredAspectFactory> aspectFactory,
+ AspectParameters parameters) {
+ super(label, configuration);
+ Preconditions.checkNotNull(parameters);
+ this.aspect = new AspectWithParameters(aspectFactory, parameters);
+ }
public Class<? extends ConfiguredAspectFactory> getAspect() {
return aspect.getAspectFactory();
}
+ @Override
@Nullable
public AspectParameters getParameters() {
return aspect.getParameters();
@@ -72,7 +89,7 @@ public final class AspectValue extends ActionLookupValue {
@Override
SkyFunctionName getType() {
- return SkyFunctions.ASPECT;
+ return SkyFunctions.NATIVE_ASPECT;
}
@Override
@@ -86,11 +103,11 @@ public final class AspectValue extends ActionLookupValue {
return true;
}
- if (!(other instanceof AspectKey)) {
+ if (!(other instanceof NativeAspectKey)) {
return false;
}
- AspectKey that = (AspectKey) other;
+ NativeAspectKey that = (NativeAspectKey) other;
return Objects.equal(label, that.label)
&& Objects.equal(configuration, that.configuration)
&& Objects.equal(aspect, that.aspect);
@@ -104,6 +121,43 @@ public final class AspectValue extends ActionLookupValue {
}
}
+ /**
+ * The key of an action that is generated by a skylark aspect.
+ */
+ public static class SkylarkAspectKey extends AspectKey {
+ private final PackageIdentifier extensionFile;
+ private final String skylarkFunctionName;
+
+ private SkylarkAspectKey(
+ Label targetLabel,
+ BuildConfiguration targetConfiguration,
+ PackageIdentifier extensionFile,
+ String skylarkFunctionName) {
+ super(targetLabel, targetConfiguration);
+ this.extensionFile = extensionFile;
+ this.skylarkFunctionName = skylarkFunctionName;
+ }
+
+ public PackageIdentifier getExtensionFile() {
+ return extensionFile;
+ }
+
+ public String getSkylarkValueName() {
+ return skylarkFunctionName;
+ }
+
+ @Override
+ public AspectParameters getParameters() {
+ return AspectParameters.EMPTY;
+ }
+
+ @Override
+ SkyFunctionName getType() {
+ return SkyFunctions.SKYLARK_ASPECT;
+ }
+ }
+
+
private final Label label;
private final Location location;
private final AspectKey key;
@@ -144,18 +198,27 @@ public final class AspectValue extends ActionLookupValue {
public static SkyKey key(Label label, BuildConfiguration configuration,
Class<? extends ConfiguredAspectFactory> aspectFactory,
AspectParameters additionalConfiguration) {
- return new SkyKey(SkyFunctions.ASPECT,
- new AspectKey(label, configuration, aspectFactory, additionalConfiguration));
+ return new SkyKey(
+ SkyFunctions.NATIVE_ASPECT,
+ new NativeAspectKey(label, configuration, aspectFactory, additionalConfiguration));
}
public static SkyKey key(AspectKey aspectKey) {
- return new SkyKey(SkyFunctions.ASPECT, aspectKey);
+ return new SkyKey(aspectKey.getType(), aspectKey);
}
- public static AspectKey createAspectKey(
+ public static NativeAspectKey createAspectKey(
Label label,
BuildConfiguration configuration,
Class<? extends ConfiguredAspectFactory> aspectFactory) {
- return new AspectKey(label, configuration, aspectFactory, AspectParameters.EMPTY);
+ return new NativeAspectKey(label, configuration, aspectFactory, AspectParameters.EMPTY);
+ }
+
+ public static SkylarkAspectKey createSkylarkAspectKey(
+ Label targetLabel,
+ BuildConfiguration targetConfiguration,
+ PackageIdentifier bzlFile,
+ String skylarkFunctionName) {
+ return new SkylarkAspectKey(targetLabel, targetConfiguration, bzlFile, skylarkFunctionName);
}
}