Merge "Use both module name and stem name to filter updatable boot jars" am: 276fd424ad am: 31620af91d

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1748051

Change-Id: Ib0f336f1ee599d2cb8ed03af3caec2fb953a4878
This commit is contained in:
Paul Duffin 2021-07-02 21:17:38 +00:00 committed by Automerger Merge Worker
commit 59480e327e
3 changed files with 28 additions and 23 deletions

View file

@ -532,27 +532,18 @@ func (b *BootclasspathFragmentModule) configuredJars(ctx android.ModuleContext)
global := dexpreopt.GetGlobalConfig(ctx)
// Convert content names to their appropriate stems, in case a test library is overriding an actual boot jar
var stems []string
for _, name := range b.properties.Contents {
dep := ctx.GetDirectDepWithTag(name, bootclasspathFragmentContentDepTag)
if m, ok := dep.(ModuleWithStem); ok {
stems = append(stems, m.Stem())
} else {
ctx.PropertyErrorf("contents", "%v is not a ModuleWithStem", name)
}
}
possibleUpdatableModules := gatherPossibleUpdatableModuleNamesAndStems(ctx, b.properties.Contents, bootclasspathFragmentContentDepTag)
// Only create configs for updatable boot jars. Non-updatable boot jars must be part of the
// platform_bootclasspath's classpath proto config to guarantee that they come before any
// updatable jars at runtime.
jars := global.UpdatableBootJars.Filter(stems)
jars := global.UpdatableBootJars.Filter(possibleUpdatableModules)
// TODO(satayev): for apex_test we want to include all contents unconditionally to classpaths
// config. However, any test specific jars would not be present in UpdatableBootJars. Instead,
// we should check if we are creating a config for apex_test via ApexInfo and amend the values.
// This is an exception to support end-to-end test for SdkExtensions, until such support exists.
if android.InList("test_framework-sdkextensions", stems) {
if android.InList("test_framework-sdkextensions", possibleUpdatableModules) {
jars = jars.Append("com.android.sdkext", "test_framework-sdkextensions")
}
return jars

View file

@ -91,6 +91,29 @@ type classpathJar struct {
maxSdkVersion int32
}
// gatherPossibleUpdatableModuleNamesAndStems returns a set of module and stem names from the
// supplied contents that may be in the updatable boot jars.
//
// The module names are included because sometimes the stem is set to just change the name of
// the installed file and it expects the configuration to still use the actual module name.
//
// The stem names are included because sometimes the stem is set to change the effective name of the
// module that is used in the configuration as well,e .g. when a test library is overriding an
// actual boot jar
func gatherPossibleUpdatableModuleNamesAndStems(ctx android.ModuleContext, contents []string, tag blueprint.DependencyTag) []string {
set := map[string]struct{}{}
for _, name := range contents {
dep := ctx.GetDirectDepWithTag(name, tag)
set[name] = struct{}{}
if m, ok := dep.(ModuleWithStem); ok {
set[m.Stem()] = struct{}{}
} else {
ctx.PropertyErrorf("contents", "%v is not a ModuleWithStem", name)
}
}
return android.SortedStringKeys(set)
}
// Converts android.ConfiguredJarList into a list of classpathJars for each given classpathType.
func configuredJarListToClasspathJars(ctx android.ModuleContext, configuredJars android.ConfiguredJarList, classpaths ...classpathType) []classpathJar {
paths := configuredJars.DevicePaths(ctx.Config(), android.Android)

View file

@ -106,21 +106,12 @@ func (s *SystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.Mo
func (s *SystemServerClasspathModule) configuredJars(ctx android.ModuleContext) android.ConfiguredJarList {
global := dexpreopt.GetGlobalConfig(ctx)
// Convert content names to their appropriate stems, in case a test library is overriding an actual boot jar
var stems []string
for _, name := range s.properties.Contents {
dep := ctx.GetDirectDepWithTag(name, systemServerClasspathFragmentContentDepTag)
if m, ok := dep.(ModuleWithStem); ok {
stems = append(stems, m.Stem())
} else {
ctx.PropertyErrorf("contents", "%v is not a ModuleWithStem", name)
}
}
possibleUpdatableModules := gatherPossibleUpdatableModuleNamesAndStems(ctx, s.properties.Contents, systemServerClasspathFragmentContentDepTag)
// Only create configs for updatable boot jars. Non-updatable system server jars must be part of the
// platform_systemserverclasspath's classpath proto config to guarantee that they come before any
// updatable jars at runtime.
return global.UpdatableSystemServerJars.Filter(stems)
return global.UpdatableSystemServerJars.Filter(possibleUpdatableModules)
}
type systemServerClasspathFragmentContentDependencyTag struct {