Skip to content

Commit

Permalink
Prepare to remove support for files in proto_lang_toolchain.blacklist…
Browse files Browse the repository at this point in the history
…ed_protos

PiperOrigin-RevId: 288016010
  • Loading branch information
cushon authored and copybara-github committed Jan 3, 2020
1 parent 9a458c5 commit 01df1e5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ public ConfiguredTarget create(RuleContext ruleContext)
NestedSetBuilder<Artifact> blacklistedProtos = NestedSetBuilder.stableOrder();
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());
blacklistedProtos.addTransitive(protoInfo.getTransitiveProtoSources());
} else {
blacklistedProtos.addTransitive(protos.getProvider(FileProvider.class).getFilesToBuild());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ public static void setup(MockToolsConfig config) throws IOException {
" runtime = '//third_party/java/j2objc:proto_runtime',",
")",
"exports_files(['j2objc_deploy.jar'])",
"filegroup(",
"proto_library(",
" name = 'j2objc_proto_blacklist',",
" srcs = [",
" '" + TestConstants.TOOLS_REPOSITORY + "//tools/j2objc/proto:blacklisted.proto'",
" deps = [",
" '" + TestConstants.TOOLS_REPOSITORY + "//tools/j2objc/proto:blacklisted'",
" ])");

config.create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private static void createNetProto2(MockToolsConfig config) throws IOException {
config.create(
"java/com/google/protobuf/BUILD",
"package(default_visibility=['//visibility:public'])",
"filegroup(name = 'protobuf_proto_sources', srcs = [])");
"proto_library(name = 'protobuf_proto_sources', srcs = [])");

// RPC generator plugins.
config.create("net/rpc/compiler/BUILD",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ public void testProtoToolchainForJ2ObjcFlag() throws Exception {
" name = 'j2objc_wrapper',",
" srcs = ['j2objc_wrapper.py'],",
")",
"filegroup(",
"proto_library(",
" name = 'blacklisted_protos',",
" srcs = ['some_blacklisted_proto.proto'],",
")",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class ProtoLangToolchainTest extends BuildViewTestCase {
@Before
public void setUp() throws Exception {
MockProtoSupport.setupWorkspace(scratch);
MockProtoSupport.setup(mockToolsConfig);
invalidatePackages();
}

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

scratch.file(
"foo/BUILD",
Expand All @@ -55,7 +57,7 @@ public void protoToolchain() throws Exception {
" command_line = 'cmd-line',",
" plugin = '//x:plugin',",
" runtime = '//x:runtime',",
" blacklisted_protos = ['//x:descriptors', '//x:any']",
" blacklisted_protos = ['//x:blacklist']",
")");

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

0 comments on commit 01df1e5

Please sign in to comment.