Merge "Remove IsModuleInVersionedSdk"

This commit is contained in:
Paul Duffin
2023-01-06 22:37:59 +00:00
committed by Gerrit Code Review
8 changed files with 40 additions and 121 deletions

View File

@@ -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

View File

@@ -3539,7 +3539,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
}

View File

@@ -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
}

View File

@@ -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),

View File

@@ -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)

View File

@@ -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.

View File

@@ -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()

View File

@@ -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)
}