Let LLNDK implementation libraries depend on LLNDK headers

The ABI checker dumps the ABI from the source code of LLNDK
implementation libraries. It needs to filter the ABI by the LLNDK
headers.

This commit adds dependencies from LLNDK implementation libraries to
their export_llndk_headers. The LLNDK header directories are added to
PathDeps. A followup change will pass the directories to the ABI
checker.

Bug: 314010764
Test: make
Change-Id: Ibc2d5eac3d70d9e038e0fd255cd1ebc1044fabbe
This commit is contained in:
Hsin-Yi Chen
2024-03-27 16:31:16 +08:00
parent af369886e5
commit 715142a20b
2 changed files with 29 additions and 0 deletions

View File

@@ -137,6 +137,12 @@ type Deps struct {
ExcludeLibsForApex []string
// List of libs that need to be excluded for non-APEX variant
ExcludeLibsForNonApex []string
// LLNDK headers for the ABI checker to check LLNDK implementation library.
// An LLNDK implementation is the core variant. LLNDK header libs are reexported by the vendor variant.
// The core variant cannot depend on the vendor variant because of the order of CreateVariations.
// Instead, the LLNDK implementation depends on the LLNDK header libs.
LlndkHeaderLibs []string
}
// PathDeps is a struct containing file paths to dependencies of a module.
@@ -192,6 +198,10 @@ type PathDeps struct {
// Paths to direct srcs and transitive include dirs from direct aidl_library deps
AidlLibraryInfos []aidl_library.AidlLibraryInfo
// LLNDK headers for the ABI checker to check LLNDK implementation library.
LlndkIncludeDirs android.Paths
LlndkSystemIncludeDirs android.Paths
}
// LocalOrGlobalFlags contains flags that need to have values set globally by the build system or locally by the module
@@ -809,6 +819,7 @@ var (
JniFuzzLibTag = dependencyTag{name: "jni_fuzz_lib_tag"}
FdoProfileTag = dependencyTag{name: "fdo_profile"}
aidlLibraryTag = dependencyTag{name: "aidl_library"}
llndkHeaderLibTag = dependencyTag{name: "llndk_header_lib"}
)
func IsSharedDepTag(depTag blueprint.DependencyTag) bool {
@@ -2316,6 +2327,7 @@ func (c *Module) deps(ctx DepsContext) Deps {
deps.LateSharedLibs = android.LastUniqueStrings(deps.LateSharedLibs)
deps.HeaderLibs = android.LastUniqueStrings(deps.HeaderLibs)
deps.RuntimeLibs = android.LastUniqueStrings(deps.RuntimeLibs)
deps.LlndkHeaderLibs = android.LastUniqueStrings(deps.LlndkHeaderLibs)
for _, lib := range deps.ReexportSharedLibHeaders {
if !inList(lib, deps.SharedLibs) {
@@ -2627,6 +2639,15 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
), stubImplementation, c.BaseModuleName())
}
// If this module is an LLNDK implementation library, let it depend on LlndkHeaderLibs.
if c.ImageVariation().Variation == android.CoreVariation && c.Device() &&
c.Target().NativeBridge == android.NativeBridgeDisabled {
actx.AddVariationDependencies(
[]blueprint.Variation{{Mutator: "image", Variation: VendorVariation}},
llndkHeaderLibTag,
deps.LlndkHeaderLibs...)
}
for _, lib := range deps.WholeStaticLibs {
depTag := libraryDependencyTag{Kind: staticLibraryDependency, wholeStatic: true, reexportFlags: true}
@@ -3187,6 +3208,12 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
return
}
if depTag == llndkHeaderLibTag {
depExporterInfo, _ := android.OtherModuleProvider(ctx, dep, FlagExporterInfoProvider)
depPaths.LlndkIncludeDirs = append(depPaths.LlndkIncludeDirs, depExporterInfo.IncludeDirs...)
depPaths.LlndkSystemIncludeDirs = append(depPaths.LlndkSystemIncludeDirs, depExporterInfo.SystemIncludeDirs...)
}
linkFile := ccDep.OutputFile()
if libDepTag, ok := depTag.(libraryDependencyTag); ok {

View File

@@ -976,6 +976,8 @@ func (library *libraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.ReexportSharedLibHeaders = append(deps.ReexportSharedLibHeaders, library.SharedProperties.Shared.Export_shared_lib_headers...)
deps.ReexportStaticLibHeaders = append(deps.ReexportStaticLibHeaders, library.SharedProperties.Shared.Export_static_lib_headers...)
deps.LlndkHeaderLibs = append(deps.LlndkHeaderLibs, library.Properties.Llndk.Export_llndk_headers...)
}
if ctx.inVendor() {
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, library.baseLinker.Properties.Target.Vendor.Exclude_static_libs)