Create LLNDK vendor variants when DeviceVndkVersion is not set

The LLNDK vendor variants need to exist even when the VNDK is not
being used in order for the next patch to list them once the global
maps are removed.

Bug: 176904285
Test: m checkbuild
Change-Id: Ib29ede455d5b6a4b7d3f4685db8fba6d32025314
This commit is contained in:
Colin Cross 2021-01-06 17:05:04 -08:00
parent 9aed5bc715
commit b5f6fa678d
3 changed files with 49 additions and 39 deletions

View file

@ -738,12 +738,29 @@ func TestVndkWhenVndkVersionIsNotSet(t *testing.T) {
},
nocrt: true,
}
cc_library {
name: "libllndk",
llndk_stubs: "libllndk.llndk",
}
llndk_library {
name: "libllndk.llndk",
symbol_file: "",
export_llndk_headers: ["libllndk_headers"],
}
llndk_headers {
name: "libllndk_headers",
export_include_dirs: ["include"],
}
`)
checkVndkOutput(t, ctx, "vndk/vndk.libraries.txt", []string{
"LLNDK: libc.so",
"LLNDK: libdl.so",
"LLNDK: libft2.so",
"LLNDK: libllndk.so",
"LLNDK: libm.so",
"VNDK-SP: libc++.so",
"VNDK-core: libvndk-private.so",

View file

@ -282,31 +282,34 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
productVndkVersion = platformVndkVersion
}
if boardVndkVersion == "" {
_, isLLNDKLibrary := m.linker.(*llndkStubDecorator)
_, isLLNDKHeaders := m.linker.(*llndkHeadersDecorator)
lib := moduleLibraryInterface(m)
hasLLNDKStubs := lib != nil && lib.hasLLNDKStubs()
if isLLNDKLibrary || isLLNDKHeaders || hasLLNDKStubs {
// This is an LLNDK library. The implementation of the library will be on /system,
// and vendor and product variants will be created with LLNDK stubs.
// The LLNDK libraries need vendor variants even if there is no VNDK.
// The obsolete llndk_library and llndk_headers modules also need the vendor variants
// so the cc_library LLNDK stubs can depend on them.
if hasLLNDKStubs {
coreVariantNeeded = true
}
if platformVndkVersion != "" {
vendorVariants = append(vendorVariants, platformVndkVersion)
productVariants = append(productVariants, platformVndkVersion)
}
if boardVndkVersion != "" {
vendorVariants = append(vendorVariants, boardVndkVersion)
}
if productVndkVersion != "" {
productVariants = append(productVariants, productVndkVersion)
}
} else if boardVndkVersion == "" {
// If the device isn't compiling against the VNDK, we always
// use the core mode.
coreVariantNeeded = true
} else if _, ok := m.linker.(*llndkStubDecorator); ok {
// LL-NDK stubs only exist in the vendor and product variants,
// since the real libraries will be used in the core variant.
vendorVariants = append(vendorVariants,
platformVndkVersion,
boardVndkVersion,
)
productVariants = append(productVariants,
platformVndkVersion,
productVndkVersion,
)
} else if _, ok := m.linker.(*llndkHeadersDecorator); ok {
// ... and LL-NDK headers as well
vendorVariants = append(vendorVariants,
platformVndkVersion,
boardVndkVersion,
)
productVariants = append(productVariants,
platformVndkVersion,
productVndkVersion,
)
} else if m.isSnapshotPrebuilt() {
// Make vendor variants only for the versions in BOARD_VNDK_VERSION and
// PRODUCT_EXTRA_VNDK_VERSIONS.
@ -364,18 +367,6 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
} else {
vendorVariants = append(vendorVariants, platformVndkVersion)
}
} else if lib := moduleLibraryInterface(m); lib != nil && lib.hasLLNDKStubs() {
// This is an LLNDK library. The implementation of the library will be on /system,
// and vendor and product variants will be created with LLNDK stubs.
coreVariantNeeded = true
vendorVariants = append(vendorVariants,
platformVndkVersion,
boardVndkVersion,
)
productVariants = append(productVariants,
platformVndkVersion,
productVndkVersion,
)
} else {
// This is either in /system (or similar: /data), or is a
// modules built with the NDK. Modules built with the NDK

View file

@ -161,6 +161,13 @@ type llndkHeadersDecorator struct {
*libraryDecorator
}
func (llndk *llndkHeadersDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.HeaderLibs = append(deps.HeaderLibs, llndk.Properties.Llndk.Export_llndk_headers...)
deps.ReexportHeaderLibHeaders = append(deps.ReexportHeaderLibHeaders,
llndk.Properties.Llndk.Export_llndk_headers...)
return deps
}
// llndk_headers contains a set of c/c++ llndk headers files which are imported
// by other soongs cc modules.
func llndkHeadersFactory() android.Module {
@ -178,11 +185,6 @@ func llndkHeadersFactory() android.Module {
module.installer = nil
module.library = decorator
module.AddProperties(
&module.Properties,
&library.MutatedProperties,
&library.flagExporter.Properties)
module.Init()
return module