Move copying of dex files from dexpreopt_bootjars singleton
The art dex files are copied in the bootclasspath_fragment and the
non-updatable and updatable dex files are copied in the
platform_bootclasspath.
Bug: 177892522
Test: m nothing
Change-Id: I5d3d533d1a7a9f8e7ae20c12eb33029a898a2cd6
diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go
index bed629d..5b1be22 100644
--- a/java/bootclasspath_fragment.go
+++ b/java/bootclasspath_fragment.go
@@ -361,6 +361,15 @@
// Generate classpaths.proto config
b.generateClasspathProtoBuildActions(ctx)
+ // Gather the bootclasspath fragment's contents.
+ var contents []android.Module
+ ctx.VisitDirectDeps(func(module android.Module) {
+ tag := ctx.OtherModuleDependencyTag(module)
+ if IsBootclasspathFragmentContentDepTag(tag) {
+ contents = append(contents, module)
+ }
+ })
+
// Perform hidden API processing.
b.generateHiddenAPIBuildActions(ctx)
@@ -376,6 +385,9 @@
// GenerateSingletonBuildActions method as it cannot create it for itself.
dexpreopt.GetGlobalSoongConfig(ctx)
info.imageConfig = b.getImageConfig(ctx)
+
+ // Only generate the boot image if the configuration does not skip it.
+ b.generateBootImageBuildActions(ctx, contents)
}
// Make it available for other modules.
@@ -434,6 +446,40 @@
ctx.SetProvider(bootclasspathApiInfoProvider, bootclasspathApiInfo)
}
+// generateBootImageBuildActions generates ninja rules to create the boot image if required for this
+// module.
+func (b *BootclasspathFragmentModule) generateBootImageBuildActions(ctx android.ModuleContext, contents []android.Module) {
+ global := dexpreopt.GetGlobalConfig(ctx)
+ if !shouldBuildBootImages(ctx.Config(), global) {
+ return
+ }
+
+ // Bootclasspath fragment modules that are not preferred do not produce a boot image.
+ if !isActiveModule(ctx.Module()) {
+ return
+ }
+
+ // Bootclasspath fragment modules that have no image_name property do not produce a boot image.
+ imageConfig := b.getImageConfig(ctx)
+ if imageConfig == nil {
+ return
+ }
+
+ // Bootclasspath fragment modules that are for the platform do not produce a boot image.
+ apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ if apexInfo.IsForPlatform() {
+ return
+ }
+
+ // Bootclasspath fragment modules that are versioned do not produce a boot image.
+ if android.IsModuleInVersionedSdk(ctx.Module()) {
+ return
+ }
+
+ // Copy the dex jars of this fragment's content modules to their predefined locations.
+ copyBootJarsToPredefinedLocations(ctx, contents, imageConfig.modules, imageConfig.dexPaths)
+}
+
type bootclasspathFragmentMemberType struct {
android.SdkMemberTypeBase
}