Merge "Add support and tests for export_*_lib_headers"

This commit is contained in:
Trevor Radcliffe 2022-06-30 17:30:16 +00:00 committed by Gerrit Code Review
commit 130d98f8b2
2 changed files with 67 additions and 0 deletions

View file

@ -324,3 +324,69 @@ 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{},
blueprint: soongCcLibraryHeadersPreamble + `
cc_library_headers {
name: "foo_headers",
export_static_lib_headers: ["foo_export"],
static_libs: ["foo_export", "foo_no_reexport"],
bazel_module: { bp2build_available: true },
}
` + simpleModuleDoNotConvertBp2build("cc_library_headers", "foo_export"),
expectedBazelTargets: []string{
makeBazelTarget("cc_library_headers", "foo_headers", attrNameToString{
"deps": `[":foo_export"]`,
}),
},
})
}
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{},
blueprint: soongCcLibraryHeadersPreamble + `
cc_library_headers {
name: "foo_headers",
export_shared_lib_headers: ["foo_export"],
shared_libs: ["foo_export", "foo_no_reexport"],
bazel_module: { bp2build_available: true },
}
` + simpleModuleDoNotConvertBp2build("cc_library_headers", "foo_export"),
expectedBazelTargets: []string{
makeBazelTarget("cc_library_headers", "foo_headers", attrNameToString{
"deps": `[":foo_export"]`,
}),
},
})
}
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{},
blueprint: soongCcLibraryHeadersPreamble + `
cc_library_headers {
name: "foo_headers",
export_header_lib_headers: ["foo_export"],
header_libs: ["foo_export", "foo_no_reexport"],
bazel_module: { bp2build_available: true },
}
` + simpleModuleDoNotConvertBp2build("cc_library_headers", "foo_export"),
expectedBazelTargets: []string{
makeBazelTarget("cc_library_headers", "foo_headers", attrNameToString{
"deps": `[":foo_export"]`,
}),
},
})
}

View file

@ -125,6 +125,7 @@ func libraryHeadersBp2Build(ctx android.TopDownMutatorContext, module *Module) {
baseAttributes := bp2BuildParseBaseProps(ctx, module)
exportedIncludes := bp2BuildParseExportedIncludes(ctx, module, &baseAttributes.includes)
linkerAttrs := baseAttributes.linkerAttributes
(&linkerAttrs.deps).Append(linkerAttrs.dynamicDeps)
attrs := &bazelCcLibraryHeadersAttributes{
Export_includes: exportedIncludes.Includes,