From b11e23c710df111169333b1b2d89744af6d751cb Mon Sep 17 00:00:00 2001 From: Sergio Campama Date: Thu, 26 May 2016 15:12:19 +0000 Subject: Fixes bug where the well known types would not be added as an input to the generating action and would fail to compile. -- MOS_MIGRATED_REVID=123320220 --- .../devtools/build/lib/rules/objc/ProtoSupport.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/main') diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ProtoSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ProtoSupport.java index c6844f9d4d..7399509080 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ProtoSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ProtoSupport.java @@ -169,7 +169,7 @@ final class ProtoSupport { * @return this proto support */ public ProtoSupport registerActions() { - if (!Iterables.isEmpty(getProtoSources())) { + if (!Iterables.isEmpty(getFilteredProtoSources())) { registerProtoInputListFileAction(); registerGenerateProtoFilesAction(); } @@ -282,7 +282,7 @@ final class ProtoSupport { return attributes.hasPortableProtoFilters() || targetType == TargetType.LINKING_TARGET; } - private Iterable getProtoSources() { + private Iterable getAllProtoSources() { NestedSetBuilder protos = NestedSetBuilder.stableOrder(); if (experimentalAutoUnion() && targetType == TargetType.LINKING_TARGET) { @@ -295,6 +295,10 @@ final class ProtoSupport { protos.addTransitive(attributes.getProtoFiles()); + return protos.build(); + } + + private Iterable getFilteredProtoSources() { // Transform the well known proto artifacts by removing the external/bazel_tools prefix if // present. Otherwise the comparison for filtering out the well known types is not possible. ImmutableSet.Builder wellKnownProtoPathsBuilder = new ImmutableSet.Builder<>(); @@ -312,7 +316,7 @@ final class ProtoSupport { // Filter out the well known types from being sent to be generated, as these protos have already // been generated and linked in libprotobuf.a. ImmutableSet.Builder filteredProtos = new ImmutableSet.Builder<>(); - for (Artifact proto : protos.build()) { + for (Artifact proto : getAllProtoSources()) { if (!wellKnownProtoPaths.contains(proto.getExecPath())) { filteredProtos.add(proto); } @@ -367,7 +371,7 @@ final class ProtoSupport { } private String getProtoInputListFileContents() { - return Artifact.joinExecPaths("\n", getProtoSources()); + return Artifact.joinExecPaths("\n", getFilteredProtoSources()); } private PathFragment getWorkspaceRelativeOutputDir() { @@ -397,7 +401,7 @@ final class ProtoSupport { NestedSetBuilder inputsBuilder = NestedSetBuilder.stableOrder() .add(attributes.getProtoCompiler()) - .addAll(getProtoSources()) + .addAll(getAllProtoSources()) .add(getProtoInputListFile()) .addAll(attributes.getProtoCompilerSupport()) .addAll(getPortableProtoFilters()); @@ -478,7 +482,7 @@ final class ProtoSupport { private ImmutableList generatedOutputArtifacts(FileType newFileType) { ImmutableList.Builder builder = new ImmutableList.Builder<>(); - for (Artifact protoFile : getProtoSources()) { + for (Artifact protoFile : getFilteredProtoSources()) { String protoFileName = FileSystemUtils.removeExtension(protoFile.getFilename()); String generatedOutputName; if (attributes.outputsCpp()) { -- cgit v1.2.3