Support cc_library as LLNDK without llndk_library
Allow cc_library modules to configure themselves as an LLNDK library using llndk.symbol_file instead of llndk_stubs pointing to an llndk_library module. Bug: 170784825 Test: TestEmbeddedLlndkLibrary Change-Id: Id884cdada7094bbea6809a98e687e039778c5dc6
This commit is contained in:
7
cc/cc.go
7
cc/cc.go
@@ -1145,12 +1145,7 @@ func (m *Module) HasLlndkStubs() bool {
|
|||||||
func (c *Module) isImplementationForLLNDKPublic() bool {
|
func (c *Module) isImplementationForLLNDKPublic() bool {
|
||||||
library, _ := c.library.(*libraryDecorator)
|
library, _ := c.library.(*libraryDecorator)
|
||||||
return library != nil && library.hasLLNDKStubs() &&
|
return library != nil && library.hasLLNDKStubs() &&
|
||||||
(!Bool(library.Properties.Llndk.Private) ||
|
!Bool(library.Properties.Llndk.Private)
|
||||||
// TODO(b/170784825): until the LLNDK properties are moved into the cc_library,
|
|
||||||
// the non-Vendor variants of the cc_library don't know if the corresponding
|
|
||||||
// llndk_library set private: true. Since libft2 is the only private LLNDK
|
|
||||||
// library, hardcode it during the transition.
|
|
||||||
c.BaseModuleName() != "libft2")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true for LLNDK-private, VNDK-SP-private, and VNDK-core-private.
|
// Returns true for LLNDK-private, VNDK-SP-private, and VNDK-core-private.
|
||||||
|
@@ -2824,6 +2824,100 @@ func TestLlndkLibrary(t *testing.T) {
|
|||||||
checkEquals(t, "override apiLevel for versioned stubs", "1", params.Args["apiLevel"])
|
checkEquals(t, "override apiLevel for versioned stubs", "1", params.Args["apiLevel"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestEmbeddedLlndkLibrary(t *testing.T) {
|
||||||
|
result := prepareForCcTest.RunTestWithBp(t, `
|
||||||
|
cc_library {
|
||||||
|
name: "libllndk",
|
||||||
|
stubs: { versions: ["1", "2"] },
|
||||||
|
llndk: {
|
||||||
|
symbol_file: "libllndk.map.txt",
|
||||||
|
},
|
||||||
|
export_include_dirs: ["include"],
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_prebuilt_library_shared {
|
||||||
|
name: "libllndkprebuilt",
|
||||||
|
stubs: { versions: ["1", "2"] },
|
||||||
|
llndk: {
|
||||||
|
symbol_file: "libllndkprebuilt.map.txt",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library {
|
||||||
|
name: "libllndk_with_external_headers",
|
||||||
|
stubs: { versions: ["1", "2"] },
|
||||||
|
llndk: {
|
||||||
|
symbol_file: "libllndk.map.txt",
|
||||||
|
export_llndk_headers: ["libexternal_llndk_headers"],
|
||||||
|
},
|
||||||
|
header_libs: ["libexternal_headers"],
|
||||||
|
export_header_lib_headers: ["libexternal_headers"],
|
||||||
|
}
|
||||||
|
cc_library_headers {
|
||||||
|
name: "libexternal_headers",
|
||||||
|
export_include_dirs: ["include"],
|
||||||
|
vendor_available: true,
|
||||||
|
}
|
||||||
|
cc_library_headers {
|
||||||
|
name: "libexternal_llndk_headers",
|
||||||
|
export_include_dirs: ["include_llndk"],
|
||||||
|
llndk: {
|
||||||
|
symbol_file: "libllndk.map.txt",
|
||||||
|
},
|
||||||
|
vendor_available: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library {
|
||||||
|
name: "libllndk_with_override_headers",
|
||||||
|
stubs: { versions: ["1", "2"] },
|
||||||
|
llndk: {
|
||||||
|
symbol_file: "libllndk.map.txt",
|
||||||
|
override_export_include_dirs: ["include_llndk"],
|
||||||
|
},
|
||||||
|
export_include_dirs: ["include"],
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
actual := result.ModuleVariantsForTests("libllndk")
|
||||||
|
for i := 0; i < len(actual); i++ {
|
||||||
|
if !strings.HasPrefix(actual[i], "android_vendor.29_") {
|
||||||
|
actual = append(actual[:i], actual[i+1:]...)
|
||||||
|
i--
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expected := []string{
|
||||||
|
"android_vendor.29_arm64_armv8-a_shared_1",
|
||||||
|
"android_vendor.29_arm64_armv8-a_shared_2",
|
||||||
|
"android_vendor.29_arm64_armv8-a_shared_current",
|
||||||
|
"android_vendor.29_arm64_armv8-a_shared",
|
||||||
|
"android_vendor.29_arm_armv7-a-neon_shared_1",
|
||||||
|
"android_vendor.29_arm_armv7-a-neon_shared_2",
|
||||||
|
"android_vendor.29_arm_armv7-a-neon_shared_current",
|
||||||
|
"android_vendor.29_arm_armv7-a-neon_shared",
|
||||||
|
}
|
||||||
|
android.AssertArrayString(t, "variants for llndk stubs", expected, actual)
|
||||||
|
|
||||||
|
params := result.ModuleForTests("libllndk", "android_vendor.29_arm_armv7-a-neon_shared").Description("generate stub")
|
||||||
|
android.AssertSame(t, "use VNDK version for default stubs", "current", params.Args["apiLevel"])
|
||||||
|
|
||||||
|
params = result.ModuleForTests("libllndk", "android_vendor.29_arm_armv7-a-neon_shared_1").Description("generate stub")
|
||||||
|
android.AssertSame(t, "override apiLevel for versioned stubs", "1", params.Args["apiLevel"])
|
||||||
|
|
||||||
|
checkExportedIncludeDirs := func(module, variant string, expectedDirs ...string) {
|
||||||
|
t.Helper()
|
||||||
|
m := result.ModuleForTests(module, variant).Module()
|
||||||
|
f := result.ModuleProvider(m, FlagExporterInfoProvider).(FlagExporterInfo)
|
||||||
|
android.AssertPathsRelativeToTopEquals(t, "exported include dirs for "+module+"["+variant+"]",
|
||||||
|
expectedDirs, f.IncludeDirs)
|
||||||
|
}
|
||||||
|
|
||||||
|
checkExportedIncludeDirs("libllndk", "android_arm64_armv8-a_shared", "include")
|
||||||
|
checkExportedIncludeDirs("libllndk", "android_vendor.29_arm64_armv8-a_shared", "include")
|
||||||
|
checkExportedIncludeDirs("libllndk_with_external_headers", "android_arm64_armv8-a_shared", "include")
|
||||||
|
checkExportedIncludeDirs("libllndk_with_external_headers", "android_vendor.29_arm64_armv8-a_shared", "include_llndk")
|
||||||
|
checkExportedIncludeDirs("libllndk_with_override_headers", "android_arm64_armv8-a_shared", "include")
|
||||||
|
checkExportedIncludeDirs("libllndk_with_override_headers", "android_vendor.29_arm64_armv8-a_shared", "include_llndk")
|
||||||
|
}
|
||||||
|
|
||||||
func TestLlndkHeaders(t *testing.T) {
|
func TestLlndkHeaders(t *testing.T) {
|
||||||
ctx := testCc(t, `
|
ctx := testCc(t, `
|
||||||
llndk_headers {
|
llndk_headers {
|
||||||
|
@@ -960,9 +960,8 @@ func (library *libraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
|||||||
if ctx.IsLlndk() {
|
if ctx.IsLlndk() {
|
||||||
// LLNDK libraries ignore most of the properties on the cc_library and use the
|
// LLNDK libraries ignore most of the properties on the cc_library and use the
|
||||||
// LLNDK-specific properties instead.
|
// LLNDK-specific properties instead.
|
||||||
deps.HeaderLibs = append(deps.HeaderLibs, library.Properties.Llndk.Export_llndk_headers...)
|
deps.HeaderLibs = append([]string(nil), library.Properties.Llndk.Export_llndk_headers...)
|
||||||
deps.ReexportHeaderLibHeaders = append(deps.ReexportHeaderLibHeaders,
|
deps.ReexportHeaderLibHeaders = append([]string(nil), library.Properties.Llndk.Export_llndk_headers...)
|
||||||
library.Properties.Llndk.Export_llndk_headers...)
|
|
||||||
return deps
|
return deps
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1407,6 +1406,12 @@ func (library *libraryDecorator) link(ctx ModuleContext,
|
|||||||
library.reexportDeps(timestampFiles...)
|
library.reexportDeps(timestampFiles...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// override the module's export_include_dirs with llndk.override_export_include_dirs
|
||||||
|
// if it is set.
|
||||||
|
if override := library.Properties.Llndk.Override_export_include_dirs; override != nil {
|
||||||
|
library.flagExporter.Properties.Export_include_dirs = override
|
||||||
|
}
|
||||||
|
|
||||||
if Bool(library.Properties.Llndk.Export_headers_as_system) {
|
if Bool(library.Properties.Llndk.Export_headers_as_system) {
|
||||||
library.flagExporter.Properties.Export_system_include_dirs = append(
|
library.flagExporter.Properties.Export_system_include_dirs = append(
|
||||||
library.flagExporter.Properties.Export_system_include_dirs,
|
library.flagExporter.Properties.Export_system_include_dirs,
|
||||||
@@ -1668,6 +1673,13 @@ func (library *libraryDecorator) HeaderOnly() {
|
|||||||
|
|
||||||
// hasLLNDKStubs returns true if this cc_library module has a variant that will build LLNDK stubs.
|
// hasLLNDKStubs returns true if this cc_library module has a variant that will build LLNDK stubs.
|
||||||
func (library *libraryDecorator) hasLLNDKStubs() bool {
|
func (library *libraryDecorator) hasLLNDKStubs() bool {
|
||||||
|
return library.hasVestigialLLNDKLibrary() || String(library.Properties.Llndk.Symbol_file) != ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// hasVestigialLLNDKLibrary returns true if this cc_library module has a corresponding llndk_library
|
||||||
|
// module containing properties describing the LLNDK variant.
|
||||||
|
// TODO(b/170784825): remove this once there are no more llndk_library modules.
|
||||||
|
func (library *libraryDecorator) hasVestigialLLNDKLibrary() bool {
|
||||||
return String(library.Properties.Llndk_stubs) != ""
|
return String(library.Properties.Llndk_stubs) != ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -56,7 +56,12 @@ type llndkLibraryProperties struct {
|
|||||||
Unversioned *bool
|
Unversioned *bool
|
||||||
|
|
||||||
// list of llndk headers to re-export include directories from.
|
// list of llndk headers to re-export include directories from.
|
||||||
Export_llndk_headers []string `android:"arch_variant"`
|
Export_llndk_headers []string
|
||||||
|
|
||||||
|
// list of directories relative to the Blueprints file that willbe added to the include path
|
||||||
|
// (using -I) for any module that links against the LLNDK variant of this module, replacing
|
||||||
|
// any that were listed outside the llndk clause.
|
||||||
|
Override_export_include_dirs []string
|
||||||
|
|
||||||
// whether this module can be directly depended upon by libs that are installed
|
// whether this module can be directly depended upon by libs that are installed
|
||||||
// to /vendor and /product.
|
// to /vendor and /product.
|
||||||
|
15
cc/vndk.go
15
cc/vndk.go
@@ -233,7 +233,7 @@ func vndkIsVndkDepAllowed(from *vndkdep, to *vndkdep) error {
|
|||||||
type moduleListerFunc func(ctx android.SingletonContext) (moduleNames, fileNames []string)
|
type moduleListerFunc func(ctx android.SingletonContext) (moduleNames, fileNames []string)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
llndkLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsLLNDK && !isVestigialLLNDKModule(m) })
|
llndkLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsLLNDK && !isVestigialLLNDKModule(m) && !m.Header() })
|
||||||
llndkLibrariesWithoutHWASAN = vndkModuleListRemover(llndkLibraries, "libclang_rt.hwasan-")
|
llndkLibrariesWithoutHWASAN = vndkModuleListRemover(llndkLibraries, "libclang_rt.hwasan-")
|
||||||
vndkSPLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsVNDKSP })
|
vndkSPLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsVNDKSP })
|
||||||
vndkCoreLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsVNDKCore })
|
vndkCoreLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsVNDKCore })
|
||||||
@@ -423,15 +423,24 @@ func VndkMutator(mctx android.BottomUpMutatorContext) {
|
|||||||
lib, isLib := m.linker.(*libraryDecorator)
|
lib, isLib := m.linker.(*libraryDecorator)
|
||||||
prebuiltLib, isPrebuiltLib := m.linker.(*prebuiltLibraryLinker)
|
prebuiltLib, isPrebuiltLib := m.linker.(*prebuiltLibraryLinker)
|
||||||
|
|
||||||
if m.UseVndk() && isLib && lib.hasLLNDKStubs() {
|
if m.UseVndk() && isLib && lib.hasVestigialLLNDKLibrary() {
|
||||||
llndk := mctx.AddVariationDependencies(nil, llndkStubDepTag, String(lib.Properties.Llndk_stubs))
|
llndk := mctx.AddVariationDependencies(nil, llndkStubDepTag, String(lib.Properties.Llndk_stubs))
|
||||||
mergeLLNDKToLib(llndk[0].(*Module), &lib.Properties.Llndk, &lib.flagExporter)
|
mergeLLNDKToLib(llndk[0].(*Module), &lib.Properties.Llndk, &lib.flagExporter)
|
||||||
}
|
}
|
||||||
if m.UseVndk() && isPrebuiltLib && prebuiltLib.hasLLNDKStubs() {
|
if m.UseVndk() && isPrebuiltLib && prebuiltLib.hasVestigialLLNDKLibrary() {
|
||||||
llndk := mctx.AddVariationDependencies(nil, llndkStubDepTag, String(prebuiltLib.Properties.Llndk_stubs))
|
llndk := mctx.AddVariationDependencies(nil, llndkStubDepTag, String(prebuiltLib.Properties.Llndk_stubs))
|
||||||
mergeLLNDKToLib(llndk[0].(*Module), &prebuiltLib.Properties.Llndk, &prebuiltLib.flagExporter)
|
mergeLLNDKToLib(llndk[0].(*Module), &prebuiltLib.Properties.Llndk, &prebuiltLib.flagExporter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if m.UseVndk() && isLib && lib.hasLLNDKStubs() && !lib.hasVestigialLLNDKLibrary() {
|
||||||
|
m.VendorProperties.IsLLNDK = true
|
||||||
|
m.VendorProperties.IsVNDKPrivate = Bool(lib.Properties.Llndk.Private)
|
||||||
|
}
|
||||||
|
if m.UseVndk() && isPrebuiltLib && prebuiltLib.hasLLNDKStubs() && !prebuiltLib.hasVestigialLLNDKLibrary() {
|
||||||
|
m.VendorProperties.IsLLNDK = true
|
||||||
|
m.VendorProperties.IsVNDKPrivate = Bool(prebuiltLib.Properties.Llndk.Private)
|
||||||
|
}
|
||||||
|
|
||||||
if (isLib && lib.buildShared()) || (isPrebuiltLib && prebuiltLib.buildShared()) {
|
if (isLib && lib.buildShared()) || (isPrebuiltLib && prebuiltLib.buildShared()) {
|
||||||
if m.vndkdep != nil && m.vndkdep.isVndk() && !m.vndkdep.isVndkExt() {
|
if m.vndkdep != nil && m.vndkdep.isVndk() && !m.vndkdep.isVndkExt() {
|
||||||
processVndkLibrary(mctx, m)
|
processVndkLibrary(mctx, m)
|
||||||
|
Reference in New Issue
Block a user