Merge "Call PackageFile for dexpreopt files of APEX bundles." into main
This commit is contained in:
commit
9034af498e
3 changed files with 18 additions and 3 deletions
|
@ -1677,12 +1677,12 @@ var _ javaModule = (*java.DexImport)(nil)
|
||||||
var _ javaModule = (*java.SdkLibraryImport)(nil)
|
var _ javaModule = (*java.SdkLibraryImport)(nil)
|
||||||
|
|
||||||
// apexFileForJavaModule creates an apexFile for a java module's dex implementation jar.
|
// 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())
|
return apexFileForJavaModuleWithFile(ctx, module, module.DexJarBuildPath(ctx).PathOrNil())
|
||||||
}
|
}
|
||||||
|
|
||||||
// apexFileForJavaModuleWithFile creates an apexFile for a java module with the supplied file.
|
// 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"
|
dirInApex := "javalib"
|
||||||
af := newApexFile(ctx, dexImplementationJar, module.BaseModuleName(), dirInApex, javaSharedLib, module)
|
af := newApexFile(ctx, dexImplementationJar, module.BaseModuleName(), dirInApex, javaSharedLib, module)
|
||||||
af.jacocoReportClassesFile = module.JacocoReportClassesFile()
|
af.jacocoReportClassesFile = module.JacocoReportClassesFile()
|
||||||
|
@ -1693,10 +1693,12 @@ func apexFileForJavaModuleWithFile(ctx android.BaseModuleContext, module javaMod
|
||||||
if sdkLib, ok := module.(*java.SdkLibrary); ok {
|
if sdkLib, ok := module.(*java.SdkLibrary); ok {
|
||||||
for _, install := range sdkLib.BuiltInstalledForApex() {
|
for _, install := range sdkLib.BuiltInstalledForApex() {
|
||||||
af.requiredModuleNames = append(af.requiredModuleNames, install.FullModuleName())
|
af.requiredModuleNames = append(af.requiredModuleNames, install.FullModuleName())
|
||||||
|
install.PackageFile(ctx)
|
||||||
}
|
}
|
||||||
} else if dexpreopter, ok := module.(java.DexpreopterInterface); ok {
|
} else if dexpreopter, ok := module.(java.DexpreopterInterface); ok {
|
||||||
for _, install := range dexpreopter.DexpreoptBuiltInstalledForApex() {
|
for _, install := range dexpreopter.DexpreoptBuiltInstalledForApex() {
|
||||||
af.requiredModuleNames = append(af.requiredModuleNames, install.FullModuleName())
|
af.requiredModuleNames = append(af.requiredModuleNames, install.FullModuleName())
|
||||||
|
install.PackageFile(ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return af
|
return af
|
||||||
|
|
|
@ -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
|
// If this apex contains a system server jar, then the dexpreopt artifacts should be added as required
|
||||||
for _, install := range p.Dexpreopter.DexpreoptBuiltInstalledForApex() {
|
for _, install := range p.Dexpreopter.DexpreoptBuiltInstalledForApex() {
|
||||||
p.requiredModuleNames = append(p.requiredModuleNames, install.FullModuleName())
|
p.requiredModuleNames = append(p.requiredModuleNames, install.FullModuleName())
|
||||||
|
install.PackageFile(ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 {
|
type Dexpreopter struct {
|
||||||
dexpreopter
|
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
|
// Use the path of the dex file to determine the library name
|
||||||
isApexSystemServerJar := global.AllApexSystemServerJars(ctx).ContainsJar(dexJarStem)
|
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() {
|
for _, install := range dexpreoptRule.Installs() {
|
||||||
// Remove the "/" prefix because the path should be relative to $ANDROID_PRODUCT_OUT.
|
// Remove the "/" prefix because the path should be relative to $ANDROID_PRODUCT_OUT.
|
||||||
installDir := strings.TrimPrefix(filepath.Dir(install.To), "/")
|
installDir := strings.TrimPrefix(filepath.Dir(install.To), "/")
|
||||||
|
partition := dexpreoptPartition
|
||||||
if strings.HasPrefix(installDir, partition+"/") {
|
if strings.HasPrefix(installDir, partition+"/") {
|
||||||
installDir = strings.TrimPrefix(installDir, partition+"/")
|
installDir = strings.TrimPrefix(installDir, partition+"/")
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue