From 458a15bd8af649af4f2d3752ba2e6d0d5c61350b Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Fri, 25 Nov 2022 12:18:24 +0000 Subject: [PATCH] Remove IsModuleInVersionedSdk Previously, as all versioned sdk snapshots have been removed from Android.bp files this method would always return false. This change effectively replaces all calls to it with false, and then optimizes away any unused code. Bug: 260237150 Test: m nothing Change-Id: I1b717ee8345e807bd888451f6e7e3c3a0d391ee2 --- android/sdk.go | 10 --- cc/cc.go | 2 +- cc/fuzz.go | 6 -- java/androidmk.go | 5 -- java/bootclasspath_fragment.go | 114 ++++++++---------------- java/hiddenapi_modular.go | 8 -- java/platform_compat_config.go | 14 +-- java/systemserver_classpath_fragment.go | 2 +- 8 files changed, 40 insertions(+), 121 deletions(-) diff --git a/android/sdk.go b/android/sdk.go index bd2f5d13f..5459a8aa0 100644 --- a/android/sdk.go +++ b/android/sdk.go @@ -216,16 +216,6 @@ func InitSdkAwareModule(m SdkAware) { m.AddProperties(&base.properties) } -// IsModuleInVersionedSdk returns true if the module is an versioned sdk. -func IsModuleInVersionedSdk(module Module) bool { - if s, ok := module.(SdkAware); ok { - if !s.ContainingSdk().Unversioned() { - return true - } - } - return false -} - // SnapshotBuilder provides support for generating the build rules which will build the snapshot. type SnapshotBuilder interface { // CopyToSnapshot generates a rule that will copy the src to the dest (which is a snapshot diff --git a/cc/cc.go b/cc/cc.go index c4f87257e..6271b2888 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -3520,7 +3520,7 @@ func (c *Module) IsInstallableToApex() bool { if lib := c.library; lib != nil { // Stub libs and prebuilt libs in a versioned SDK are not // installable to APEX even though they are shared libs. - return lib.shared() && !lib.buildStubs() && !android.IsModuleInVersionedSdk(c) + return lib.shared() && !lib.buildStubs() } else if _, ok := c.linker.(testPerSrc); ok { return true } diff --git a/cc/fuzz.go b/cc/fuzz.go index d714bf2aa..7113d87df 100644 --- a/cc/fuzz.go +++ b/cc/fuzz.go @@ -209,12 +209,6 @@ func IsValidSharedDependency(dependency android.Module) bool { return false } - // Discard versioned members of SDK snapshots, because they will conflict with - // unversioned ones. - if android.IsModuleInVersionedSdk(dependency) { - return false - } - return true } diff --git a/java/androidmk.go b/java/androidmk.go index e37a90e0f..a4dac80d4 100644 --- a/java/androidmk.go +++ b/java/androidmk.go @@ -200,11 +200,6 @@ func (prebuilt *Import) AndroidMkEntries() []android.AndroidMkEntries { dexpreoptEntries := prebuilt.dexpreopter.AndroidMkEntriesForApex() return append(dexpreoptEntries, android.AndroidMkEntries{Disabled: true}) } - if android.IsModuleInVersionedSdk(prebuilt) { - return []android.AndroidMkEntries{android.AndroidMkEntries{ - Disabled: true, - }} - } return []android.AndroidMkEntries{android.AndroidMkEntries{ Class: "JAVA_LIBRARIES", OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile), diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index 3a28c5910..e67f1cab1 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -332,19 +332,6 @@ func bootclasspathFragmentInitContentsFromImage(ctx android.EarlyModuleContext, return } - // TODO(b/177892522): Prebuilts (versioned or not) should not use the image_name property. - if android.IsModuleInVersionedSdk(m) { - // The module is a versioned prebuilt so ignore it. This is done for a couple of reasons: - // 1. There is no way to use this at the moment so ignoring it is safe. - // 2. Attempting to initialize the contents property from the configuration will end up having - // the versioned prebuilt depending on the unversioned prebuilt. That will cause problems - // as the unversioned prebuilt could end up with an APEX variant created for the source - // APEX which will prevent it from having an APEX variant for the prebuilt APEX which in - // turn will prevent it from accessing the dex implementation jar from that which will - // break hidden API processing, amongst others. - return - } - // Get the configuration for the art apex jars. Do not use getImageConfig(ctx) here as this is // too early in the Soong processing for that to work. global := dexpreopt.GetGlobalConfig(ctx) @@ -383,19 +370,6 @@ func bootclasspathFragmentInitContentsFromImage(ctx android.EarlyModuleContext, func (b *BootclasspathFragmentModule) bootclasspathImageNameContentsConsistencyCheck(ctx android.BaseModuleContext) { imageName := proptools.String(b.properties.Image_name) if imageName == "art" { - // TODO(b/177892522): Prebuilts (versioned or not) should not use the image_name property. - if android.IsModuleInVersionedSdk(b) { - // The module is a versioned prebuilt so ignore it. This is done for a couple of reasons: - // 1. There is no way to use this at the moment so ignoring it is safe. - // 2. Attempting to initialize the contents property from the configuration will end up having - // the versioned prebuilt depending on the unversioned prebuilt. That will cause problems - // as the unversioned prebuilt could end up with an APEX variant created for the source - // APEX which will prevent it from having an APEX variant for the prebuilt APEX which in - // turn will prevent it from accessing the dex implementation jar from that which will - // break hidden API processing, amongst others. - return - } - // Get the configuration for the art apex jars. modules := b.getImageConfig(ctx).modules configuredJars := modules.CopyOfJars() @@ -575,57 +549,48 @@ func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.Mo // prebuilt which will not use the image config. imageConfig := b.getImageConfig(ctx) - // A versioned prebuilt_bootclasspath_fragment cannot and does not need to perform hidden API - // processing. It cannot do it because it is not part of a prebuilt_apex and so has no access to - // the correct dex implementation jar. It does not need to because the platform-bootclasspath - // always references the latest bootclasspath_fragments. - if !android.IsModuleInVersionedSdk(ctx.Module()) { - // Perform hidden API processing. - hiddenAPIOutput := b.generateHiddenAPIBuildActions(ctx, contents, fragments) + // Perform hidden API processing. + hiddenAPIOutput := b.generateHiddenAPIBuildActions(ctx, contents, fragments) - var bootImageFiles bootImageOutputs - if imageConfig != nil { - // Delegate the production of the boot image files to a module type specific method. - common := ctx.Module().(commonBootclasspathFragment) - bootImageFiles = common.produceBootImageFiles(ctx, imageConfig) + var bootImageFiles bootImageOutputs + if imageConfig != nil { + // Delegate the production of the boot image files to a module type specific method. + common := ctx.Module().(commonBootclasspathFragment) + bootImageFiles = common.produceBootImageFiles(ctx, imageConfig) - if shouldCopyBootFilesToPredefinedLocations(ctx, imageConfig) { - // Zip the boot image files up, if available. This will generate the zip file in a - // predefined location. - buildBootImageZipInPredefinedLocation(ctx, imageConfig, bootImageFiles.byArch) + if shouldCopyBootFilesToPredefinedLocations(ctx, imageConfig) { + // Zip the boot image files up, if available. This will generate the zip file in a + // predefined location. + buildBootImageZipInPredefinedLocation(ctx, imageConfig, bootImageFiles.byArch) - // Copy the dex jars of this fragment's content modules to their predefined locations. - 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, - }) - } - } + // Copy the dex jars of this fragment's content modules to their predefined locations. + copyBootJarsToPredefinedLocations(ctx, hiddenAPIOutput.EncodedBootDexFilesByModule, imageConfig.dexPathsByModule) } - // A prebuilt fragment cannot contribute to an apex. - if !android.IsModulePrebuilt(ctx.Module()) { - // Provide the apex content info. - b.provideApexContentInfo(ctx, imageConfig, hiddenAPIOutput, bootImageFiles) + 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, + }) + } } - } else { - // Versioned fragments are not needed by make. - b.HideFromMake() + } + + // A prebuilt fragment cannot contribute to an apex. + if !android.IsModulePrebuilt(ctx.Module()) { + // Provide the apex content info. + b.provideApexContentInfo(ctx, imageConfig, hiddenAPIOutput, bootImageFiles) } // In order for information about bootclasspath_fragment modules to be added to module-info.json @@ -719,7 +684,7 @@ func (b *BootclasspathFragmentModule) configuredJars(ctx android.ModuleContext) jars = jars.Append("com.android.sdkext", "test_framework-sdkextensions") } else if android.InList("test_framework-apexd", possibleUpdatableModules) { jars = jars.Append("com.android.apex.test_package", "test_framework-apexd") - } else if global.ApexBootJars.Len() != 0 && !android.IsModuleInVersionedSdk(ctx.Module()) { + } else if global.ApexBootJars.Len() != 0 { unknown = android.RemoveListFromList(unknown, b.properties.Coverage.Contents) _, unknown = android.RemoveFromList("core-icu4j", unknown) // This module only exists in car products. @@ -961,11 +926,6 @@ func (b *BootclasspathFragmentModule) generateBootImageBuildActions(ctx android. return bootImageOutputs{} } - // Bootclasspath fragment modules that are versioned do not produce a boot image. - if android.IsModuleInVersionedSdk(ctx.Module()) { - return bootImageOutputs{} - } - // Build a profile for the image config and then use that to build the boot image. profile := bootImageProfileRule(ctx, imageConfig) diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go index 5474ae11e..593d7724f 100644 --- a/java/hiddenapi_modular.go +++ b/java/hiddenapi_modular.go @@ -1352,14 +1352,6 @@ func deferReportingMissingBootDexJar(ctx android.ModuleContext, module android.M return true } - // A bootclasspath module that is part of a versioned sdk never provides a boot dex jar as there - // is no equivalently versioned prebuilt APEX file from which it can be obtained. However, - // versioned bootclasspath modules are processed by Soong so in order to avoid them causing build - // failures missing boot dex jars need to be deferred. - if android.IsModuleInVersionedSdk(ctx.Module()) { - return true - } - // This is called for both platform_bootclasspath and bootclasspath_fragment modules. // // A bootclasspath_fragment module should only use the APEX variant of source or prebuilt modules. diff --git a/java/platform_compat_config.go b/java/platform_compat_config.go index 655021fc4..201dedede 100644 --- a/java/platform_compat_config.go +++ b/java/platform_compat_config.go @@ -223,18 +223,6 @@ type platformCompatConfigSingleton struct { metadata android.Path } -// isModulePreferredByCompatConfig checks to see whether the module is preferred for use by -// platform compat config. -func isModulePreferredByCompatConfig(module android.Module) bool { - // A versioned prebuilt_platform_compat_config, i.e. foo-platform-compat-config@current should be - // ignored. - if android.IsModuleInVersionedSdk(module) { - return false - } - - return android.IsModulePreferred(module) -} - func (p *platformCompatConfigSingleton) GenerateBuildActions(ctx android.SingletonContext) { var compatConfigMetadata android.Paths @@ -244,7 +232,7 @@ func (p *platformCompatConfigSingleton) GenerateBuildActions(ctx android.Singlet return } if c, ok := module.(platformCompatConfigMetadataProvider); ok { - if !isModulePreferredByCompatConfig(module) { + if !android.IsModulePreferred(module) { return } metadata := c.compatConfigMetadata() diff --git a/java/systemserver_classpath_fragment.go b/java/systemserver_classpath_fragment.go index a2cd2619a..f6cb79585 100644 --- a/java/systemserver_classpath_fragment.go +++ b/java/systemserver_classpath_fragment.go @@ -160,7 +160,7 @@ func (s *SystemServerClasspathModule) configuredJars(ctx android.ModuleContext) // This is an exception to support end-to-end test for ApexdUnitTests, until such support exists. if android.InList("test_service-apexd", possibleUpdatableModules) { jars = jars.Append("com.android.apex.test_package", "test_service-apexd") - } else if global.ApexSystemServerJars.Len() > 0 && len(unknown) > 0 && !android.IsModuleInVersionedSdk(ctx.Module()) { + } else if global.ApexSystemServerJars.Len() > 0 && len(unknown) > 0 { // For non test apexes, make sure that all contents are actually declared in make. ctx.ModuleErrorf("%s in contents must also be declared in PRODUCT_APEX_SYSTEM_SERVER_JARS", unknown) }