aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com
diff options
context:
space:
mode:
authorGravatar dslomov <dslomov@google.com>2017-05-08 08:47:44 -0400
committerGravatar Kristina Chodorow <kchodorow@google.com>2017-05-08 09:50:19 -0400
commitfa50c3ddd67d835a134ea8da0cb9ba02fed704d1 (patch)
tree4e1b00014069ee50029e8cab4349f2879fdbb385 /src/main/java/com
parentc5c9aced57681cce897f3286d41b935d33876caa (diff)
Do not report errors when aspects try to attach to files.
Instead, silently ignore them in the same way we do for rules to which aspects are not applicable. In the future aspects will gain the ability to apply to, and propagate through, files. RELNOTES: None. PiperOrigin-RevId: 155369925
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/BuildView.java10
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java11
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java3
3 files changed, 5 insertions, 19 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
index 4c22da39fb..60a694636e 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
@@ -511,9 +511,6 @@ public class BuildView {
String skylarkFunctionName = aspect.substring(delimiterPosition + 1);
for (TargetAndConfiguration targetSpec : topLevelTargetsWithConfigs) {
- if (!(targetSpec.getTarget() instanceof Rule)) {
- continue;
- }
aspectKeys.add(
AspectValue.createSkylarkAspectKey(
targetSpec.getLabel(),
@@ -529,12 +526,7 @@ public class BuildView {
ruleClassProvider.getNativeAspectClassMap().get(aspect);
if (aspectFactoryClass != null) {
- AspectParameters aspectParameters = AspectParameters.EMPTY;
- boolean applyToFiles = aspectFactoryClass.getDefinition(aspectParameters).applyToFiles();
for (TargetAndConfiguration targetSpec : topLevelTargetsWithConfigs) {
- if (!applyToFiles && !(targetSpec.getTarget() instanceof Rule)) {
- continue;
- }
// For invoking top-level aspects, use the top-level configuration for both the
// aspect and the base target while the top-level configuration is untrimmed.
BuildConfiguration configuration = targetSpec.getConfiguration();
@@ -542,7 +534,7 @@ public class BuildView {
AspectValue.createAspectKey(
targetSpec.getLabel(),
configuration,
- new AspectDescriptor(aspectFactoryClass, aspectParameters),
+ new AspectDescriptor(aspectFactoryClass, AspectParameters.EMPTY),
configuration
));
}
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 5a2f964b89..52d00e3141 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
@@ -43,7 +43,6 @@ import com.google.devtools.build.lib.packages.BuildFileContainsErrorsException;
import com.google.devtools.build.lib.packages.NativeAspectClass;
import com.google.devtools.build.lib.packages.NoSuchThingException;
import com.google.devtools.build.lib.packages.Package;
-import com.google.devtools.build.lib.packages.Rule;
import com.google.devtools.build.lib.packages.RuleClassProvider;
import com.google.devtools.build.lib.packages.SkylarkAspect;
import com.google.devtools.build.lib.packages.SkylarkAspectClass;
@@ -205,15 +204,6 @@ public final class AspectFunction implements SkyFunction {
ConfiguredTarget associatedTarget = configuredTargetValue.getConfiguredTarget();
Target target = associatedTarget.getTarget();
- if (!aspect.getDefinition().applyToFiles() && !(target instanceof Rule)) {
- env.getListener().handle(Event.error(
- target.getLocation(),
- String.format("%s is attached to %s %s but aspects must be attached to rules",
- aspect.getAspectClass().getName(), target.getTargetKind(), target.getName())));
- throw new AspectFunctionException(new AspectCreationException(
- "aspects must be attached to rules"));
- }
-
if (configuredTargetValue.getConfiguredTarget().getProvider(AliasProvider.class) != null) {
return createAliasAspect(env, target, aspect, key,
@@ -380,6 +370,7 @@ public final class AspectFunction implements SkyFunction {
// the aspect comes after all aspects it transitively sees.
aspectPathBuilder.add(skyKey);
}
+
private SkyValue createAliasAspect(
Environment env,
Target originalTarget,
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 034e87dd84..06b61e6fde 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
@@ -947,6 +947,9 @@ final class ConfiguredTargetFunction implements SkyFunction {
}
static boolean aspectMatchesConfiguredTarget(final ConfiguredTarget dep, Aspect aspect) {
+ if (!aspect.getDefinition().applyToFiles() && !(dep.getTarget() instanceof Rule)) {
+ return false;
+ }
return aspect.getDefinition().getRequiredProviders().isSatisfiedBy(
new Predicate<Class<?>>() {
@Override