Populate individual classpath_fragments' classpaths.proto configs.

To avoid duplicates on *CLASSPATH environ variables at runtime, remove
split entries from platform-*classpath, i.e. all updatable jars that
have their own classpath fragments should not appear in the
platform-*classpath's classpaths.proto config.

Bug: 180105615
Test: m && launch_cvd; atest CtsClasspathsTestCases
Change-Id: Id2759ab8e106cc183e695bf3509a6ab60ab0ef2a
This commit is contained in:
satayev
2021-05-20 11:24:00 +01:00
parent 796421bdf1
commit 95bfbb169f
5 changed files with 37 additions and 52 deletions

View File

@@ -15,7 +15,6 @@
package java
import (
"fmt"
"path/filepath"
"strings"
@@ -23,32 +22,6 @@ import (
"android/soong/dexpreopt"
)
// systemServerClasspath returns the on-device locations of the modules in the system server classpath. It is computed
// once the first time it is called for any ctx.Config(), and returns the same slice for all future calls with the same
// ctx.Config().
func systemServerClasspath(ctx android.PathContext) []string {
return ctx.Config().OnceStringSlice(systemServerClasspathKey, func() []string {
global := dexpreopt.GetGlobalConfig(ctx)
var systemServerClasspathLocations []string
nonUpdatable := dexpreopt.NonUpdatableSystemServerJars(ctx, global)
// 1) Non-updatable jars.
for _, m := range nonUpdatable {
systemServerClasspathLocations = append(systemServerClasspathLocations,
filepath.Join("/system/framework", m+".jar"))
}
// 2) The jars that are from an updatable apex.
systemServerClasspathLocations = append(systemServerClasspathLocations,
global.UpdatableSystemServerJars.DevicePaths(ctx.Config(), android.Android)...)
if expectedLen := global.SystemServerJars.Len() + global.UpdatableSystemServerJars.Len(); expectedLen != len(systemServerClasspathLocations) {
panic(fmt.Errorf("wrong number of system server jars, got %d, expected %d", len(systemServerClasspathLocations), expectedLen))
}
return systemServerClasspathLocations
})
}
var systemServerClasspathKey = android.NewOnceKey("systemServerClasspath")
// dexpreoptTargets returns the list of targets that are relevant to dexpreopting, which excludes architectures
// supported through native bridge.
func dexpreoptTargets(ctx android.PathContext) []android.Target {