Search in sources :

Example 1 with AspectClass

use of com.google.devtools.build.lib.packages.AspectClass in project bazel by bazelbuild.

the class BuildView method addExtraActionsFromTargets.

private NestedSet<Artifact> addExtraActionsFromTargets(BuildView.Options viewOptions, Collection<ConfiguredTarget> configuredTargets) {
    NestedSetBuilder<Artifact> builder = NestedSetBuilder.stableOrder();
    for (ConfiguredTarget target : configuredTargets) {
        ExtraActionArtifactsProvider provider = target.getProvider(ExtraActionArtifactsProvider.class);
        if (provider != null) {
            if (viewOptions.extraActionTopLevelOnly) {
                if (!viewOptions.extraActionTopLevelOnlyWithAspects) {
                    builder.addTransitive(provider.getExtraActionArtifacts());
                } else {
                    // Collect all aspect-classes that topLevel might inject.
                    Set<AspectClass> aspectClasses = new HashSet<>();
                    for (Attribute attr : target.getTarget().getAssociatedRule().getAttributes()) {
                        aspectClasses.addAll(attr.getAspectClasses());
                    }
                    builder.addTransitive(provider.getExtraActionArtifacts());
                    if (!aspectClasses.isEmpty()) {
                        builder.addAll(filterTransitiveExtraActions(provider, aspectClasses));
                    }
                }
            } else {
                builder.addTransitive(provider.getTransitiveExtraActionArtifacts());
            }
        }
    }
    return builder.build();
}
Also used : NativeAspectClass(com.google.devtools.build.lib.packages.NativeAspectClass) AspectClass(com.google.devtools.build.lib.packages.AspectClass) Attribute(com.google.devtools.build.lib.packages.Attribute) Artifact(com.google.devtools.build.lib.actions.Artifact) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

Artifact (com.google.devtools.build.lib.actions.Artifact)1 AspectClass (com.google.devtools.build.lib.packages.AspectClass)1 Attribute (com.google.devtools.build.lib.packages.Attribute)1 NativeAspectClass (com.google.devtools.build.lib.packages.NativeAspectClass)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1