summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yu Liu <yudiliu@google.com> 2022-09-15 22:18:48 -0700
committer Yu Liu <yudiliu@google.com> 2022-09-15 22:18:48 -0700
commit2a85fb195dde37d773068b545aef4a52c644287f (patch)
treea01bba23d55258678bc6858b5098a667aa92a712
parent609c3e074f060a50972e1d5577ad38cf87ce9b0c (diff)
Fix a bug where deps were missing for converted proto_library
This is just a partial fix. Bug: 246997908 Test: Manual build //frameworks/proto_logging/stats:libstats_proto_host_proto Change-Id: I9e4e62bce22cb68bcd7f917c57f3d1438fcec716
-rw-r--r--android/filegroup.go4
-rw-r--r--android/proto.go2
-rw-r--r--bp2build/cc_library_conversion_test.go4
-rw-r--r--bp2build/filegroup_conversion_test.go3
4 files changed, 12 insertions, 1 deletions
diff --git a/android/filegroup.go b/android/filegroup.go
index e5eec87cf..6b1117230 100644
--- a/android/filegroup.go
+++ b/android/filegroup.go
@@ -120,9 +120,13 @@ func (fg *fileGroup) ConvertWithBp2build(ctx TopDownMutatorContext) {
ctx.CreateBazelTargetModule(props, CommonAttributes{Name: fg.Name()}, attrs)
} else {
if fg.ShouldConvertToProtoLibrary(ctx) {
+ // TODO(b/246997908): we can remove this tag if we could figure out a
+ // solution for this bug.
+ tags := []string{"manual"}
attrs := &ProtoAttrs{
Srcs: srcs,
Strip_import_prefix: fg.properties.Path,
+ Tags: tags,
}
ctx.CreateBazelTargetModule(
diff --git a/android/proto.go b/android/proto.go
index 3a5d4da5c..3cac9a185 100644
--- a/android/proto.go
+++ b/android/proto.go
@@ -164,6 +164,7 @@ type ProtoAttrs struct {
Srcs bazel.LabelListAttribute
Strip_import_prefix *string
Deps bazel.LabelListAttribute
+ Tags []string
}
// For each package in the include_dirs property a proto_library target should
@@ -203,6 +204,7 @@ func Bp2buildProtoProperties(ctx Bp2buildMutatorContext, m *ModuleBase, srcs baz
attrs := ProtoAttrs{
Srcs: bazel.MakeLabelListAttribute(directProtoSrcs),
}
+ attrs.Deps.Append(bazel.MakeLabelListAttribute(protoLibraries))
for axis, configToProps := range m.GetArchVariantProperties(ctx, &ProtoProperties{}) {
for _, rawProps := range configToProps {
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index ba7af0945..12cffc304 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -2284,6 +2284,7 @@ cc_library {
}`,
ExpectedBazelTargets: []string{
MakeBazelTarget("proto_library", "a_proto", AttrNameToString{
+ "deps": `[":a_fg_proto_bp2build_converted"]`,
"srcs": `["a.proto"]`,
}), MakeBazelTarget("cc_lite_proto_library", "a_cc_proto_lite", AttrNameToString{
"deps": `[
@@ -2298,6 +2299,7 @@ cc_library {
"whole_archive_deps": `[":a_cc_proto_lite"]`,
}), MakeBazelTargetNoRestrictions("proto_library", "a_fg_proto_bp2build_converted", AttrNameToString{
"srcs": `["a_fg.proto"]`,
+ "tags": `["manual"]`,
}), MakeBazelTargetNoRestrictions("filegroup", "a_fg_proto", AttrNameToString{
"srcs": `["a_fg.proto"]`,
}),
@@ -2336,6 +2338,7 @@ cc_library {
"whole_archive_deps": `[":a_cc_proto_lite"]`,
}), MakeBazelTargetNoRestrictions("proto_library", "a_fg_proto_bp2build_converted", AttrNameToString{
"srcs": `["a_fg.proto"]`,
+ "tags": `["manual"]`,
}), MakeBazelTargetNoRestrictions("filegroup", "a_fg_proto", AttrNameToString{
"srcs": `["a_fg.proto"]`,
}),
@@ -2368,6 +2371,7 @@ cc_library {
}`,
ExpectedBazelTargets: []string{
MakeBazelTarget("proto_library", "a_proto", AttrNameToString{
+ "deps": `["//path/to/A:a_fg_proto_bp2build_converted"]`,
"srcs": `["a.proto"]`,
}), MakeBazelTarget("cc_lite_proto_library", "a_cc_proto_lite", AttrNameToString{
"deps": `[
diff --git a/bp2build/filegroup_conversion_test.go b/bp2build/filegroup_conversion_test.go
index d84d4b374..e978fb319 100644
--- a/bp2build/filegroup_conversion_test.go
+++ b/bp2build/filegroup_conversion_test.go
@@ -135,7 +135,8 @@ filegroup {
ExpectedBazelTargets: []string{
MakeBazelTargetNoRestrictions("proto_library", "foo_bp2build_converted", AttrNameToString{
"srcs": `["proto/foo.proto"]`,
- "strip_import_prefix": `"proto"`}),
+ "strip_import_prefix": `"proto"`,
+ "tags": `["manual"]`}),
MakeBazelTargetNoRestrictions("filegroup", "foo", AttrNameToString{
"srcs": `["proto/foo.proto"]`}),
}})