Merge "Add the transitive dependencies of boot_image to apex"

This commit is contained in:
Paul Duffin
2021-03-30 16:42:07 +00:00
committed by Gerrit Code Review
3 changed files with 33 additions and 6 deletions

View File

@@ -1702,6 +1702,9 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
filesInfo = append(filesInfo, af) filesInfo = append(filesInfo, af)
} }
} }
// Track transitive dependencies.
return true
} }
case javaLibTag: case javaLibTag:
switch child.(type) { switch child.(type) {
@@ -1910,6 +1913,21 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
filesInfo = append(filesInfo, af) filesInfo = append(filesInfo, af)
return true // track transitive dependencies return true // track transitive dependencies
} }
} else if java.IsbootImageContentDepTag(depTag) {
// Add the contents of the boot image to the apex.
switch child.(type) {
case *java.Library, *java.SdkLibrary:
af := apexFileForJavaModule(ctx, child.(javaModule))
if !af.ok() {
ctx.PropertyErrorf("boot_images", "boot image content %q is not configured to be compiled into dex", depName)
return false
}
filesInfo = append(filesInfo, af)
return true // track transitive dependencies
default:
ctx.PropertyErrorf("boot_images", "boot image content %q of type %q is not supported", depName, ctx.OtherModuleType(child))
}
} else if _, ok := depTag.(android.CopyDirectlyInAnyApexTag); ok { } else if _, ok := depTag.(android.CopyDirectlyInAnyApexTag); ok {
// nothing // nothing
} else if am.CanHaveApexVariants() && am.IsInstallableToApex() { } else if am.CanHaveApexVariants() && am.IsInstallableToApex() {

View File

@@ -177,8 +177,10 @@ func TestBootImageInArtApex(t *testing.T) {
boot_images: [ boot_images: [
"mybootimage", "mybootimage",
], ],
// bar (like foo) should be transitively included in this apex because it is part of the
// mybootimage boot_image. However, it is kept here to ensure that the apex dedups the files
// correctly.
java_libs: [ java_libs: [
"foo",
"bar", "bar",
], ],
updatable: false, updatable: false,
@@ -247,7 +249,6 @@ func TestBootImageInArtApex(t *testing.T) {
java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{ java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{
`bar`, `bar`,
`com.android.art.key`, `com.android.art.key`,
`foo`,
`mybootimage`, `mybootimage`,
}) })
} }
@@ -365,8 +366,12 @@ func TestBootImageContentsNoName(t *testing.T) {
} }
`) `)
// The apex is empty because the contents of boot_image are not transitively included, yet! ensureExactContents(t, result.TestContext, "myapex", "android_common_myapex_image", []string{
ensureExactContents(t, result.TestContext, "myapex", "android_common_myapex_image", []string{}) // This does not include art, oat or vdex files as they are only included for the art boot
// image.
"javalib/bar.jar",
"javalib/foo.jar",
})
java.CheckModuleDependencies(t, result.TestContext, "myapex", "android_common_myapex_image", []string{ java.CheckModuleDependencies(t, result.TestContext, "myapex", "android_common_myapex_image", []string{
`myapex.key`, `myapex.key`,

View File

@@ -70,6 +70,10 @@ var bootImageContentDepTag = bootImageContentDependencyTag{}
var _ android.ExcludeFromVisibilityEnforcementTag = bootImageContentDepTag var _ android.ExcludeFromVisibilityEnforcementTag = bootImageContentDepTag
func IsbootImageContentDepTag(tag blueprint.DependencyTag) bool {
return tag == bootImageContentDepTag
}
type bootImageProperties struct { type bootImageProperties struct {
// The name of the image this represents. // The name of the image this represents.
// //
@@ -182,8 +186,8 @@ func (i BootImageInfo) AndroidBootImageFilesByArchType() map[android.ArchType]an
func (b *BootImageModule) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { func (b *BootImageModule) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
tag := ctx.OtherModuleDependencyTag(dep) tag := ctx.OtherModuleDependencyTag(dep)
if tag == bootImageContentDepTag { if tag == bootImageContentDepTag {
// Boot image contents are not automatically added to apex, yet. // Boot image contents are automatically added to apex.
return false return true
} }
if android.IsMetaDependencyTag(tag) { if android.IsMetaDependencyTag(tag) {
// Cross-cutting metadata dependencies are metadata. // Cross-cutting metadata dependencies are metadata.