diff options
| author | 2023-08-22 18:19:44 +0000 | |
|---|---|---|
| committer | 2023-08-24 19:00:11 +0000 | |
| commit | e0f2ed56a0a0c8477ec737d6a5919ae9b98f28e3 (patch) | |
| tree | b5335bf845ccd442b654da24b35592c37317db66 | |
| parent | 138ee09e28b462559bd73fb0f460a77464ae99de (diff) | |
Add manual tag to proto_library at the root package
This is a fix similar to aosp/2707793. This adds manual tags to the
top-level proto_library created in the root package, plus any
dynamically created proto_library targets for proto.include_dirs. These
proto_library targets might not specify their deps correctly and might
be unbuildable.
(We need to keep these targets because they provide a ProtoInfo for
cc/java/py source gen)
Test: go test ./bp2build
Change-Id: Ic00f05186327fcfcc8d33a0a2c0891ed619b7acb
| -rw-r--r-- | android/proto.go | 7 | ||||
| -rw-r--r-- | bp2build/cc_library_conversion_test.go | 3 |
2 files changed, 9 insertions, 1 deletions
diff --git a/android/proto.go b/android/proto.go index 0ffb9b62a..178d54f7f 100644 --- a/android/proto.go +++ b/android/proto.go @@ -292,9 +292,14 @@ func Bp2buildProtoProperties(ctx Bp2buildMutatorContext, m *ModuleBase, srcs baz // (or a different subpackage), it will not find it. // The CcProtoGen action itself runs fine because we construct the correct ProtoInfo, // but the FileDescriptorSet of each proto_library might not be compile-able - if pkg != ctx.ModuleDir() { + // + // Add manual tag if either + // 1. .proto files are in more than one package + // 2. proto.include_dirs is not empty + if len(SortedStringKeys(pkgToSrcs)) > 1 || len(protoIncludeDirs) > 0 { tags.Append(bazel.MakeStringListAttribute([]string{"manual"})) } + ctx.CreateBazelTargetModule( bazel.BazelTargetModuleProperties{Rule_class: "proto_library"}, CommonAttributes{Name: name, Dir: proptools.StringPtr(pkg), Tags: tags}, diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go index 28dbf7ead..05d2e6aec 100644 --- a/bp2build/cc_library_conversion_test.go +++ b/bp2build/cc_library_conversion_test.go @@ -4965,6 +4965,7 @@ cc_library_static { }), MakeBazelTarget("proto_library", "foo_proto", AttrNameToString{ "srcs": `["foo.proto"]`, + "tags": `["manual"]`, }), MakeBazelTarget("cc_lite_proto_library", "foo_cc_proto_lite", AttrNameToString{ "deps": `[ @@ -5033,6 +5034,7 @@ cc_library_static { MakeBazelTarget("proto_library", "foo_proto", AttrNameToString{ "srcs": `["foo.proto"]`, "strip_import_prefix": `""`, + "tags": `["manual"]`, }), MakeBazelTarget("cc_lite_proto_library", "foo_cc_proto_lite", AttrNameToString{ "deps": `[ @@ -5103,6 +5105,7 @@ cc_library_static { }), MakeBazelTarget("proto_library", "foo_proto", AttrNameToString{ "srcs": `["foo.proto"]`, + "tags": `["manual"]`, }), MakeBazelTarget("cc_lite_proto_library", "foo_cc_proto_lite", AttrNameToString{ "deps": `[":foo_proto"]`, |