Dedupe dylib-handled-protos by runfiles path instead of full path
RELNOTES: None.
@@ -16,7 +16,7 @@ package com.google.devtools.build.lib.rules.objc;
import com.google.common.base.Joiner;
import com.google.common.base.Optional;
-import com.google.common.base.Predicates;
+import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSetMultimap;
@@ -37,6 +37,7 @@ import com.google.devtools.build.lib.rules.proto.ProtoSourcesProvider;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Set;
import java.util.TreeMap;
@@ -68,7 +69,7 @@ final class ProtobufSupport {
private final BuildConfiguration buildConfiguration;
private final ProtoAttributes attributes;
private final IntermediateArtifacts intermediateArtifacts;
- private final Set<Artifact> dylibHandledProtos;
+ private final Set<PathFragment> dylibHandledProtoPaths;
private final Iterable<ObjcProtoProvider> objcProtoProviders;
private final NestedSet<Artifact> portableProtoFilters;
@@ -140,7 +141,7 @@ final class ProtobufSupport {
this.ruleContext = ruleContext;
this.buildConfiguration = buildConfiguration;
this.attributes = new ProtoAttributes(ruleContext);
- this.dylibHandledProtos = dylibHandledProtos.toSet();
+ this.dylibHandledProtoPaths = runfilesPaths(dylibHandledProtos.toSet());
this.objcProtoProviders = objcProtoProviders;
this.portableProtoFilters = portableProtoFilters;
this.intermediateArtifacts =
@@ -301,6 +302,14 @@ final class ProtobufSupport {
return protobufHeaderSearchPaths.build();
}
+ private static Set<PathFragment> runfilesPaths(Set<Artifact> artifacts) {
+ HashSet<PathFragment> pathsSet = new HashSet<>();
+ for (Artifact artifact : artifacts) {
+ pathsSet.add(artifact.getRunfilesPath());
+ }
+ return pathsSet;
+ }
+
private static ImmutableSetMultimap<ImmutableSet<Artifact>, Artifact> getInputsToOutputsMap(
ProtoAttributes attributes,
Iterable<ProtoSourcesProvider> protoProviders,
@@ -412,8 +421,10 @@ final class ProtobufSupport {
private Iterable<Artifact> getProtoSourceFilesForCompilation(
Iterable<Artifact> outputProtoFiles) {
+ Predicate<Artifact> notDylibHandled =
+ artifact -> !dylibHandledProtoPaths.contains(artifact.getRunfilesPath());
Iterable<Artifact> filteredOutputs =
- Iterables.filter(outputProtoFiles, Predicates.not(Predicates.in(dylibHandledProtos)));
+ Iterables.filter(outputProtoFiles, notDylibHandled);
return getGeneratedProtoOutputs(filteredOutputs, SOURCE_SUFFIX);
}
