Bp2build: handle embedded structs as blueprint
For structs that are embedded, Blueprint does not nest under the
embedded name, flattening them into the original struct for blueprint
files (e.g.
9fd2ed93df
:proptools/unpack_test.go;l=402-431;drc=3adb2409648d6f8b25354ac47f083dae87731f10).
We should do the same for bp2build.
This will also allow us to embed structs for bp2build conversion
allowing more reuse.
Test: go test bp2build tests
Change-Id: I9ce088462adaf59bffa80bea76cd488e31f98e9d
This commit is contained in:
@@ -148,7 +148,18 @@ type nestedProps struct {
|
||||
Nested_prop string
|
||||
}
|
||||
|
||||
type EmbeddedProps struct {
|
||||
Embedded_prop string
|
||||
}
|
||||
|
||||
type OtherEmbeddedProps struct {
|
||||
Other_embedded_prop string
|
||||
}
|
||||
|
||||
type customProps struct {
|
||||
EmbeddedProps
|
||||
*OtherEmbeddedProps
|
||||
|
||||
Bool_prop bool
|
||||
Bool_ptr_prop *bool
|
||||
// Ensure that properties tagged `blueprint:mutated` are omitted
|
||||
@@ -246,7 +257,17 @@ func customDefaultsModuleFactory() android.Module {
|
||||
return m
|
||||
}
|
||||
|
||||
type EmbeddedAttr struct {
|
||||
Embedded_attr string
|
||||
}
|
||||
|
||||
type OtherEmbeddedAttr struct {
|
||||
Other_embedded_attr string
|
||||
}
|
||||
|
||||
type customBazelModuleAttributes struct {
|
||||
EmbeddedAttr
|
||||
*OtherEmbeddedAttr
|
||||
String_prop string
|
||||
String_list_prop []string
|
||||
Arch_paths bazel.LabelListAttribute
|
||||
@@ -275,6 +296,10 @@ func customBp2BuildMutator(ctx android.TopDownMutatorContext) {
|
||||
String_list_prop: m.props.String_list_prop,
|
||||
Arch_paths: paths,
|
||||
}
|
||||
attrs.Embedded_attr = m.props.Embedded_prop
|
||||
if m.props.OtherEmbeddedProps != nil {
|
||||
attrs.OtherEmbeddedAttr = &OtherEmbeddedAttr{Other_embedded_attr: m.props.OtherEmbeddedProps.Other_embedded_prop}
|
||||
}
|
||||
|
||||
props := bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "custom",
|
||||
|
Reference in New Issue
Block a user