Skip to content

Commit 01df1e5

Browse files
cushoncopybara-github
authored andcommitted
Prepare to remove support for files in proto_lang_toolchain.blacklisted_protos
PiperOrigin-RevId: 288016010
1 parent 9a458c5 commit 01df1e5

5 files changed

Lines changed: 12 additions & 9 deletions

File tree

src/main/java/com/google/devtools/build/lib/rules/proto/ProtoLangToolchain.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ public ConfiguredTarget create(RuleContext ruleContext)
4141
NestedSetBuilder<Artifact> blacklistedProtos = NestedSetBuilder.stableOrder();
4242
for (TransitiveInfoCollection protos :
4343
ruleContext.getPrerequisites("blacklisted_protos", TARGET)) {
44-
blacklistedProtos.addTransitive(protos.getProvider(FileProvider.class).getFilesToBuild());
4544
ProtoInfo protoInfo = protos.get(ProtoInfo.PROVIDER);
4645
// TODO(cushon): it would be nice to make this mandatory and stop adding files to build too
4746
if (protoInfo != null) {
48-
blacklistedProtos.addAll(protoInfo.getDirectProtoSources());
47+
blacklistedProtos.addTransitive(protoInfo.getTransitiveProtoSources());
48+
} else {
49+
blacklistedProtos.addTransitive(protos.getProvider(FileProvider.class).getFilesToBuild());
4950
}
5051
}
5152

src/test/java/com/google/devtools/build/lib/packages/util/MockJ2ObjcSupport.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ public static void setup(MockToolsConfig config) throws IOException {
9494
" runtime = '//third_party/java/j2objc:proto_runtime',",
9595
")",
9696
"exports_files(['j2objc_deploy.jar'])",
97-
"filegroup(",
97+
"proto_library(",
9898
" name = 'j2objc_proto_blacklist',",
99-
" srcs = [",
100-
" '" + TestConstants.TOOLS_REPOSITORY + "//tools/j2objc/proto:blacklisted.proto'",
99+
" deps = [",
100+
" '" + TestConstants.TOOLS_REPOSITORY + "//tools/j2objc/proto:blacklisted'",
101101
" ])");
102102

103103
config.create(

src/test/java/com/google/devtools/build/lib/packages/util/MockProtoSupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ private static void createNetProto2(MockToolsConfig config) throws IOException {
8787
config.create(
8888
"java/com/google/protobuf/BUILD",
8989
"package(default_visibility=['//visibility:public'])",
90-
"filegroup(name = 'protobuf_proto_sources', srcs = [])");
90+
"proto_library(name = 'protobuf_proto_sources', srcs = [])");
9191

9292
// RPC generator plugins.
9393
config.create("net/rpc/compiler/BUILD",

src/test/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcLibraryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ public void testProtoToolchainForJ2ObjcFlag() throws Exception {
10431043
" name = 'j2objc_wrapper',",
10441044
" srcs = ['j2objc_wrapper.py'],",
10451045
")",
1046-
"filegroup(",
1046+
"proto_library(",
10471047
" name = 'blacklisted_protos',",
10481048
" srcs = ['some_blacklisted_proto.proto'],",
10491049
")",

src/test/java/com/google/devtools/build/lib/rules/proto/ProtoLangToolchainTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class ProtoLangToolchainTest extends BuildViewTestCase {
3535
@Before
3636
public void setUp() throws Exception {
3737
MockProtoSupport.setupWorkspace(scratch);
38+
MockProtoSupport.setup(mockToolsConfig);
3839
invalidatePackages();
3940
}
4041

@@ -45,7 +46,8 @@ public void protoToolchain() throws Exception {
4546
"cc_binary(name = 'plugin', srcs = ['plugin.cc'])",
4647
"cc_library(name = 'runtime', srcs = ['runtime.cc'])",
4748
"filegroup(name = 'descriptors', srcs = ['metadata.proto', 'descriptor.proto'])",
48-
"filegroup(name = 'any', srcs = ['any.proto'])");
49+
"filegroup(name = 'any', srcs = ['any.proto'])",
50+
"proto_library(name = 'blacklist', srcs = [':descriptors', ':any'])");
4951

5052
scratch.file(
5153
"foo/BUILD",
@@ -55,7 +57,7 @@ public void protoToolchain() throws Exception {
5557
" command_line = 'cmd-line',",
5658
" plugin = '//x:plugin',",
5759
" runtime = '//x:runtime',",
58-
" blacklisted_protos = ['//x:descriptors', '//x:any']",
60+
" blacklisted_protos = ['//x:blacklist']",
5961
")");
6062

6163
update(ImmutableList.of("//foo:toolchain"), false, 1, true, new EventBus());

0 commit comments

Comments
 (0)