Skip to content

Commit

Permalink
Support proto_library in proto_lang_toolchain.blacklisted_protos
Browse files Browse the repository at this point in the history
in addition to output files.

PiperOrigin-RevId: 242492558
  • Loading branch information
cushon authored and Copybara-Service committed Apr 8, 2019
1 parent 4d7def6 commit a5ee2c4
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.Runfiles;
import com.google.devtools.build.lib.analysis.RunfilesProvider;
import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.syntax.Type;

Expand All @@ -37,9 +38,14 @@ public class ProtoLangToolchain implements RuleConfiguredTargetFactory {
public ConfiguredTarget create(RuleContext ruleContext)
throws InterruptedException, RuleErrorException, ActionConflictException {
NestedSetBuilder<Artifact> blacklistedProtos = NestedSetBuilder.stableOrder();
for (FileProvider protos :
ruleContext.getPrerequisites("blacklisted_protos", TARGET, FileProvider.class)) {
blacklistedProtos.addTransitive(protos.getFilesToBuild());
for (TransitiveInfoCollection protos :
ruleContext.getPrerequisites("blacklisted_protos", TARGET)) {
blacklistedProtos.addTransitive(protos.getProvider(FileProvider.class).getFilesToBuild());
ProtoInfo protoInfo = protos.get(ProtoInfo.PROVIDER);
// TODO(cushon): it would be nice to make this mandatory and stop adding files to build too
if (protoInfo != null) {
blacklistedProtos.addAll(protoInfo.getDirectProtoSources());
}
}

return new RuleConfiguredTargetBuilder(ruleContext)
Expand Down

0 comments on commit a5ee2c4

Please sign in to comment.