Merge "Call PackageFile for dexpreopt files of APEX bundles." into main am: 9034af498e

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3128073

Change-Id: I40cce87cc466de96df45e05c9a6cf7b073725ec8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2024-06-13 21:49:51 +00:00
committed by Automerger Merge Worker
3 changed files with 18 additions and 3 deletions

View File

@@ -1663,12 +1663,12 @@ var _ javaModule = (*java.DexImport)(nil)
var _ javaModule = (*java.SdkLibraryImport)(nil)
// apexFileForJavaModule creates an apexFile for a java module's dex implementation jar.
func apexFileForJavaModule(ctx android.BaseModuleContext, module javaModule) apexFile {
func apexFileForJavaModule(ctx android.ModuleContext, module javaModule) apexFile {
return apexFileForJavaModuleWithFile(ctx, module, module.DexJarBuildPath(ctx).PathOrNil())
}
// apexFileForJavaModuleWithFile creates an apexFile for a java module with the supplied file.
func apexFileForJavaModuleWithFile(ctx android.BaseModuleContext, module javaModule, dexImplementationJar android.Path) apexFile {
func apexFileForJavaModuleWithFile(ctx android.ModuleContext, module javaModule, dexImplementationJar android.Path) apexFile {
dirInApex := "javalib"
af := newApexFile(ctx, dexImplementationJar, module.BaseModuleName(), dirInApex, javaSharedLib, module)
af.jacocoReportClassesFile = module.JacocoReportClassesFile()
@@ -1679,10 +1679,12 @@ func apexFileForJavaModuleWithFile(ctx android.BaseModuleContext, module javaMod
if sdkLib, ok := module.(*java.SdkLibrary); ok {
for _, install := range sdkLib.BuiltInstalledForApex() {
af.requiredModuleNames = append(af.requiredModuleNames, install.FullModuleName())
install.PackageFile(ctx)
}
} else if dexpreopter, ok := module.(java.DexpreopterInterface); ok {
for _, install := range dexpreopter.DexpreoptBuiltInstalledForApex() {
af.requiredModuleNames = append(af.requiredModuleNames, install.FullModuleName())
install.PackageFile(ctx)
}
}
return af

View File

@@ -197,6 +197,7 @@ func (p *prebuiltCommon) initApexFilesForAndroidMk(ctx android.ModuleContext) {
// If this apex contains a system server jar, then the dexpreopt artifacts should be added as required
for _, install := range p.Dexpreopter.DexpreoptBuiltInstalledForApex() {
p.requiredModuleNames = append(p.requiredModuleNames, install.FullModuleName())
install.PackageFile(ctx)
}
}

View File

@@ -96,6 +96,10 @@ func (install dexpreopterInstall) ToMakeEntries() android.AndroidMkEntries {
}
}
func (install dexpreopterInstall) PackageFile(ctx android.ModuleContext) android.PackagingSpec {
return ctx.PackageFile(install.installDirOnDevice, install.installFileOnDevice, install.outputPathOnHost)
}
type Dexpreopter struct {
dexpreopter
}
@@ -541,10 +545,18 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, libName string, dexJa
// Use the path of the dex file to determine the library name
isApexSystemServerJar := global.AllApexSystemServerJars(ctx).ContainsJar(dexJarStem)
partition := d.installPath.Partition()
dexpreoptPartition := d.installPath.Partition()
// dexpreoptPartition is set to empty for dexpreopts of system APEX and system_other.
// In case of system APEX, however, we can set it to "system" manually.
// TODO(b/346662300): Let dexpreopter generate the installPath for dexpreopt files instead of
// using the dex location to generate the installPath.
if isApexSystemServerJar {
dexpreoptPartition = "system"
}
for _, install := range dexpreoptRule.Installs() {
// Remove the "/" prefix because the path should be relative to $ANDROID_PRODUCT_OUT.
installDir := strings.TrimPrefix(filepath.Dir(install.To), "/")
partition := dexpreoptPartition
if strings.HasPrefix(installDir, partition+"/") {
installDir = strings.TrimPrefix(installDir, partition+"/")
} else {