diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/TopLevelArtifactHelper.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/TopLevelArtifactHelper.java | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/TopLevelArtifactHelper.java b/src/main/java/com/google/devtools/build/lib/analysis/TopLevelArtifactHelper.java index 853ecb93a8..ff153030d6 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/TopLevelArtifactHelper.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/TopLevelArtifactHelper.java @@ -17,16 +17,16 @@ package com.google.devtools.build.lib.analysis; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.annotations.VisibleForTesting; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.SetMultimap; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.test.TestProvider; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; +import com.google.devtools.build.lib.profiler.AutoProfiler; import com.google.devtools.build.lib.skyframe.AspectValue; import com.google.devtools.build.lib.util.RegexFilter; +import java.util.logging.Logger; import javax.annotation.Nullable; /** @@ -34,6 +34,7 @@ import javax.annotation.Nullable; * extra top-level artifacts into the build. */ public final class TopLevelArtifactHelper { + private static Logger logger = Logger.getLogger(TopLevelArtifactHelper.class.getName()); /** Set of {@link Artifact}s in an output group. */ @Immutable @@ -119,46 +120,49 @@ public final class TopLevelArtifactHelper { } @VisibleForTesting - public static SetMultimap<Artifact, Label> makeTopLevelArtifactsToOwnerLabels( + public static ArtifactsToOwnerLabels makeTopLevelArtifactsToOwnerLabels( AnalysisResult analysisResult, Iterable<AspectValue> aspects) { - SetMultimap<Artifact, Label> topLevelArtifactsToOwnerLabels = - HashMultimap.create(analysisResult.getTopLevelArtifactsToOwnerLabels()); + try (AutoProfiler ignored = AutoProfiler.logged("assigning owner labels", logger, 10)) { + + ArtifactsToOwnerLabels.Builder artifactsToOwnerLabelsBuilder = + analysisResult.getTopLevelArtifactsToOwnerLabels().toBuilder(); TopLevelArtifactContext artifactContext = analysisResult.getTopLevelContext(); for (ConfiguredTarget target : analysisResult.getTargetsToBuild()) { - addArtifactsWithOwnerLabel( - getAllArtifactsToBuild(target, artifactContext).getAllArtifacts(), - null, - target.getLabel(), - topLevelArtifactsToOwnerLabels); + addArtifactsWithOwnerLabel( + getAllArtifactsToBuild(target, artifactContext).getAllArtifacts(), + null, + target.getLabel(), + artifactsToOwnerLabelsBuilder); } for (AspectValue aspect : aspects) { - addArtifactsWithOwnerLabel( - getAllArtifactsToBuild(aspect, artifactContext).getAllArtifacts(), - null, - aspect.getLabel(), - topLevelArtifactsToOwnerLabels); + addArtifactsWithOwnerLabel( + getAllArtifactsToBuild(aspect, artifactContext).getAllArtifacts(), + null, + aspect.getLabel(), + artifactsToOwnerLabelsBuilder); } if (analysisResult.getTargetsToTest() != null) { for (ConfiguredTarget target : analysisResult.getTargetsToTest()) { - addArtifactsWithOwnerLabel( - TestProvider.getTestStatusArtifacts(target), - null, - target.getLabel(), - topLevelArtifactsToOwnerLabels); + addArtifactsWithOwnerLabel( + TestProvider.getTestStatusArtifacts(target), + null, + target.getLabel(), + artifactsToOwnerLabelsBuilder); } } - // TODO(dslomov): Artifacts to test from aspects? - return topLevelArtifactsToOwnerLabels; + // TODO(dslomov): Artifacts to test from aspects? + return artifactsToOwnerLabelsBuilder.build(); + } } - public static void addArtifactsWithOwnerLabel( + static void addArtifactsWithOwnerLabel( Iterable<Artifact> artifacts, @Nullable RegexFilter filter, Label ownerLabel, - SetMultimap<Artifact, Label> artifactToTopLevelLabels) { + ArtifactsToOwnerLabels.Builder artifactsToOwnerLabelsBuilder) { for (Artifact artifact : artifacts) { if (filter == null || filter.isIncluded(artifact.getOwnerLabel().toString())) { - artifactToTopLevelLabels.put(artifact, ownerLabel); + artifactsToOwnerLabelsBuilder.addArtifact(artifact, ownerLabel); } } } |