diff options
author | 2017-08-02 22:40:58 +0200 | |
---|---|---|
committer | 2017-08-03 12:09:59 +0200 | |
commit | 20f7da51b3228eca561102e3b871b67b704347a9 (patch) | |
tree | 30402cd1f5b7db82ab23e1c9f02253df7bd3e9fa /src/main/java | |
parent | 389142468f72a16b6f21c35c20c9084eb85c504d (diff) |
Dedupe dylib-handled-protos by runfiles path instead of full path
RELNOTES: None.
PiperOrigin-RevId: 164031163
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/objc/ProtobufSupport.java | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ProtobufSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ProtobufSupport.java index f779b952e1..9784155a41 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ProtobufSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ProtobufSupport.java @@ -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); } |