Dynamically link static libs for sdk_library created java_library

Rename java_library created inside sdk_library with the ".from-source"
suffix, and set it as static lib of the top level java_library, which
gets java_api_library instead as static lib during from-text stub build.

Test: m nothing && m nothing --build-from-text-stub
Bug: 286446015
Change-Id: I32e8ea264987e9f9df05e462292bd54e45074912
This commit is contained in:
Jihoon Kang
2023-06-08 23:25:57 +00:00
parent 5244c1a19f
commit 1147b31eb0
6 changed files with 117 additions and 56 deletions

View File

@@ -1388,12 +1388,20 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
// prebuilt dependencies until we support modules in the platform build, so there shouldn't be
// any if len(jars) == 1.
// moduleStubLinkType determines if the module is the TopLevelStubLibrary generated
// from sdk_library. The TopLevelStubLibrary contains only one static lib,
// either with .from-source or .from-text suffix.
// outputFile should be agnostic to the build configuration,
// thus "combine" the single static lib in order to prevent the static lib from being exposed
// to the copy rules.
stub, _ := moduleStubLinkType(ctx.ModuleName())
// Transform the single path to the jar into an OutputPath as that is required by the following
// code.
if moduleOutPath, ok := jars[0].(android.ModuleOutPath); ok {
if moduleOutPath, ok := jars[0].(android.ModuleOutPath); ok && !stub {
// The path contains an embedded OutputPath so reuse that.
outputFile = moduleOutPath.OutputPath
} else if outputPath, ok := jars[0].(android.OutputPath); ok {
} else if outputPath, ok := jars[0].(android.OutputPath); ok && !stub {
// The path is an OutputPath so reuse it directly.
outputFile = outputPath
} else {