Merge "Add contents property to boot_image (and prebuilt_boot_image)"
This commit is contained in:
@@ -315,4 +315,63 @@ func TestBootImageInPrebuiltArtApex(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestBootImageContentsNoName(t *testing.T) {
|
||||
result := android.GroupFixturePreparers(
|
||||
prepareForTestWithBootImage,
|
||||
prepareForTestWithMyapex,
|
||||
).RunTestWithBp(t, `
|
||||
apex {
|
||||
name: "myapex",
|
||||
key: "myapex.key",
|
||||
boot_images: [
|
||||
"mybootimage",
|
||||
],
|
||||
updatable: false,
|
||||
}
|
||||
|
||||
apex_key {
|
||||
name: "myapex.key",
|
||||
public_key: "testkey.avbpubkey",
|
||||
private_key: "testkey.pem",
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "foo",
|
||||
srcs: ["b.java"],
|
||||
installable: true,
|
||||
apex_available: [
|
||||
"myapex",
|
||||
],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "bar",
|
||||
srcs: ["b.java"],
|
||||
installable: true,
|
||||
apex_available: [
|
||||
"myapex",
|
||||
],
|
||||
}
|
||||
|
||||
boot_image {
|
||||
name: "mybootimage",
|
||||
contents: [
|
||||
"foo",
|
||||
"bar",
|
||||
],
|
||||
apex_available: [
|
||||
"myapex",
|
||||
],
|
||||
}
|
||||
`)
|
||||
|
||||
// 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{})
|
||||
|
||||
java.CheckModuleDependencies(t, result.TestContext, "myapex", "android_common_myapex_image", []string{
|
||||
`myapex.key`,
|
||||
`mybootimage`,
|
||||
})
|
||||
}
|
||||
|
||||
// TODO(b/177892522) - add test for host apex.
|
||||
|
@@ -73,13 +73,13 @@ var _ android.ExcludeFromVisibilityEnforcementTag = bootImageContentDepTag
|
||||
type bootImageProperties struct {
|
||||
// The name of the image this represents.
|
||||
//
|
||||
// Must be one of "art" or "boot".
|
||||
// If specified then it must be one of "art" or "boot".
|
||||
Image_name *string
|
||||
|
||||
// The contents of this boot image, could be either java_library, java_sdk_library, or boot_image.
|
||||
//
|
||||
// The order of this list matters as it is the order that is used in the bootclasspath.
|
||||
Contents []string `blueprint:"mutated"`
|
||||
Contents []string
|
||||
}
|
||||
|
||||
type BootImageModule struct {
|
||||
@@ -104,6 +104,13 @@ func bootImageFactory() android.Module {
|
||||
}
|
||||
|
||||
func bootImageConsistencyCheck(ctx android.EarlyModuleContext, m *BootImageModule) {
|
||||
contents := m.properties.Contents
|
||||
if m.properties.Image_name == nil && len(contents) == 0 {
|
||||
ctx.ModuleErrorf(`neither of the "image_name" and "contents" properties have been supplied, please supply exactly one`)
|
||||
}
|
||||
if m.properties.Image_name != nil && len(contents) != 0 {
|
||||
ctx.ModuleErrorf(`both of the "image_name" and "contents" properties have been supplied, please supply exactly one`)
|
||||
}
|
||||
imageName := proptools.String(m.properties.Image_name)
|
||||
if imageName == "art" {
|
||||
// Get the configuration for the art apex jars. Do not use getImageConfig(ctx) here as this is
|
||||
|
@@ -101,3 +101,27 @@ func TestBootImageInconsistentArtConfiguration_ApexMixture(t *testing.T) {
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
func TestBootImageWithoutImageNameOrContents(t *testing.T) {
|
||||
prepareForTestWithBootImage.
|
||||
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
||||
`\Qneither of the "image_name" and "contents" properties\E`)).
|
||||
RunTestWithBp(t, `
|
||||
boot_image {
|
||||
name: "boot-image",
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
func TestBootImageWithImageNameAndContents(t *testing.T) {
|
||||
prepareForTestWithBootImage.
|
||||
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
||||
`\Qboth of the "image_name" and "contents" properties\E`)).
|
||||
RunTestWithBp(t, `
|
||||
boot_image {
|
||||
name: "boot-image",
|
||||
image_name: "boot",
|
||||
contents: ["other"],
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
Reference in New Issue
Block a user