diff options
Diffstat (limited to 'java/bootclasspath_fragment.go')
-rw-r--r-- | java/bootclasspath_fragment.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index bed629da3..5b1be22c5 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -361,6 +361,15 @@ func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.Mo // 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 @@ func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.Mo // 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 @@ func (b *BootclasspathFragmentModule) generateHiddenAPIBuildActions(ctx android. 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 } |