Support empty strings in bp2build

Previously, could not set an empty string as a value of an attribute;
however, this is necessary in some cases. To not unnecessarily create an
empty string, use string pointers for attributes rather than strings.

Test: go test bp2build tests
Change-Id: I03b3a3567452d455246d22d81f86c317d06b7c39
This commit is contained in:
Liz Kammer
2021-12-01 10:09:34 -05:00
parent 7c721018bb
commit 46fb7aba4d
7 changed files with 57 additions and 28 deletions

View File

@@ -149,15 +149,15 @@ func runBp2BuildTestCase(t *testing.T, registerModuleTypes func(ctx android.Regi
}
type nestedProps struct {
Nested_prop string
Nested_prop *string
}
type EmbeddedProps struct {
Embedded_prop string
Embedded_prop *string
}
type OtherEmbeddedProps struct {
Other_embedded_prop string
Other_embedded_prop *string
}
type customProps struct {
@@ -262,17 +262,17 @@ func customDefaultsModuleFactory() android.Module {
}
type EmbeddedAttr struct {
Embedded_attr string
Embedded_attr *string
}
type OtherEmbeddedAttr struct {
Other_embedded_attr string
Other_embedded_attr *string
}
type customBazelModuleAttributes struct {
EmbeddedAttr
*OtherEmbeddedAttr
String_prop string
String_ptr_prop *string
String_list_prop []string
Arch_paths bazel.LabelListAttribute
}
@@ -296,7 +296,7 @@ func customBp2BuildMutator(ctx android.TopDownMutatorContext) {
paths.ResolveExcludes()
attrs := &customBazelModuleAttributes{
String_prop: m.props.String_prop,
String_ptr_prop: m.props.String_ptr_prop,
String_list_prop: m.props.String_list_prop,
Arch_paths: paths,
}