Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 86a407f2 authored by Liz Kammer's avatar Liz Kammer
Browse files

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
parent 06ac78ce
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -922,6 +922,7 @@ var (
		"aconfig_values",
		"aidl_interface_headers",
		"bpf",
		"cc_prebuilt_library_headers",
		"combined_apis",
		"droiddoc_exported_dir",
		"java_import",
+44 −39
Original line number Diff line number Diff line
@@ -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) {
@@ -67,8 +68,6 @@ 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,
		Filesystem: map[string]string{
			"lib-1/lib1a.h":                        "",
			"lib-1/lib1b.h":                        "",
@@ -128,8 +127,6 @@ cc_library_headers {
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{},
		StubbedBuildDefinitions: []string{"android-lib", "base-lib", "darwin-lib",
			"linux-lib", "linux_bionic-lib", "windows-lib"},
@@ -198,8 +195,6 @@ 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"},
		Blueprint: soongCcLibraryPreamble + `
@@ -233,8 +228,6 @@ 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{},
		Blueprint: soongCcLibraryPreamble + `cc_library_headers {
    name: "foo_headers",
@@ -292,8 +285,6 @@ 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,
		Filesystem: map[string]string{
			"lib-1/lib1a.h":                        "",
			"lib-1/lib1b.h":                        "",
@@ -325,8 +316,6 @@ 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"},
		Blueprint: soongCcLibraryHeadersPreamble + `
@@ -348,8 +337,6 @@ 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"},
		Blueprint: soongCcLibraryHeadersPreamble + `
@@ -371,8 +358,6 @@ 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"},
		Blueprint: soongCcLibraryHeadersPreamble + `
@@ -394,8 +379,6 @@ 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"},
		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"]`,
			}),
		},
	})
}
+6 −1
Original line number Diff line number Diff line
@@ -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)
}