Fix bp2build for cc_aidl_library to use LabelListAttribute.Partition
Using LabelListAttribute.Partition instead of Includes ensures the configuration axes are taken into account when iterating through the AIDL srcs and filegroups This CI should not have any effect on the already converted modules and bp2build tests. Bug: 243826707 Test: CI Change-Id: Ifcd9a37fc1b0887635e69fe227c81893e09b4c47
This commit is contained in:
@@ -746,60 +746,37 @@ func bp2BuildParseBaseProps(ctx android.Bp2buildMutatorContext, module *Module)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func bp2buildAidlLibraries(
|
func bp2buildCcAidlLibrary(
|
||||||
ctx android.Bp2buildMutatorContext,
|
ctx android.Bp2buildMutatorContext,
|
||||||
m *Module,
|
m *Module,
|
||||||
aidlSrcs bazel.LabelListAttribute,
|
aidlLabelList bazel.LabelListAttribute,
|
||||||
) bazel.LabelList {
|
) *bazel.LabelAttribute {
|
||||||
var aidlLibraries bazel.LabelList
|
if !aidlLabelList.IsEmpty() {
|
||||||
var directAidlSrcs bazel.LabelList
|
aidlLibs, aidlSrcs := aidlLabelList.Partition(func(src bazel.Label) bool {
|
||||||
|
if fg, ok := android.ToFileGroupAsLibrary(ctx, src.OriginalModuleName); ok &&
|
||||||
// Make a list of labels that correspond to filegroups that are already converted to aidl_library
|
|
||||||
for _, aidlSrc := range aidlSrcs.Value.Includes {
|
|
||||||
src := aidlSrc.OriginalModuleName
|
|
||||||
if fg, ok := android.ToFileGroupAsLibrary(ctx, src); ok &&
|
|
||||||
fg.ShouldConvertToAidlLibrary(ctx) {
|
fg.ShouldConvertToAidlLibrary(ctx) {
|
||||||
aidlLibraries.Add(&bazel.Label{
|
return true
|
||||||
Label: fg.GetAidlLibraryLabel(ctx),
|
}
|
||||||
|
return false
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
directAidlSrcs.Add(&aidlSrc)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(directAidlSrcs.Includes) > 0 {
|
if !aidlSrcs.IsEmpty() {
|
||||||
aidlLibraryLabel := m.Name() + "_aidl_library"
|
aidlLibName := m.Name() + "_aidl_library"
|
||||||
ctx.CreateBazelTargetModule(
|
ctx.CreateBazelTargetModule(
|
||||||
bazel.BazelTargetModuleProperties{
|
bazel.BazelTargetModuleProperties{
|
||||||
Rule_class: "aidl_library",
|
Rule_class: "aidl_library",
|
||||||
Bzl_load_location: "//build/bazel/rules/aidl:library.bzl",
|
Bzl_load_location: "//build/bazel/rules/aidl:library.bzl",
|
||||||
},
|
},
|
||||||
android.CommonAttributes{Name: aidlLibraryLabel},
|
android.CommonAttributes{Name: aidlLibName},
|
||||||
&aidlLibraryAttributes{
|
&aidlLibraryAttributes{
|
||||||
Srcs: bazel.MakeLabelListAttribute(directAidlSrcs),
|
Srcs: aidlSrcs,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
aidlLibraries.Add(&bazel.Label{
|
aidlLibs.Add(&bazel.LabelAttribute{Value: &bazel.Label{Label: ":" + aidlLibName}})
|
||||||
Label: ":" + aidlLibraryLabel,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return aidlLibraries
|
|
||||||
}
|
|
||||||
|
|
||||||
func bp2buildCcAidlLibrary(
|
|
||||||
ctx android.Bp2buildMutatorContext,
|
|
||||||
m *Module,
|
|
||||||
aidlSrcs bazel.LabelListAttribute,
|
|
||||||
) *bazel.LabelAttribute {
|
|
||||||
suffix := "_cc_aidl_library"
|
|
||||||
ccAidlLibrarylabel := m.Name() + suffix
|
|
||||||
|
|
||||||
aidlLibraries := bp2buildAidlLibraries(ctx, m, aidlSrcs)
|
|
||||||
|
|
||||||
if aidlLibraries.IsEmpty() {
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !aidlLibs.IsEmpty() {
|
||||||
|
ccAidlLibrarylabel := m.Name() + "_cc_aidl_library"
|
||||||
ctx.CreateBazelTargetModule(
|
ctx.CreateBazelTargetModule(
|
||||||
bazel.BazelTargetModuleProperties{
|
bazel.BazelTargetModuleProperties{
|
||||||
Rule_class: "cc_aidl_library",
|
Rule_class: "cc_aidl_library",
|
||||||
@@ -807,16 +784,19 @@ func bp2buildCcAidlLibrary(
|
|||||||
},
|
},
|
||||||
android.CommonAttributes{Name: ccAidlLibrarylabel},
|
android.CommonAttributes{Name: ccAidlLibrarylabel},
|
||||||
&ccAidlLibraryAttributes{
|
&ccAidlLibraryAttributes{
|
||||||
Deps: bazel.MakeLabelListAttribute(aidlLibraries),
|
Deps: aidlLibs,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
label := &bazel.LabelAttribute{
|
label := &bazel.LabelAttribute{
|
||||||
Value: &bazel.Label{
|
Value: &bazel.Label{
|
||||||
Label: ":" + ccAidlLibrarylabel,
|
Label: ":" + ccAidlLibrarylabel,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return label
|
return label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func bp2BuildParseSdkAttributes(module *Module) sdkAttributes {
|
func bp2BuildParseSdkAttributes(module *Module) sdkAttributes {
|
||||||
|
Reference in New Issue
Block a user