From 56c93e899a355311463d41e988c9ba511af14278 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Tue, 29 Jun 2021 20:04:45 +0100 Subject: Use both module name and stem name to filter updatable boot jars Sometimes the stem property is set to change both the installed file name and the name use to filter the configured module list, e.g. when adding a test library to replace the standard library, e.g. test_foo instead of foo. Sometimes it is used just to change the installed file name. This change uses both to filter the updatable boot jars and not just the stem. Bug: 180105615 Test: m nothing Change-Id: I6c459fc3597b1e4f062bc9a4e52843305b538c5f --- java/classpath_fragment.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'java/classpath_fragment.go') diff --git a/java/classpath_fragment.go b/java/classpath_fragment.go index f7a200ad3..12bb71174 100644 --- a/java/classpath_fragment.go +++ b/java/classpath_fragment.go @@ -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) -- cgit v1.2.3-59-g8ed1b