From 4c094428a73d55332a3a1145e0f5c63115ef384c Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Mon, 26 Apr 2021 20:10:48 +0100 Subject: [PATCH] Move generateUpdatableBcpPackagesRule to platform_bootclasspath Changes generateUpdatableBcpPackagesRule to use ModuleContext instead of SingletonContext and moves the call from dexpreoptBootJar's GenerateSingletonBuildActions method to platform_bootclasspath's GenerateAndroidBuildActions. Bug: 177892522 Test: lunch art_module_arm64 m out/soong/module_arm64/dex_bootjars/updatable-bcp-packages.txt - make sure it is not affected by this change Change-Id: I9741ae1eb9573cafe12dd7a17dc1d8449b224dc8 --- java/dexpreopt_bootjars.go | 30 ++---------------------------- java/platform_bootclasspath.go | 7 +++++-- 2 files changed, 7 insertions(+), 30 deletions(-) diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index 8a6f3d19b..be14be417 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -431,9 +431,6 @@ func (d *dexpreoptBootJars) GenerateSingletonBuildActions(ctx android.SingletonC defaultImageConfig := defaultBootImageConfig(ctx) profile := bootImageProfileRule(ctx, defaultImageConfig) - // Generate the updatable bootclasspath packages rule. - updatableBcpPackagesRule(ctx, defaultImageConfig) - // Create the default boot image. d.defaultBootImage = buildBootImage(ctx, defaultImageConfig, profile) @@ -887,32 +884,9 @@ func bootFrameworkProfileRule(ctx android.ModuleContext, image *bootImageConfig) return profile } -func updatableBcpPackagesRule(ctx android.SingletonContext, image *bootImageConfig) android.WritablePath { - if ctx.Config().UnbundledBuild() { - return nil - } - - global := dexpreopt.GetGlobalConfig(ctx) - var modules []android.Module - updatableModules := global.UpdatableBootJars.CopyOfJars() - ctx.VisitAllModules(func(module android.Module) { - if !isActiveModule(module) { - return - } - name := ctx.ModuleName(module) - if i := android.IndexList(name, updatableModules); i != -1 { - modules = append(modules, module) - // Do not match the same library repeatedly. - updatableModules = append(updatableModules[:i], updatableModules[i+1:]...) - } - }) - - return generateUpdatableBcpPackagesRule(ctx, image, modules) -} - // generateUpdatableBcpPackagesRule generates the rule to create the updatable-bcp-packages.txt file // and returns a path to the generated file. -func generateUpdatableBcpPackagesRule(ctx android.SingletonContext, image *bootImageConfig, updatableModules []android.Module) android.WritablePath { +func generateUpdatableBcpPackagesRule(ctx android.ModuleContext, image *bootImageConfig, updatableModules []android.Module) android.WritablePath { // Collect `permitted_packages` for updatable boot jars. var updatablePackages []string for _, module := range updatableModules { @@ -921,7 +895,7 @@ func generateUpdatableBcpPackagesRule(ctx android.SingletonContext, image *bootI if len(pp) > 0 { updatablePackages = append(updatablePackages, pp...) } else { - ctx.Errorf("Missing permitted_packages for %s", ctx.ModuleName(module)) + ctx.ModuleErrorf("Missing permitted_packages") } } } diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go index 790445244..3b27ef6b4 100644 --- a/java/platform_bootclasspath.go +++ b/java/platform_bootclasspath.go @@ -179,7 +179,7 @@ func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.Mo return } - b.generateBootImageBuildActions(ctx) + b.generateBootImageBuildActions(ctx, updatableModules) } func (b *platformBootclasspathModule) getImageConfig(ctx android.EarlyModuleContext) *bootImageConfig { @@ -308,7 +308,7 @@ func (b *platformBootclasspathModule) generatedHiddenAPIMetadataRules(ctx androi } // generateBootImageBuildActions generates ninja rules related to the boot image creation. -func (b *platformBootclasspathModule) generateBootImageBuildActions(ctx android.ModuleContext) { +func (b *platformBootclasspathModule) generateBootImageBuildActions(ctx android.ModuleContext, updatableModules []android.Module) { // Force the GlobalSoongConfig to be created and cached for use by the dex_bootjars // GenerateSingletonBuildActions method as it cannot create it for itself. dexpreopt.GetGlobalSoongConfig(ctx) @@ -325,4 +325,7 @@ func (b *platformBootclasspathModule) generateBootImageBuildActions(ctx android. // Generate the framework profile rule bootFrameworkProfileRule(ctx, imageConfig) + + // Generate the updatable bootclasspath packages rule. + generateUpdatableBcpPackagesRule(ctx, imageConfig, updatableModules) }