diff options
author | Sergio Campama <kaipi@google.com> | 2016-08-16 04:22:30 +0000 |
---|---|---|
committer | Philipp Wollermann <philwo@google.com> | 2016-08-16 15:21:27 +0000 |
commit | aaa58714859459d2bac3814579a74f5d56297d1b (patch) | |
tree | ffa1b3786fa64ea207a941ce93eaadf607231bd3 /src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoProvider.java | |
parent | 74c075aa1864875c5529540f62bcbe3fe80fc311 (diff) |
Adds proto grouping behavior so that generation and compilation actions are much smaller. This adds more granularity and helps prevent excessive compilation by minimizing the number of inputs for each action.
--
MOS_MIGRATED_REVID=130359288
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoProvider.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoProvider.java | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoProvider.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoProvider.java index f11f8ff904..b8dd834ff0 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoProvider.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoProvider.java @@ -40,27 +40,25 @@ import com.google.devtools.build.lib.vfs.PathFragment; */ public class ObjcProtoProvider implements TransitiveInfoProvider { - private final NestedSet<Artifact> protoSources; + private final NestedSet<NestedSet<Artifact>> protoGroups; private final NestedSet<Artifact> protobufHeaders; private final NestedSet<PathFragment> protobufHeaderSearchPaths; private final NestedSet<Artifact> portableProtoFilters; private ObjcProtoProvider( - NestedSet<Artifact> protoSources, + NestedSet<NestedSet<Artifact>> protoGroups, NestedSet<Artifact> portableProtoFilters, NestedSet<Artifact> protobufHeaders, NestedSet<PathFragment> protobufHeaderSearchPaths) { - this.protoSources = Preconditions.checkNotNull(protoSources); + this.protoGroups = Preconditions.checkNotNull(protoGroups); this.portableProtoFilters = Preconditions.checkNotNull(portableProtoFilters); this.protobufHeaders = Preconditions.checkNotNull(protobufHeaders); this.protobufHeaderSearchPaths = Preconditions.checkNotNull(protobufHeaderSearchPaths); } - /** - * Returns the set of all the protos that the dependencies of this provider has seen. - */ - public NestedSet<Artifact> getProtoSources() { - return protoSources; + /** Returns the set of all proto groups that the dependencies of this provider has seen. */ + public NestedSet<NestedSet<Artifact>> getProtoGroups() { + return protoGroups; } /** Returns the header artifacts provided by the Protobuf library. */ @@ -85,17 +83,21 @@ public class ObjcProtoProvider implements TransitiveInfoProvider { * several transitive dependencies. */ public static final class Builder { - private final NestedSetBuilder<Artifact> protoSources = NestedSetBuilder.naiveLinkOrder(); + private final NestedSetBuilder<NestedSet<Artifact>> protoGroups = + NestedSetBuilder.stableOrder(); private final NestedSetBuilder<Artifact> portableProtoFilters = NestedSetBuilder.stableOrder(); private final NestedSetBuilder<Artifact> protobufHeaders = NestedSetBuilder.stableOrder(); private final NestedSetBuilder<PathFragment> protobufHeaderSearchPaths = NestedSetBuilder.linkOrder(); /** - * Adds all the protos to the set of dependencies. + * Adds a proto group to be propagated. Each group represents a proto_library target and + * contains protos to be built along with their transitive dependencies. We propagate protos as + * groups because the grouping provides relationship information between the protos, which can + * be used to limit the number of inputs to each proto generation action. */ - public Builder addProtoSources(NestedSet<Artifact> protoSources) { - this.protoSources.addTransitive(protoSources); + public Builder addProtoGroup(NestedSet<Artifact> protoGroup) { + this.protoGroups.add(protoGroup); return this; } @@ -125,7 +127,7 @@ public class ObjcProtoProvider implements TransitiveInfoProvider { */ public Builder addTransitive(Iterable<ObjcProtoProvider> providers) { for (ObjcProtoProvider provider : providers) { - this.protoSources.addTransitive(provider.getProtoSources()); + this.protoGroups.addTransitive(provider.getProtoGroups()); this.portableProtoFilters.addTransitive(provider.getPortableProtoFilters()); this.protobufHeaders.addTransitive(provider.getProtobufHeaders()); this.protobufHeaderSearchPaths.addTransitive(provider.getProtobufHeaderSearchPaths()); @@ -137,12 +139,12 @@ public class ObjcProtoProvider implements TransitiveInfoProvider { * Whether this provider has any protos or filters. */ public boolean isEmpty() { - return protoSources.isEmpty() && portableProtoFilters.isEmpty(); + return protoGroups.isEmpty() && portableProtoFilters.isEmpty(); } public ObjcProtoProvider build() { return new ObjcProtoProvider( - protoSources.build(), + protoGroups.build(), portableProtoFilters.build(), protobufHeaders.build(), protobufHeaderSearchPaths.build()); |