Skip to content

Commit

Permalink
Accept proto_library as //tools/objc:protobuf_well_known_types
Browse files Browse the repository at this point in the history
Part of the migration of Protobuf rules/aspects to `ProtoSource`.
A future change will make `ProtoInfo` mandatory (similar to what was
done for `proto_lang_toolchain`).

Note that this is for Obj-C Protobuf rules which don't exist in Bazel.

Updates #10005

Closes #12486.

PiperOrigin-RevId: 344498042
  • Loading branch information
Yannic authored and copybara-github committed Nov 27, 2020
1 parent 20f62f8 commit c85ecbe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/main/java/com/google/devtools/build/lib/rules/objc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/analysis:config/core_options",
"//src/main/java/com/google/devtools/build/lib/analysis:config/fragment",
"//src/main/java/com/google/devtools/build/lib/analysis:config/fragment_options",
"//src/main/java/com/google/devtools/build/lib/analysis:config/fragment_provider",
"//src/main/java/com/google/devtools/build/lib/analysis:config/host_transition",
"//src/main/java/com/google/devtools/build/lib/analysis:config/invalid_configuration_exception",
"//src/main/java/com/google/devtools/build/lib/analysis:config/transitions/composing_transition_factory",
"//src/main/java/com/google/devtools/build/lib/analysis:config/transitions/patch_transition",
"//src/main/java/com/google/devtools/build/lib/analysis:config/transitions/split_transition",
"//src/main/java/com/google/devtools/build/lib/analysis:config/transitions/transition_factory",
"//src/main/java/com/google/devtools/build/lib/analysis:configured_target",
"//src/main/java/com/google/devtools/build/lib/analysis:file_provider",
"//src/main/java/com/google/devtools/build/lib/analysis:platform_options",
"//src/main/java/com/google/devtools/build/lib/analysis:rule_definition_environment",
"//src/main/java/com/google/devtools/build/lib/analysis:test/instrumented_files_info",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.PrerequisiteArtifacts;
import com.google.devtools.build.lib.analysis.FileProvider;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.rules.proto.ProtoInfo;
Expand Down Expand Up @@ -86,7 +87,17 @@ ImmutableList<Artifact> getPortableProtoFilters() {

/** Returns the list of well known type protos. */
NestedSet<Artifact> getWellKnownTypeProtos() {
return PrerequisiteArtifacts.nestedSet(ruleContext, ObjcRuleClasses.PROTOBUF_WELL_KNOWN_TYPES);
NestedSetBuilder<Artifact> wellKnownTypeProtos = NestedSetBuilder.stableOrder();
for (TransitiveInfoCollection protos :
ruleContext.getPrerequisites(ObjcRuleClasses.PROTOBUF_WELL_KNOWN_TYPES)) {
ProtoInfo protoInfo = protos.get(ProtoInfo.PROVIDER);
if (protoInfo != null) {
wellKnownTypeProtos.addTransitive(protoInfo.getTransitiveProtoSources());
} else {
wellKnownTypeProtos.addTransitive(protos.getProvider(FileProvider.class).getFilesToBuild());
}
}
return wellKnownTypeProtos.build();
}

/** Returns the list of proto files to compile. */
Expand Down

0 comments on commit c85ecbe

Please sign in to comment.