Merge "Delete ApiBp2build soong_build mode" into main
This commit is contained in:
@@ -2839,205 +2839,6 @@ cc_library {
|
||||
)
|
||||
}
|
||||
|
||||
func TestCcApiContributionsWithHdrs(t *testing.T) {
|
||||
bp := `
|
||||
cc_library {
|
||||
name: "libfoo",
|
||||
stubs: { symbol_file: "libfoo.map.txt", versions: ["28", "29", "current"] },
|
||||
llndk: { symbol_file: "libfoo.map.txt", override_export_include_dirs: ["dir2"]},
|
||||
export_include_dirs: ["dir1"],
|
||||
}
|
||||
`
|
||||
expectedBazelTargets := []string{
|
||||
MakeBazelTarget(
|
||||
"cc_api_library_headers",
|
||||
"libfoo.module-libapi.headers",
|
||||
AttrNameToString{
|
||||
"export_includes": `["dir1"]`,
|
||||
}),
|
||||
MakeBazelTarget(
|
||||
"cc_api_library_headers",
|
||||
"libfoo.vendorapi.headers",
|
||||
AttrNameToString{
|
||||
"export_includes": `["dir2"]`,
|
||||
}),
|
||||
MakeBazelTarget(
|
||||
"cc_api_contribution",
|
||||
"libfoo.contribution",
|
||||
AttrNameToString{
|
||||
"api": `"libfoo.map.txt"`,
|
||||
"library_name": `"libfoo"`,
|
||||
"api_surfaces": `[
|
||||
"module-libapi",
|
||||
"vendorapi",
|
||||
]`,
|
||||
"hdrs": `[
|
||||
":libfoo.module-libapi.headers",
|
||||
":libfoo.vendorapi.headers",
|
||||
]`,
|
||||
}),
|
||||
}
|
||||
RunApiBp2BuildTestCase(t, cc.RegisterLibraryBuildComponents, Bp2buildTestCase{
|
||||
Blueprint: bp,
|
||||
Description: "cc API contributions to module-libapi and vendorapi",
|
||||
ExpectedBazelTargets: expectedBazelTargets,
|
||||
})
|
||||
}
|
||||
|
||||
func TestCcApiSurfaceCombinations(t *testing.T) {
|
||||
testCases := []struct {
|
||||
bp string
|
||||
expectedApi string
|
||||
expectedApiSurfaces string
|
||||
description string
|
||||
}{
|
||||
{
|
||||
bp: `
|
||||
cc_library {
|
||||
name: "a",
|
||||
stubs: {symbol_file: "a.map.txt"},
|
||||
}`,
|
||||
expectedApi: `"a.map.txt"`,
|
||||
expectedApiSurfaces: `["module-libapi"]`,
|
||||
description: "Library that contributes to module-libapi",
|
||||
},
|
||||
{
|
||||
bp: `
|
||||
cc_library {
|
||||
name: "a",
|
||||
llndk: {symbol_file: "a.map.txt"},
|
||||
}`,
|
||||
expectedApi: `"a.map.txt"`,
|
||||
expectedApiSurfaces: `["vendorapi"]`,
|
||||
description: "Library that contributes to vendorapi",
|
||||
},
|
||||
{
|
||||
bp: `
|
||||
cc_library {
|
||||
name: "a",
|
||||
llndk: {symbol_file: "a.map.txt"},
|
||||
stubs: {symbol_file: "a.map.txt"},
|
||||
}`,
|
||||
expectedApi: `"a.map.txt"`,
|
||||
expectedApiSurfaces: `[
|
||||
"module-libapi",
|
||||
"vendorapi",
|
||||
]`,
|
||||
description: "Library that contributes to module-libapi and vendorapi",
|
||||
},
|
||||
}
|
||||
for _, testCase := range testCases {
|
||||
expectedBazelTargets := []string{
|
||||
MakeBazelTarget(
|
||||
"cc_api_contribution",
|
||||
"a.contribution",
|
||||
AttrNameToString{
|
||||
"library_name": `"a"`,
|
||||
"hdrs": `[]`,
|
||||
"api": testCase.expectedApi,
|
||||
"api_surfaces": testCase.expectedApiSurfaces,
|
||||
},
|
||||
),
|
||||
}
|
||||
RunApiBp2BuildTestCase(t, cc.RegisterLibraryBuildComponents, Bp2buildTestCase{
|
||||
Blueprint: testCase.bp,
|
||||
Description: testCase.description,
|
||||
ExpectedBazelTargets: expectedBazelTargets,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// llndk struct property in Soong provides users with several options to configure the exported include dirs
|
||||
// Test the generated bazel targets for the different configurations
|
||||
func TestCcVendorApiHeaders(t *testing.T) {
|
||||
testCases := []struct {
|
||||
bp string
|
||||
expectedIncludes string
|
||||
expectedSystemIncludes string
|
||||
description string
|
||||
}{
|
||||
{
|
||||
bp: `
|
||||
cc_library {
|
||||
name: "a",
|
||||
export_include_dirs: ["include"],
|
||||
export_system_include_dirs: ["base_system_include"],
|
||||
llndk: {
|
||||
symbol_file: "a.map.txt",
|
||||
export_headers_as_system: true,
|
||||
},
|
||||
}
|
||||
`,
|
||||
expectedIncludes: "",
|
||||
expectedSystemIncludes: `[
|
||||
"base_system_include",
|
||||
"include",
|
||||
]`,
|
||||
description: "Headers are exported as system to API surface",
|
||||
},
|
||||
{
|
||||
bp: `
|
||||
cc_library {
|
||||
name: "a",
|
||||
export_include_dirs: ["include"],
|
||||
export_system_include_dirs: ["base_system_include"],
|
||||
llndk: {
|
||||
symbol_file: "a.map.txt",
|
||||
override_export_include_dirs: ["llndk_include"],
|
||||
},
|
||||
}
|
||||
`,
|
||||
expectedIncludes: `["llndk_include"]`,
|
||||
expectedSystemIncludes: `["base_system_include"]`,
|
||||
description: "Non-system Headers are ovverriden before export to API surface",
|
||||
},
|
||||
{
|
||||
bp: `
|
||||
cc_library {
|
||||
name: "a",
|
||||
export_include_dirs: ["include"],
|
||||
export_system_include_dirs: ["base_system_include"],
|
||||
llndk: {
|
||||
symbol_file: "a.map.txt",
|
||||
override_export_include_dirs: ["llndk_include"],
|
||||
export_headers_as_system: true,
|
||||
},
|
||||
}
|
||||
`,
|
||||
expectedIncludes: "", // includes are set to nil
|
||||
expectedSystemIncludes: `[
|
||||
"base_system_include",
|
||||
"llndk_include",
|
||||
]`,
|
||||
description: "System Headers are extended before export to API surface",
|
||||
},
|
||||
}
|
||||
for _, testCase := range testCases {
|
||||
attrs := AttrNameToString{}
|
||||
if testCase.expectedIncludes != "" {
|
||||
attrs["export_includes"] = testCase.expectedIncludes
|
||||
}
|
||||
if testCase.expectedSystemIncludes != "" {
|
||||
attrs["export_system_includes"] = testCase.expectedSystemIncludes
|
||||
}
|
||||
|
||||
expectedBazelTargets := []string{
|
||||
MakeBazelTarget("cc_api_library_headers", "a.vendorapi.headers", attrs),
|
||||
// Create a target for cc_api_contribution target
|
||||
MakeBazelTarget("cc_api_contribution", "a.contribution", AttrNameToString{
|
||||
"api": `"a.map.txt"`,
|
||||
"api_surfaces": `["vendorapi"]`,
|
||||
"hdrs": `[":a.vendorapi.headers"]`,
|
||||
"library_name": `"a"`,
|
||||
}),
|
||||
}
|
||||
RunApiBp2BuildTestCase(t, cc.RegisterLibraryBuildComponents, Bp2buildTestCase{
|
||||
Blueprint: testCase.bp,
|
||||
ExpectedBazelTargets: expectedBazelTargets,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestCcLibraryStubsAcrossConfigsDuplicatesRemoved(t *testing.T) {
|
||||
runCcLibraryTestCase(t, Bp2buildTestCase{
|
||||
Description: "stub target generation of the same lib across configs should not result in duplicates",
|
||||
|
Reference in New Issue
Block a user