From fa50c3ddd67d835a134ea8da0cb9ba02fed704d1 Mon Sep 17 00:00:00 2001 From: dslomov Date: Mon, 8 May 2017 08:47:44 -0400 Subject: 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 --- .../google/devtools/build/lib/skyframe/AspectFunction.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java') 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, -- cgit v1.2.3