Ensure that only one dex jar is chosen for each boot image library

This change does not break modules like "core-oj" that are in multiple
apexes, i.e. com.android.art, com.android.art.debug and
com.android.art.testing because they all shared the same variant. So,
the getBootImageJar() is only called once for that variant.

Test: m droid
Bug: 171061220
Change-Id: Ibf26da147af2b49ab9e4588030e8cd4002d04a7a
This commit is contained in:
Paul Duffin 2020-12-03 19:25:39 +00:00
parent 71debbfcc5
commit db77e14d84
1 changed files with 6 additions and 0 deletions

View File

@ -495,6 +495,12 @@ func buildBootImage(ctx android.SingletonContext, image *bootImageConfig) *bootI
bootDexJars := make(android.Paths, image.modules.Len())
ctx.VisitAllModules(func(module android.Module) {
if i, j := getBootImageJar(ctx, image, module); i != -1 {
if existing := bootDexJars[i]; existing != nil {
ctx.Errorf("Multiple dex jars found for %s:%s - %s and %s",
image.modules.Apex(i), image.modules.Jar(i), existing, j)
return
}
bootDexJars[i] = j
}
})