Merge changes I9c94a54a,Idc0c73a7 am: 2c6ede11cc am: 23a5cba0af am: 57c29dd3e3 am: 36c6e5583f am: 9c4f4a179f

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

Change-Id: Ic1c8e0971d4807c92bdc8138a62c435862e70b69
This commit is contained in:
Jiakai Zhang
2021-09-17 12:23:41 +00:00
committed by Automerger Merge Worker
6 changed files with 51 additions and 10 deletions

View File

@@ -160,6 +160,10 @@ func (d *dexpreopter) dexpreoptDisabled(ctx android.BaseModuleContext) bool {
}
}
if !android.IsModulePreferred(ctx.Module()) {
return true
}
// TODO: contains no java code
return false
@@ -232,8 +236,7 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Wr
bootImage = artBootImageConfig(ctx)
}
// System server jars are an exception: they are dexpreopted without updatable bootclasspath.
dexFiles, dexLocations := bcpForDexpreopt(ctx, global.PreoptWithUpdatableBcp && !isSystemServerJar)
dexFiles, dexLocations := bcpForDexpreopt(ctx, global.PreoptWithUpdatableBcp)
targets := ctx.MultiTargets()
if len(targets) == 0 {

View File

@@ -1925,6 +1925,7 @@ type SdkLibraryImport struct {
android.SdkBase
hiddenAPI
dexpreopter
properties sdkLibraryImportProperties
@@ -2129,6 +2130,14 @@ func (module *SdkLibraryImport) DepsMutator(ctx android.BottomUpMutatorContext)
}
}
func (module *SdkLibraryImport) AndroidMkEntries() []android.AndroidMkEntries {
// For an SDK library imported from a prebuilt APEX, we don't need a Make module for itself, as we
// don't need to install it. However, we need to add its dexpreopt outputs as sub-modules, if it
// is preopted.
dexpreoptEntries := module.dexpreopter.AndroidMkEntriesForApex()
return append(dexpreoptEntries, android.AndroidMkEntries{Disabled: true})
}
var _ android.ApexModule = (*SdkLibraryImport)(nil)
// Implements android.ApexModule
@@ -2226,8 +2235,16 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo
di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo)
if dexOutputPath := di.PrebuiltExportPath(apexRootRelativePathToJavaLib(module.BaseModuleName())); dexOutputPath != nil {
module.dexJarFile = dexOutputPath
module.installFile = android.PathForModuleInPartitionInstall(ctx, "apex", ai.ApexVariationName, apexRootRelativePathToJavaLib(module.BaseModuleName()))
installPath := android.PathForModuleInPartitionInstall(
ctx, "apex", ai.ApexVariationName, apexRootRelativePathToJavaLib(module.BaseModuleName()))
module.installFile = installPath
module.initHiddenAPI(ctx, dexOutputPath, module.findScopePaths(apiScopePublic).stubsImplPath[0], nil)
// Dexpreopting.
module.dexpreopter.installPath = module.dexpreopter.getInstallPath(ctx, installPath)
module.dexpreopter.isSDKLibrary = true
module.dexpreopter.uncompressedDex = shouldUncompressDex(ctx, &module.dexpreopter)
module.dexpreopt(ctx, dexOutputPath)
} else {
// This should never happen as a variant for a prebuilt_apex is only created if the
// prebuilt_apex has been configured to export the java library dex file.
@@ -2346,6 +2363,11 @@ func (module *SdkLibraryImport) ImplementationAndResourcesJars() android.Paths {
}
}
// to satisfy java.DexpreopterInterface interface
func (module *SdkLibraryImport) IsInstallable() bool {
return true
}
var _ android.RequiredFilesFromPrebuiltApex = (*SdkLibraryImport)(nil)
func (module *SdkLibraryImport) RequiredFilesFromPrebuiltApex(ctx android.BaseModuleContext) []string {

View File

@@ -667,6 +667,7 @@ func TestJavaSdkLibraryImport(t *testing.T) {
}
CheckModuleDependencies(t, result.TestContext, "sdklib", "android_common", []string{
`dex2oatd`,
`prebuilt_sdklib.stubs`,
`prebuilt_sdklib.stubs.source.test`,
`prebuilt_sdklib.stubs.system`,
@@ -743,7 +744,6 @@ func TestJavaSdkLibraryImport_Preferred(t *testing.T) {
`)
CheckModuleDependencies(t, result.TestContext, "sdklib", "android_common", []string{
`dex2oatd`,
`prebuilt_sdklib`,
`sdklib.impl`,
`sdklib.stubs`,
@@ -752,6 +752,7 @@ func TestJavaSdkLibraryImport_Preferred(t *testing.T) {
})
CheckModuleDependencies(t, result.TestContext, "prebuilt_sdklib", "android_common", []string{
`dex2oatd`,
`prebuilt_sdklib.stubs`,
`sdklib.impl`,
`sdklib.xml`,