Always convert prebuilt cc library headers

Test: go tests
Test: CI
Test: patch in CL using prebuilts for mainline modules and build
Bug: 300640274
Change-Id: I73f70dac679e341670e1484ce57bc984f413d409
This commit is contained in:
Liz Kammer
2023-09-18 09:23:38 -04:00
parent 06ac78ce40
commit 86a407f284
3 changed files with 51 additions and 40 deletions

View File

@@ -922,6 +922,7 @@ var (
"aconfig_values", "aconfig_values",
"aidl_interface_headers", "aidl_interface_headers",
"bpf", "bpf",
"cc_prebuilt_library_headers",
"combined_apis", "combined_apis",
"droiddoc_exported_dir", "droiddoc_exported_dir",
"java_import", "java_import",

View File

@@ -57,6 +57,7 @@ func TestCcLibraryHeadersLoadStatement(t *testing.T) {
func registerCcLibraryHeadersModuleTypes(ctx android.RegistrationContext) { func registerCcLibraryHeadersModuleTypes(ctx android.RegistrationContext) {
cc.RegisterCCBuildComponents(ctx) cc.RegisterCCBuildComponents(ctx)
cc.RegisterLibraryHeadersBuildComponents(ctx)
} }
func runCcLibraryHeadersTestCase(t *testing.T, tc Bp2buildTestCase) { func runCcLibraryHeadersTestCase(t *testing.T, tc Bp2buildTestCase) {
@@ -67,8 +68,6 @@ func runCcLibraryHeadersTestCase(t *testing.T, tc Bp2buildTestCase) {
func TestCcLibraryHeadersSimple(t *testing.T) { func TestCcLibraryHeadersSimple(t *testing.T) {
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{ runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Description: "cc_library_headers test", Description: "cc_library_headers test",
ModuleTypeUnderTest: "cc_library_headers",
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
Filesystem: map[string]string{ Filesystem: map[string]string{
"lib-1/lib1a.h": "", "lib-1/lib1a.h": "",
"lib-1/lib1b.h": "", "lib-1/lib1b.h": "",
@@ -128,8 +127,6 @@ cc_library_headers {
func TestCcLibraryHeadersOsSpecificHeader(t *testing.T) { func TestCcLibraryHeadersOsSpecificHeader(t *testing.T) {
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{ runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Description: "cc_library_headers test with os-specific header_libs props", Description: "cc_library_headers test with os-specific header_libs props",
ModuleTypeUnderTest: "cc_library_headers",
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
Filesystem: map[string]string{}, Filesystem: map[string]string{},
StubbedBuildDefinitions: []string{"android-lib", "base-lib", "darwin-lib", StubbedBuildDefinitions: []string{"android-lib", "base-lib", "darwin-lib",
"linux-lib", "linux_bionic-lib", "windows-lib"}, "linux-lib", "linux_bionic-lib", "windows-lib"},
@@ -198,8 +195,6 @@ cc_library_headers {
func TestCcLibraryHeadersOsSpecficHeaderLibsExportHeaderLibHeaders(t *testing.T) { func TestCcLibraryHeadersOsSpecficHeaderLibsExportHeaderLibHeaders(t *testing.T) {
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{ runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Description: "cc_library_headers test with os-specific header_libs and export_header_lib_headers props", Description: "cc_library_headers test with os-specific header_libs and export_header_lib_headers props",
ModuleTypeUnderTest: "cc_library_headers",
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
Filesystem: map[string]string{}, Filesystem: map[string]string{},
StubbedBuildDefinitions: []string{"android-lib", "exported-lib"}, StubbedBuildDefinitions: []string{"android-lib", "exported-lib"},
Blueprint: soongCcLibraryPreamble + ` Blueprint: soongCcLibraryPreamble + `
@@ -233,8 +228,6 @@ cc_library_headers {
func TestCcLibraryHeadersArchAndTargetExportSystemIncludes(t *testing.T) { func TestCcLibraryHeadersArchAndTargetExportSystemIncludes(t *testing.T) {
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{ runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Description: "cc_library_headers test with arch-specific and target-specific export_system_include_dirs props", Description: "cc_library_headers test with arch-specific and target-specific export_system_include_dirs props",
ModuleTypeUnderTest: "cc_library_headers",
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
Filesystem: map[string]string{}, Filesystem: map[string]string{},
Blueprint: soongCcLibraryPreamble + `cc_library_headers { Blueprint: soongCcLibraryPreamble + `cc_library_headers {
name: "foo_headers", name: "foo_headers",
@@ -292,8 +285,6 @@ func TestCcLibraryHeadersArchAndTargetExportSystemIncludes(t *testing.T) {
func TestCcLibraryHeadersNoCrtIgnored(t *testing.T) { func TestCcLibraryHeadersNoCrtIgnored(t *testing.T) {
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{ runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Description: "cc_library_headers test", Description: "cc_library_headers test",
ModuleTypeUnderTest: "cc_library_headers",
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
Filesystem: map[string]string{ Filesystem: map[string]string{
"lib-1/lib1a.h": "", "lib-1/lib1a.h": "",
"lib-1/lib1b.h": "", "lib-1/lib1b.h": "",
@@ -325,8 +316,6 @@ cc_library_headers {
func TestCcLibraryHeadersExportedStaticLibHeadersReexported(t *testing.T) { func TestCcLibraryHeadersExportedStaticLibHeadersReexported(t *testing.T) {
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{ runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Description: "cc_library_headers exported_static_lib_headers is reexported", Description: "cc_library_headers exported_static_lib_headers is reexported",
ModuleTypeUnderTest: "cc_library_headers",
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
Filesystem: map[string]string{}, Filesystem: map[string]string{},
StubbedBuildDefinitions: []string{"foo_export"}, StubbedBuildDefinitions: []string{"foo_export"},
Blueprint: soongCcLibraryHeadersPreamble + ` Blueprint: soongCcLibraryHeadersPreamble + `
@@ -348,8 +337,6 @@ cc_library_headers {
func TestCcLibraryHeadersExportedSharedLibHeadersReexported(t *testing.T) { func TestCcLibraryHeadersExportedSharedLibHeadersReexported(t *testing.T) {
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{ runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Description: "cc_library_headers exported_shared_lib_headers is reexported", Description: "cc_library_headers exported_shared_lib_headers is reexported",
ModuleTypeUnderTest: "cc_library_headers",
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
Filesystem: map[string]string{}, Filesystem: map[string]string{},
StubbedBuildDefinitions: []string{"foo_export"}, StubbedBuildDefinitions: []string{"foo_export"},
Blueprint: soongCcLibraryHeadersPreamble + ` Blueprint: soongCcLibraryHeadersPreamble + `
@@ -371,8 +358,6 @@ cc_library_headers {
func TestCcLibraryHeadersExportedHeaderLibHeadersReexported(t *testing.T) { func TestCcLibraryHeadersExportedHeaderLibHeadersReexported(t *testing.T) {
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{ runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Description: "cc_library_headers exported_header_lib_headers is reexported", Description: "cc_library_headers exported_header_lib_headers is reexported",
ModuleTypeUnderTest: "cc_library_headers",
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
Filesystem: map[string]string{}, Filesystem: map[string]string{},
StubbedBuildDefinitions: []string{"foo_export"}, StubbedBuildDefinitions: []string{"foo_export"},
Blueprint: soongCcLibraryHeadersPreamble + ` Blueprint: soongCcLibraryHeadersPreamble + `
@@ -394,8 +379,6 @@ cc_library_headers {
func TestCcLibraryHeadersWholeStaticLibsReexported(t *testing.T) { func TestCcLibraryHeadersWholeStaticLibsReexported(t *testing.T) {
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{ runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Description: "cc_library_headers whole_static_libs is reexported", Description: "cc_library_headers whole_static_libs is reexported",
ModuleTypeUnderTest: "cc_library_headers",
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
Filesystem: map[string]string{}, Filesystem: map[string]string{},
StubbedBuildDefinitions: []string{"foo_export"}, StubbedBuildDefinitions: []string{"foo_export"},
Blueprint: soongCcLibraryHeadersPreamble + ` Blueprint: soongCcLibraryHeadersPreamble + `
@@ -412,3 +395,25 @@ cc_library_headers {
}, },
}) })
} }
func TestPrebuiltCcLibraryHeadersWholeStaticLibsReexported(t *testing.T) {
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Description: "cc_library_headers whole_static_libs is reexported",
Filesystem: map[string]string{
"foo/bar/Android.bp": simpleModule("cc_library_headers", "foo_headers"),
},
StubbedBuildDefinitions: []string{"foo_export"},
Blueprint: soongCcLibraryHeadersPreamble + `
cc_prebuilt_library_headers {
name: "foo_headers",
whole_static_libs: ["foo_export"],
bazel_module: { bp2build_available: true },
}
` + simpleModule("cc_library_headers", "foo_export"),
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_library_headers", "foo_headers", AttrNameToString{
"deps": `[":foo_export"]`,
}),
},
})
}

View File

@@ -153,8 +153,13 @@ func libraryHeadersBp2Build(ctx android.TopDownMutatorContext, module *Module) {
tags := android.ApexAvailableTagsWithoutTestApexes(ctx, module) tags := android.ApexAvailableTagsWithoutTestApexes(ctx, module)
name := module.Name()
if module.IsPrebuilt() {
name = android.RemoveOptionalPrebuiltPrefix(name)
}
ctx.CreateBazelTargetModule(props, android.CommonAttributes{ ctx.CreateBazelTargetModule(props, android.CommonAttributes{
Name: module.Name(), Name: name,
Tags: tags, Tags: tags,
}, attrs) }, attrs)
} }