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",
"aidl_interface_headers",
"bpf",
"cc_prebuilt_library_headers",
"combined_apis",
"droiddoc_exported_dir",
"java_import",

View file

@ -57,6 +57,7 @@ func TestCcLibraryHeadersLoadStatement(t *testing.T) {
func registerCcLibraryHeadersModuleTypes(ctx android.RegistrationContext) {
cc.RegisterCCBuildComponents(ctx)
cc.RegisterLibraryHeadersBuildComponents(ctx)
}
func runCcLibraryHeadersTestCase(t *testing.T, tc Bp2buildTestCase) {
@ -66,9 +67,7 @@ func runCcLibraryHeadersTestCase(t *testing.T, tc Bp2buildTestCase) {
func TestCcLibraryHeadersSimple(t *testing.T) {
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Description: "cc_library_headers test",
ModuleTypeUnderTest: "cc_library_headers",
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
Description: "cc_library_headers test",
Filesystem: map[string]string{
"lib-1/lib1a.h": "",
"lib-1/lib1b.h": "",
@ -127,10 +126,8 @@ cc_library_headers {
// variant info(select) should go before general info.
func TestCcLibraryHeadersOsSpecificHeader(t *testing.T) {
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Description: "cc_library_headers test with os-specific header_libs props",
ModuleTypeUnderTest: "cc_library_headers",
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
Filesystem: map[string]string{},
Description: "cc_library_headers test with os-specific header_libs props",
Filesystem: map[string]string{},
StubbedBuildDefinitions: []string{"android-lib", "base-lib", "darwin-lib",
"linux-lib", "linux_bionic-lib", "windows-lib"},
Blueprint: soongCcLibraryPreamble + `
@ -197,11 +194,9 @@ cc_library_headers {
func TestCcLibraryHeadersOsSpecficHeaderLibsExportHeaderLibHeaders(t *testing.T) {
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
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{},
StubbedBuildDefinitions: []string{"android-lib", "exported-lib"},
Description: "cc_library_headers test with os-specific header_libs and export_header_lib_headers props",
Filesystem: map[string]string{},
StubbedBuildDefinitions: []string{"android-lib", "exported-lib"},
Blueprint: soongCcLibraryPreamble + `
cc_library_headers {
name: "android-lib",
@ -232,10 +227,8 @@ cc_library_headers {
func TestCcLibraryHeadersArchAndTargetExportSystemIncludes(t *testing.T) {
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
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{},
Description: "cc_library_headers test with arch-specific and target-specific export_system_include_dirs props",
Filesystem: map[string]string{},
Blueprint: soongCcLibraryPreamble + `cc_library_headers {
name: "foo_headers",
export_system_include_dirs: [
@ -291,9 +284,7 @@ func TestCcLibraryHeadersArchAndTargetExportSystemIncludes(t *testing.T) {
func TestCcLibraryHeadersNoCrtIgnored(t *testing.T) {
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Description: "cc_library_headers test",
ModuleTypeUnderTest: "cc_library_headers",
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
Description: "cc_library_headers test",
Filesystem: map[string]string{
"lib-1/lib1a.h": "",
"lib-1/lib1b.h": "",
@ -324,11 +315,9 @@ cc_library_headers {
func TestCcLibraryHeadersExportedStaticLibHeadersReexported(t *testing.T) {
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Description: "cc_library_headers exported_static_lib_headers is reexported",
ModuleTypeUnderTest: "cc_library_headers",
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
Filesystem: map[string]string{},
StubbedBuildDefinitions: []string{"foo_export"},
Description: "cc_library_headers exported_static_lib_headers is reexported",
Filesystem: map[string]string{},
StubbedBuildDefinitions: []string{"foo_export"},
Blueprint: soongCcLibraryHeadersPreamble + `
cc_library_headers {
name: "foo_headers",
@ -347,11 +336,9 @@ cc_library_headers {
func TestCcLibraryHeadersExportedSharedLibHeadersReexported(t *testing.T) {
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Description: "cc_library_headers exported_shared_lib_headers is reexported",
ModuleTypeUnderTest: "cc_library_headers",
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
Filesystem: map[string]string{},
StubbedBuildDefinitions: []string{"foo_export"},
Description: "cc_library_headers exported_shared_lib_headers is reexported",
Filesystem: map[string]string{},
StubbedBuildDefinitions: []string{"foo_export"},
Blueprint: soongCcLibraryHeadersPreamble + `
cc_library_headers {
name: "foo_headers",
@ -370,11 +357,9 @@ cc_library_headers {
func TestCcLibraryHeadersExportedHeaderLibHeadersReexported(t *testing.T) {
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Description: "cc_library_headers exported_header_lib_headers is reexported",
ModuleTypeUnderTest: "cc_library_headers",
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
Filesystem: map[string]string{},
StubbedBuildDefinitions: []string{"foo_export"},
Description: "cc_library_headers exported_header_lib_headers is reexported",
Filesystem: map[string]string{},
StubbedBuildDefinitions: []string{"foo_export"},
Blueprint: soongCcLibraryHeadersPreamble + `
cc_library_headers {
name: "foo_headers",
@ -393,11 +378,9 @@ cc_library_headers {
func TestCcLibraryHeadersWholeStaticLibsReexported(t *testing.T) {
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Description: "cc_library_headers whole_static_libs is reexported",
ModuleTypeUnderTest: "cc_library_headers",
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
Filesystem: map[string]string{},
StubbedBuildDefinitions: []string{"foo_export"},
Description: "cc_library_headers whole_static_libs is reexported",
Filesystem: map[string]string{},
StubbedBuildDefinitions: []string{"foo_export"},
Blueprint: soongCcLibraryHeadersPreamble + `
cc_library_headers {
name: "foo_headers",
@ -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)
name := module.Name()
if module.IsPrebuilt() {
name = android.RemoveOptionalPrebuiltPrefix(name)
}
ctx.CreateBazelTargetModule(props, android.CommonAttributes{
Name: module.Name(),
Name: name,
Tags: tags,
}, attrs)
}