Remove the ability to install boot images by bootclasspath_fragments.

We don't need this anymore because we are going to compile ART jars and
framework jars together.

Bug: 280776428
Test: m
Change-Id: I070157530449a1bb5779e25984c367df3dde7b36
This commit is contained in:
Jiakai Zhang
2023-05-10 16:40:18 +01:00
parent b95998be73
commit b47caccbc0
5 changed files with 17 additions and 323 deletions

View File

@@ -2287,16 +2287,13 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
ctx.PropertyErrorf("sh_binaries", "%q is not a sh_binary module", depName) ctx.PropertyErrorf("sh_binaries", "%q is not a sh_binary module", depName)
} }
case bcpfTag: case bcpfTag:
bcpfModule, ok := child.(*java.BootclasspathFragmentModule) _, ok := child.(*java.BootclasspathFragmentModule)
if !ok { if !ok {
ctx.PropertyErrorf("bootclasspath_fragments", "%q is not a bootclasspath_fragment module", depName) ctx.PropertyErrorf("bootclasspath_fragments", "%q is not a bootclasspath_fragment module", depName)
return false return false
} }
vctx.filesInfo = append(vctx.filesInfo, apexBootclasspathFragmentFiles(ctx, child)...) vctx.filesInfo = append(vctx.filesInfo, apexBootclasspathFragmentFiles(ctx, child)...)
for _, makeModuleName := range bcpfModule.BootImageDeviceInstallMakeModules() {
a.makeModulesToInstall = append(a.makeModulesToInstall, makeModuleName)
}
return true return true
case sscpfTag: case sscpfTag:
if _, ok := child.(*java.SystemServerClasspathModule); !ok { if _, ok := child.(*java.SystemServerClasspathModule); !ok {
@@ -2662,19 +2659,6 @@ func apexBootclasspathFragmentFiles(ctx android.ModuleContext, module blueprint.
bootclasspathFragmentInfo := ctx.OtherModuleProvider(module, java.BootclasspathFragmentApexContentInfoProvider).(java.BootclasspathFragmentApexContentInfo) bootclasspathFragmentInfo := ctx.OtherModuleProvider(module, java.BootclasspathFragmentApexContentInfoProvider).(java.BootclasspathFragmentApexContentInfo)
var filesToAdd []apexFile var filesToAdd []apexFile
// Add the boot image files, e.g. .art, .oat and .vdex files.
if bootclasspathFragmentInfo.ShouldInstallBootImageInApex() {
for arch, files := range bootclasspathFragmentInfo.AndroidBootImageFilesByArchType() {
dirInApex := filepath.Join("javalib", arch.String())
for _, f := range files {
androidMkModuleName := "javalib_" + arch.String() + "_" + filepath.Base(f.String())
// TODO(b/177892522) - consider passing in the bootclasspath fragment module here instead of nil
af := newApexFile(ctx, f, androidMkModuleName, dirInApex, etc, nil)
filesToAdd = append(filesToAdd, af)
}
}
}
// Add classpaths.proto config. // Add classpaths.proto config.
if af := apexClasspathFragmentProtoFile(ctx, module); af != nil { if af := apexClasspathFragmentProtoFile(ctx, module); af != nil {
filesToAdd = append(filesToAdd, *af) filesToAdd = append(filesToAdd, *af)

View File

@@ -115,20 +115,7 @@ func TestBootclasspathFragments(t *testing.T) {
// Make sure that the art-bootclasspath-fragment is using the correct configuration. // Make sure that the art-bootclasspath-fragment is using the correct configuration.
checkBootclasspathFragment(t, result, "art-bootclasspath-fragment", "android_common_apex10000", checkBootclasspathFragment(t, result, "art-bootclasspath-fragment", "android_common_apex10000",
"com.android.art:baz,com.android.art:quuz", ` "com.android.art:baz,com.android.art:quuz")
dexpreopt_arm64/dex_artjars/android/apex/art_boot_images/javalib/arm/boot.art
dexpreopt_arm64/dex_artjars/android/apex/art_boot_images/javalib/arm/boot.oat
dexpreopt_arm64/dex_artjars/android/apex/art_boot_images/javalib/arm/boot.vdex
dexpreopt_arm64/dex_artjars/android/apex/art_boot_images/javalib/arm/boot-quuz.art
dexpreopt_arm64/dex_artjars/android/apex/art_boot_images/javalib/arm/boot-quuz.oat
dexpreopt_arm64/dex_artjars/android/apex/art_boot_images/javalib/arm/boot-quuz.vdex
dexpreopt_arm64/dex_artjars/android/apex/art_boot_images/javalib/arm64/boot.art
dexpreopt_arm64/dex_artjars/android/apex/art_boot_images/javalib/arm64/boot.oat
dexpreopt_arm64/dex_artjars/android/apex/art_boot_images/javalib/arm64/boot.vdex
dexpreopt_arm64/dex_artjars/android/apex/art_boot_images/javalib/arm64/boot-quuz.art
dexpreopt_arm64/dex_artjars/android/apex/art_boot_images/javalib/arm64/boot-quuz.oat
dexpreopt_arm64/dex_artjars/android/apex/art_boot_images/javalib/arm64/boot-quuz.vdex
`)
} }
func TestBootclasspathFragments_FragmentDependency(t *testing.T) { func TestBootclasspathFragments_FragmentDependency(t *testing.T) {
@@ -261,7 +248,7 @@ func TestBootclasspathFragments_FragmentDependency(t *testing.T) {
checkAPIScopeStubs("other", otherInfo, java.CorePlatformHiddenAPIScope) checkAPIScopeStubs("other", otherInfo, java.CorePlatformHiddenAPIScope)
} }
func checkBootclasspathFragment(t *testing.T, result *android.TestResult, moduleName, variantName string, expectedConfiguredModules string, expectedBootclasspathFragmentFiles string) { func checkBootclasspathFragment(t *testing.T, result *android.TestResult, moduleName, variantName string, expectedConfiguredModules string) {
t.Helper() t.Helper()
bootclasspathFragment := result.ModuleForTests(moduleName, variantName).Module().(*java.BootclasspathFragmentModule) bootclasspathFragment := result.ModuleForTests(moduleName, variantName).Module().(*java.BootclasspathFragmentModule)
@@ -269,19 +256,6 @@ func checkBootclasspathFragment(t *testing.T, result *android.TestResult, module
bootclasspathFragmentInfo := result.ModuleProvider(bootclasspathFragment, java.BootclasspathFragmentApexContentInfoProvider).(java.BootclasspathFragmentApexContentInfo) bootclasspathFragmentInfo := result.ModuleProvider(bootclasspathFragment, java.BootclasspathFragmentApexContentInfoProvider).(java.BootclasspathFragmentApexContentInfo)
modules := bootclasspathFragmentInfo.Modules() modules := bootclasspathFragmentInfo.Modules()
android.AssertStringEquals(t, "invalid modules for "+moduleName, expectedConfiguredModules, modules.String()) android.AssertStringEquals(t, "invalid modules for "+moduleName, expectedConfiguredModules, modules.String())
// Get a list of all the paths in the boot image sorted by arch type.
allPaths := []string{}
bootImageFilesByArchType := bootclasspathFragmentInfo.AndroidBootImageFilesByArchType()
for _, archType := range android.ArchTypeList() {
if paths, ok := bootImageFilesByArchType[archType]; ok {
for _, path := range paths {
allPaths = append(allPaths, android.NormalizePathForTesting(path))
}
}
}
android.AssertTrimmedStringEquals(t, "invalid paths for "+moduleName, expectedBootclasspathFragmentFiles, strings.Join(allPaths, "\n"))
} }
func TestBootclasspathFragmentInArtApex(t *testing.T) { func TestBootclasspathFragmentInArtApex(t *testing.T) {
@@ -420,18 +394,6 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) {
ensureExactContents(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{ ensureExactContents(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{
"etc/boot-image.prof", "etc/boot-image.prof",
"etc/classpaths/bootclasspath.pb", "etc/classpaths/bootclasspath.pb",
"javalib/arm/boot.art",
"javalib/arm/boot.oat",
"javalib/arm/boot.vdex",
"javalib/arm/boot-bar.art",
"javalib/arm/boot-bar.oat",
"javalib/arm/boot-bar.vdex",
"javalib/arm64/boot.art",
"javalib/arm64/boot.oat",
"javalib/arm64/boot.vdex",
"javalib/arm64/boot-bar.art",
"javalib/arm64/boot-bar.oat",
"javalib/arm64/boot-bar.vdex",
"javalib/bar.jar", "javalib/bar.jar",
"javalib/foo.jar", "javalib/foo.jar",
}) })
@@ -441,62 +403,12 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) {
`mybootclasspathfragment`, `mybootclasspathfragment`,
}) })
// The boot images are installed in the APEX by Soong, so there shouldn't be any dexpreopt-related Make modules.
ensureDoesNotContainRequiredDeps(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{
"mybootclasspathfragment-dexpreopt-arm64-boot.art",
"mybootclasspathfragment-dexpreopt-arm64-boot.oat",
"mybootclasspathfragment-dexpreopt-arm64-boot.vdex",
"mybootclasspathfragment-dexpreopt-arm64-boot-bar.art",
"mybootclasspathfragment-dexpreopt-arm64-boot-bar.oat",
"mybootclasspathfragment-dexpreopt-arm64-boot-bar.vdex",
"mybootclasspathfragment-dexpreopt-arm-boot.art",
"mybootclasspathfragment-dexpreopt-arm-boot.oat",
"mybootclasspathfragment-dexpreopt-arm-boot.vdex",
"mybootclasspathfragment-dexpreopt-arm-boot-bar.art",
"mybootclasspathfragment-dexpreopt-arm-boot-bar.oat",
"mybootclasspathfragment-dexpreopt-arm-boot-bar.vdex",
})
// Make sure that the source bootclasspath_fragment copies its dex files to the predefined // Make sure that the source bootclasspath_fragment copies its dex files to the predefined
// locations for the art image. // locations for the art image.
module := result.ModuleForTests("mybootclasspathfragment", "android_common_apex10000") module := result.ModuleForTests("mybootclasspathfragment", "android_common_apex10000")
checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo") checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo")
}) })
t.Run("boot image files from source no boot image in apex", func(t *testing.T) {
result := android.GroupFixturePreparers(
commonPreparer,
// Configure some libraries in the art bootclasspath_fragment that match the source
// bootclasspath_fragment's contents property.
java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"),
addSource("foo", "bar"),
java.FixtureSetBootImageInstallDirOnDevice("art", "system/framework"),
).RunTest(t)
ensureExactContents(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{
"etc/boot-image.prof",
"etc/classpaths/bootclasspath.pb",
"javalib/bar.jar",
"javalib/foo.jar",
})
ensureContainsRequiredDeps(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{
"mybootclasspathfragment-dexpreopt-arm64-boot.art",
"mybootclasspathfragment-dexpreopt-arm64-boot.oat",
"mybootclasspathfragment-dexpreopt-arm64-boot.vdex",
"mybootclasspathfragment-dexpreopt-arm64-boot-bar.art",
"mybootclasspathfragment-dexpreopt-arm64-boot-bar.oat",
"mybootclasspathfragment-dexpreopt-arm64-boot-bar.vdex",
"mybootclasspathfragment-dexpreopt-arm-boot.art",
"mybootclasspathfragment-dexpreopt-arm-boot.oat",
"mybootclasspathfragment-dexpreopt-arm-boot.vdex",
"mybootclasspathfragment-dexpreopt-arm-boot-bar.art",
"mybootclasspathfragment-dexpreopt-arm-boot-bar.oat",
"mybootclasspathfragment-dexpreopt-arm-boot-bar.vdex",
})
})
t.Run("generate boot image profile even if dexpreopt is disabled", func(t *testing.T) { t.Run("generate boot image profile even if dexpreopt is disabled", func(t *testing.T) {
result := android.GroupFixturePreparers( result := android.GroupFixturePreparers(
commonPreparer, commonPreparer,
@@ -552,18 +464,6 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) {
ensureExactDeapexedContents(t, result.TestContext, "com.android.art", "android_common", []string{ ensureExactDeapexedContents(t, result.TestContext, "com.android.art", "android_common", []string{
"etc/boot-image.prof", "etc/boot-image.prof",
"javalib/arm/boot.art",
"javalib/arm/boot.oat",
"javalib/arm/boot.vdex",
"javalib/arm/boot-bar.art",
"javalib/arm/boot-bar.oat",
"javalib/arm/boot-bar.vdex",
"javalib/arm64/boot.art",
"javalib/arm64/boot.oat",
"javalib/arm64/boot.vdex",
"javalib/arm64/boot-bar.art",
"javalib/arm64/boot-bar.oat",
"javalib/arm64/boot-bar.vdex",
"javalib/bar.jar", "javalib/bar.jar",
"javalib/foo.jar", "javalib/foo.jar",
}) })
@@ -574,65 +474,12 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) {
`prebuilt_com.android.art`, `prebuilt_com.android.art`,
}) })
// The boot images are installed in the APEX by Soong, so there shouldn't be any dexpreopt-related Make modules.
ensureDoesNotContainRequiredDeps(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{
"mybootclasspathfragment-dexpreopt-arm64-boot.art",
"mybootclasspathfragment-dexpreopt-arm64-boot.oat",
"mybootclasspathfragment-dexpreopt-arm64-boot.vdex",
"mybootclasspathfragment-dexpreopt-arm64-boot-bar.art",
"mybootclasspathfragment-dexpreopt-arm64-boot-bar.oat",
"mybootclasspathfragment-dexpreopt-arm64-boot-bar.vdex",
"mybootclasspathfragment-dexpreopt-arm-boot.art",
"mybootclasspathfragment-dexpreopt-arm-boot.oat",
"mybootclasspathfragment-dexpreopt-arm-boot.vdex",
"mybootclasspathfragment-dexpreopt-arm-boot-bar.art",
"mybootclasspathfragment-dexpreopt-arm-boot-bar.oat",
"mybootclasspathfragment-dexpreopt-arm-boot-bar.vdex",
})
// Make sure that the prebuilt bootclasspath_fragment copies its dex files to the predefined // Make sure that the prebuilt bootclasspath_fragment copies its dex files to the predefined
// locations for the art image. // locations for the art image.
module := result.ModuleForTests("prebuilt_mybootclasspathfragment", "android_common_com.android.art") module := result.ModuleForTests("prebuilt_mybootclasspathfragment", "android_common_com.android.art")
checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo") checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo")
}) })
t.Run("boot image files from preferred prebuilt no boot image in apex", func(t *testing.T) {
result := android.GroupFixturePreparers(
commonPreparer,
// Configure some libraries in the art bootclasspath_fragment that match the source
// bootclasspath_fragment's contents property.
java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"),
addSource("foo", "bar"),
// Make sure that a preferred prebuilt with consistent contents doesn't affect the apex.
addPrebuilt(true, "foo", "bar"),
java.FixtureSetBootImageInstallDirOnDevice("art", "system/framework"),
).RunTest(t)
ensureExactDeapexedContents(t, result.TestContext, "com.android.art", "android_common", []string{
"etc/boot-image.prof",
"javalib/bar.jar",
"javalib/foo.jar",
})
ensureContainsRequiredDeps(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{
"mybootclasspathfragment-dexpreopt-arm64-boot.art",
"mybootclasspathfragment-dexpreopt-arm64-boot.oat",
"mybootclasspathfragment-dexpreopt-arm64-boot.vdex",
"mybootclasspathfragment-dexpreopt-arm64-boot-bar.art",
"mybootclasspathfragment-dexpreopt-arm64-boot-bar.oat",
"mybootclasspathfragment-dexpreopt-arm64-boot-bar.vdex",
"mybootclasspathfragment-dexpreopt-arm-boot.art",
"mybootclasspathfragment-dexpreopt-arm-boot.oat",
"mybootclasspathfragment-dexpreopt-arm-boot.vdex",
"mybootclasspathfragment-dexpreopt-arm-boot-bar.art",
"mybootclasspathfragment-dexpreopt-arm-boot-bar.oat",
"mybootclasspathfragment-dexpreopt-arm-boot-bar.vdex",
})
})
t.Run("source with inconsistency between config and contents", func(t *testing.T) { t.Run("source with inconsistency between config and contents", func(t *testing.T) {
android.GroupFixturePreparers( android.GroupFixturePreparers(
commonPreparer, commonPreparer,
@@ -782,10 +629,6 @@ func TestBootclasspathFragmentInPrebuiltArtApex(t *testing.T) {
module := result.ModuleForTests("mybootclasspathfragment", "android_common_com.android.art") module := result.ModuleForTests("mybootclasspathfragment", "android_common_com.android.art")
checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo") checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo")
// Check that the right deapexer module was chosen for a boot image.
param := module.Output("out/soong/dexpreopt_arm64/dex_artjars/android/apex/art_boot_images/javalib/arm64/boot.art")
android.AssertStringDoesContain(t, "didn't find the expected deapexer in the input path", param.Input.String(), "/com.android.art.deapexer")
}) })
t.Run("enabled alternative APEX", func(t *testing.T) { t.Run("enabled alternative APEX", func(t *testing.T) {

View File

@@ -199,14 +199,11 @@ func (p *prebuiltCommon) initApexFilesForAndroidMk(ctx android.ModuleContext) {
p.apexFilesForAndroidMk = append(p.apexFilesForAndroidMk, af) p.apexFilesForAndroidMk = append(p.apexFilesForAndroidMk, af)
} }
} else if tag == exportedBootclasspathFragmentTag { } else if tag == exportedBootclasspathFragmentTag {
bcpfModule, ok := child.(*java.PrebuiltBootclasspathFragmentModule) _, ok := child.(*java.PrebuiltBootclasspathFragmentModule)
if !ok { if !ok {
ctx.PropertyErrorf("exported_bootclasspath_fragments", "%q is not a prebuilt_bootclasspath_fragment module", name) ctx.PropertyErrorf("exported_bootclasspath_fragments", "%q is not a prebuilt_bootclasspath_fragment module", name)
return false return false
} }
for _, makeModuleName := range bcpfModule.BootImageDeviceInstallMakeModules() {
p.requiredModuleNames = append(p.requiredModuleNames, makeModuleName)
}
// Visit the children of the bootclasspath_fragment. // Visit the children of the bootclasspath_fragment.
return true return true
} else if tag == exportedSystemserverclasspathFragmentTag { } else if tag == exportedSystemserverclasspathFragmentTag {

View File

@@ -240,11 +240,6 @@ type BootclasspathFragmentModule struct {
// Collect the module directory for IDE info in java/jdeps.go. // Collect the module directory for IDE info in java/jdeps.go.
modulePaths []string modulePaths []string
// Installs for on-device boot image files. This list has entries only if the installs should be
// handled by Make (e.g., the boot image should be installed on the system partition, rather than
// in the APEX).
bootImageDeviceInstalls []dexpreopterInstall
} }
// commonBootclasspathFragment defines the methods that are implemented by both source and prebuilt // commonBootclasspathFragment defines the methods that are implemented by both source and prebuilt
@@ -268,12 +263,6 @@ type commonBootclasspathFragment interface {
var _ commonBootclasspathFragment = (*BootclasspathFragmentModule)(nil) var _ commonBootclasspathFragment = (*BootclasspathFragmentModule)(nil)
// bootImageFilesByArch is a map from android.ArchType to the paths to the boot image files.
//
// The paths include the .art, .oat and .vdex files, one for each of the modules from which the boot
// image is created.
type bootImageFilesByArch map[android.ArchType]android.Paths
func bootclasspathFragmentFactory() android.Module { func bootclasspathFragmentFactory() android.Module {
m := &BootclasspathFragmentModule{} m := &BootclasspathFragmentModule{}
m.AddProperties(&m.properties, &m.sourceOnlyProperties) m.AddProperties(&m.properties, &m.sourceOnlyProperties)
@@ -395,12 +384,6 @@ type BootclasspathFragmentApexContentInfo struct {
// set image_name: "art". // set image_name: "art".
modules android.ConfiguredJarList modules android.ConfiguredJarList
// Map from arch type to the boot image files.
bootImageFilesByArch bootImageFilesByArch
// True if the boot image should be installed in the APEX.
shouldInstallBootImageInApex bool
// Map from the base module name (without prebuilt_ prefix) of a fragment's contents module to the // Map from the base module name (without prebuilt_ prefix) of a fragment's contents module to the
// hidden API encoded dex jar path. // hidden API encoded dex jar path.
contentModuleDexJarPaths bootDexJarByModule contentModuleDexJarPaths bootDexJarByModule
@@ -417,18 +400,6 @@ func (i BootclasspathFragmentApexContentInfo) Modules() android.ConfiguredJarLis
return i.modules return i.modules
} }
// Get a map from ArchType to the associated boot image's contents for Android.
//
// Extension boot images only return their own files, not the files of the boot images they extend.
func (i BootclasspathFragmentApexContentInfo) AndroidBootImageFilesByArchType() bootImageFilesByArch {
return i.bootImageFilesByArch
}
// Return true if the boot image should be installed in the APEX.
func (i *BootclasspathFragmentApexContentInfo) ShouldInstallBootImageInApex() bool {
return i.shouldInstallBootImageInApex
}
// DexBootJarPathForContentModule returns the path to the dex boot jar for specified module. // DexBootJarPathForContentModule returns the path to the dex boot jar for specified module.
// //
// The dex boot jar is one which has had hidden API encoding performed on it. // The dex boot jar is one which has had hidden API encoding performed on it.
@@ -566,25 +537,6 @@ func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.Mo
// Copy the dex jars of this fragment's content modules to their predefined locations. // Copy the dex jars of this fragment's content modules to their predefined locations.
copyBootJarsToPredefinedLocations(ctx, hiddenAPIOutput.EncodedBootDexFilesByModule, imageConfig.dexPathsByModule) copyBootJarsToPredefinedLocations(ctx, hiddenAPIOutput.EncodedBootDexFilesByModule, imageConfig.dexPathsByModule)
} }
for _, variant := range bootImageFiles.variants {
archType := variant.config.target.Arch.ArchType
arch := archType.String()
for _, install := range variant.deviceInstalls {
// Remove the "/" prefix because the path should be relative to $ANDROID_PRODUCT_OUT.
installDir := strings.TrimPrefix(filepath.Dir(install.To), "/")
installBase := filepath.Base(install.To)
installPath := android.PathForModuleInPartitionInstall(ctx, "", installDir)
b.bootImageDeviceInstalls = append(b.bootImageDeviceInstalls, dexpreopterInstall{
name: arch + "-" + installBase,
moduleName: b.Name(),
outputPathOnHost: install.From,
installDirOnDevice: installPath,
installFileOnDevice: installBase,
})
}
}
} }
// A prebuilt fragment cannot contribute to an apex. // A prebuilt fragment cannot contribute to an apex.
@@ -643,12 +595,8 @@ func (b *BootclasspathFragmentModule) provideApexContentInfo(ctx android.ModuleC
info.profilePathOnHost = bootImageFiles.profile info.profilePathOnHost = bootImageFiles.profile
info.profileInstallPathInApex = imageConfig.profileInstallPathInApex info.profileInstallPathInApex = imageConfig.profileInstallPathInApex
} }
info.shouldInstallBootImageInApex = imageConfig.shouldInstallInApex()
} }
info.bootImageFilesByArch = bootImageFiles.byArch
// Make the apex content info available for other modules. // Make the apex content info available for other modules.
ctx.SetProvider(BootclasspathFragmentApexContentInfoProvider, info) ctx.SetProvider(BootclasspathFragmentApexContentInfoProvider, info)
} }
@@ -960,21 +908,9 @@ func (b *BootclasspathFragmentModule) AndroidMkEntries() []android.AndroidMkEntr
}, },
}, },
}} }}
for _, install := range b.bootImageDeviceInstalls {
entriesList = append(entriesList, install.ToMakeEntries())
}
return entriesList return entriesList
} }
// Returns the names of all Make modules that handle the installation of the boot image.
func (b *BootclasspathFragmentModule) BootImageDeviceInstallMakeModules() []string {
var makeModules []string
for _, install := range b.bootImageDeviceInstalls {
makeModules = append(makeModules, install.FullModuleName())
}
return makeModules
}
// Collect information for opening IDE project files in java/jdeps.go. // Collect information for opening IDE project files in java/jdeps.go.
func (b *BootclasspathFragmentModule) IDEInfo(dpInfo *android.IdeInfo) { func (b *BootclasspathFragmentModule) IDEInfo(dpInfo *android.IdeInfo) {
dpInfo.Deps = append(dpInfo.Deps, b.properties.Contents...) dpInfo.Deps = append(dpInfo.Deps, b.properties.Contents...)
@@ -1262,59 +1198,17 @@ func (module *PrebuiltBootclasspathFragmentModule) produceBootImageFiles(ctx and
// built without a profile as the prebuilt modules do not provide a profile. // built without a profile as the prebuilt modules do not provide a profile.
buildBootImageVariantsForBuildOs(ctx, imageConfig, profile) buildBootImageVariantsForBuildOs(ctx, imageConfig, profile)
if imageConfig.shouldInstallInApex() { if profile == nil && imageConfig.isProfileGuided() {
// If the boot image files for the android variants are in the prebuilt apex, we must use those ctx.ModuleErrorf("Unable to produce boot image files: profiles not found in the prebuilt apex")
// rather than building new ones because those boot image files are going to be used on device. return bootImageOutputs{}
files := bootImageFilesByArch{}
bootImageFiles := bootImageOutputs{
byArch: files,
profile: profile,
}
for _, variant := range imageConfig.apexVariants() {
arch := variant.target.Arch.ArchType
bootImageFiles.variants = append(bootImageFiles.variants, bootImageVariantOutputs{
variant,
// No device installs needed when installed in APEX.
nil,
})
for _, toPath := range variant.imagesDeps {
apexRelativePath := apexRootRelativePathToBootImageFile(arch, toPath.Base())
// Get the path to the file that the deapexer extracted from the prebuilt apex file.
fromPath := di.PrebuiltExportPath(apexRelativePath)
// Return the toPath as the calling code expects the paths in the returned map to be the
// paths predefined in the bootImageConfig.
files[arch] = append(files[arch], toPath)
// Copy the file to the predefined location.
ctx.Build(pctx, android.BuildParams{
Rule: android.Cp,
Input: fromPath,
Output: toPath,
})
}
}
return bootImageFiles
} else {
if profile == nil && imageConfig.isProfileGuided() {
ctx.ModuleErrorf("Unable to produce boot image files: neither boot image files nor profiles exists in the prebuilt apex")
return bootImageOutputs{}
}
// Build boot image files for the android variants from the dex files provided by the contents
// of this module.
return buildBootImageVariantsForAndroidOs(ctx, imageConfig, profile)
} }
// Build boot image files for the android variants from the dex files provided by the contents
// of this module.
return buildBootImageVariantsForAndroidOs(ctx, imageConfig, profile)
} }
var _ commonBootclasspathFragment = (*PrebuiltBootclasspathFragmentModule)(nil) var _ commonBootclasspathFragment = (*PrebuiltBootclasspathFragmentModule)(nil)
// createBootImageTag creates the tag to uniquely identify the boot image file among all of the
// files that a module requires from the prebuilt .apex file.
func createBootImageTag(arch android.ArchType, baseName string) string {
tag := fmt.Sprintf(".bootimage-%s-%s", arch, baseName)
return tag
}
// RequiredFilesFromPrebuiltApex returns the list of all files the prebuilt_bootclasspath_fragment // RequiredFilesFromPrebuiltApex returns the list of all files the prebuilt_bootclasspath_fragment
// requires from a prebuilt .apex file. // requires from a prebuilt .apex file.
// //
@@ -1328,25 +1222,11 @@ func (module *PrebuiltBootclasspathFragmentModule) RequiredFilesFromPrebuiltApex
// Add the boot image profile. // Add the boot image profile.
files = append(files, imageConfig.profileInstallPathInApex) files = append(files, imageConfig.profileInstallPathInApex)
} }
if imageConfig.shouldInstallInApex() {
// Add the boot image files, e.g. .art, .oat and .vdex files.
for _, variant := range imageConfig.apexVariants() {
arch := variant.target.Arch.ArchType
for _, path := range variant.imagesDeps.Paths() {
base := path.Base()
files = append(files, apexRootRelativePathToBootImageFile(arch, base))
}
}
}
return files return files
} }
return nil return nil
} }
func apexRootRelativePathToBootImageFile(arch android.ArchType, base string) string {
return filepath.Join("javalib", arch.String(), base)
}
var _ android.RequiredFilesFromPrebuiltApex = (*PrebuiltBootclasspathFragmentModule)(nil) var _ android.RequiredFilesFromPrebuiltApex = (*PrebuiltBootclasspathFragmentModule)(nil)
func prebuiltBootclasspathFragmentFactory() android.Module { func prebuiltBootclasspathFragmentFactory() android.Module {

View File

@@ -421,11 +421,6 @@ func (image *bootImageConfig) apexVariants() []*bootImageVariant {
return variants return variants
} }
// Returns true if the boot image should be installed in the APEX.
func (image *bootImageConfig) shouldInstallInApex() bool {
return strings.HasPrefix(image.installDirOnDevice, "apex/")
}
// Return boot image locations (as a list of symbolic paths). // Return boot image locations (as a list of symbolic paths).
// //
// The image "location" is a symbolic path that, with multiarchitecture support, doesn't really // The image "location" is a symbolic path that, with multiarchitecture support, doesn't really
@@ -596,6 +591,12 @@ func buildBootImageVariantsForBuildOs(ctx android.ModuleContext, image *bootImag
buildBootImageForOsType(ctx, image, profile, ctx.Config().BuildOS) buildBootImageForOsType(ctx, image, profile, ctx.Config().BuildOS)
} }
// bootImageFilesByArch is a map from android.ArchType to the paths to the boot image files.
//
// The paths include the .art, .oat and .vdex files, one for each of the modules from which the boot
// image is created.
type bootImageFilesByArch map[android.ArchType]android.Paths
// bootImageOutputs encapsulates information about boot images that were created/obtained by // bootImageOutputs encapsulates information about boot images that were created/obtained by
// commonBootclasspathFragment.produceBootImageFiles. // commonBootclasspathFragment.produceBootImageFiles.
type bootImageOutputs struct { type bootImageOutputs struct {
@@ -656,8 +657,7 @@ func buildBootImageZipInPredefinedLocation(ctx android.ModuleContext, image *boo
} }
type bootImageVariantOutputs struct { type bootImageVariantOutputs struct {
config *bootImageVariant config *bootImageVariant
deviceInstalls android.RuleBuilderInstalls
} }
// Generate boot image build rules for a specific target. // Generate boot image build rules for a specific target.
@@ -800,7 +800,6 @@ func buildBootImageVariant(ctx android.ModuleContext, image *bootImageVariant, p
var vdexInstalls android.RuleBuilderInstalls var vdexInstalls android.RuleBuilderInstalls
var unstrippedInstalls android.RuleBuilderInstalls var unstrippedInstalls android.RuleBuilderInstalls
var deviceInstalls android.RuleBuilderInstalls
for _, artOrOat := range image.moduleFiles(ctx, outputDir, ".art", ".oat") { for _, artOrOat := range image.moduleFiles(ctx, outputDir, ".art", ".oat") {
cmd.ImplicitOutput(artOrOat) cmd.ImplicitOutput(artOrOat)
@@ -826,14 +825,6 @@ func buildBootImageVariant(ctx android.ModuleContext, image *bootImageVariant, p
android.RuleBuilderInstall{unstrippedOat, filepath.Join(installDir, unstrippedOat.Base())}) android.RuleBuilderInstall{unstrippedOat, filepath.Join(installDir, unstrippedOat.Base())})
} }
if image.installDirOnHost != image.installDirOnDevice && !image.shouldInstallInApex() && !ctx.Config().UnbundledBuild() {
installDirOnDevice := filepath.Join("/", image.installDirOnDevice, arch.String())
for _, file := range image.moduleFiles(ctx, outputDir, ".art", ".oat", ".vdex") {
deviceInstalls = append(deviceInstalls,
android.RuleBuilderInstall{file, filepath.Join(installDirOnDevice, file.Base())})
}
}
rule.Build(image.name+"JarsDexpreopt_"+image.target.String(), "dexpreopt "+image.name+" jars "+arch.String()) rule.Build(image.name+"JarsDexpreopt_"+image.target.String(), "dexpreopt "+image.name+" jars "+arch.String())
// save output and installed files for makevars // save output and installed files for makevars
@@ -849,7 +840,6 @@ func buildBootImageVariant(ctx android.ModuleContext, image *bootImageVariant, p
return bootImageVariantOutputs{ return bootImageVariantOutputs{
image, image,
deviceInstalls,
} }
} }