Rename BootImageModule to BootclasspathFragmentModule am: 7771eba88e
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1685589 Change-Id: Id66bf95afa1fcf422368a2fa4236678918854153
This commit is contained in:
@@ -30,7 +30,7 @@ bootstrap_go_package {
|
|||||||
],
|
],
|
||||||
testSrcs: [
|
testSrcs: [
|
||||||
"apex_test.go",
|
"apex_test.go",
|
||||||
"boot_image_test.go",
|
"bootclasspath_fragment_test.go",
|
||||||
"platform_bootclasspath_test.go",
|
"platform_bootclasspath_test.go",
|
||||||
"vndk_test.go",
|
"vndk_test.go",
|
||||||
],
|
],
|
||||||
|
@@ -1695,7 +1695,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
}
|
}
|
||||||
case bcpfTag:
|
case bcpfTag:
|
||||||
{
|
{
|
||||||
if _, ok := child.(*java.BootImageModule); !ok {
|
if _, ok := child.(*java.BootclasspathFragmentModule); !ok {
|
||||||
ctx.PropertyErrorf("bootclasspath_fragments", "%q is not a boot_image module", depName)
|
ctx.PropertyErrorf("bootclasspath_fragments", "%q is not a boot_image module", depName)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@@ -22,8 +22,8 @@ import (
|
|||||||
"android/soong/java"
|
"android/soong/java"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Contains tests for boot_image logic from java/boot_image.go as the ART boot image requires
|
// Contains tests for bootclasspath_fragment logic from java/bootclasspath_fragment.go as the ART
|
||||||
// modules from the ART apex.
|
// bootclasspath_fragment requires modules from the ART apex.
|
||||||
|
|
||||||
var prepareForTestWithBootclasspathFragment = android.GroupFixturePreparers(
|
var prepareForTestWithBootclasspathFragment = android.GroupFixturePreparers(
|
||||||
java.PrepareForTestWithDexpreopt,
|
java.PrepareForTestWithDexpreopt,
|
||||||
@@ -40,7 +40,7 @@ var prepareForTestWithArtApex = android.FixtureMergeMockFs(android.MockFS{
|
|||||||
func TestBootclasspathFragments(t *testing.T) {
|
func TestBootclasspathFragments(t *testing.T) {
|
||||||
result := android.GroupFixturePreparers(
|
result := android.GroupFixturePreparers(
|
||||||
prepareForTestWithBootclasspathFragment,
|
prepareForTestWithBootclasspathFragment,
|
||||||
// Configure some libraries in the art and framework boot images.
|
// Configure some libraries in the art bootclasspath_fragment and platform_bootclasspath.
|
||||||
java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz", "platform:foo", "platform:bar"),
|
java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz", "platform:foo", "platform:bar"),
|
||||||
prepareForTestWithArtApex,
|
prepareForTestWithArtApex,
|
||||||
|
|
||||||
@@ -141,9 +141,9 @@ test_device/dex_artjars/android/apex/art_boot_images/javalib/arm64/boot-quuz.vde
|
|||||||
func checkBootclasspathFragment(t *testing.T, result *android.TestResult, moduleName string, expectedConfiguredModules string, expectedBootclasspathFragmentFiles string) {
|
func checkBootclasspathFragment(t *testing.T, result *android.TestResult, moduleName string, expectedConfiguredModules string, expectedBootclasspathFragmentFiles string) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
bootImage := result.ModuleForTests(moduleName, "android_common").Module().(*java.BootImageModule)
|
bootclasspathFragment := result.ModuleForTests(moduleName, "android_common").Module().(*java.BootclasspathFragmentModule)
|
||||||
|
|
||||||
bootImageInfo := result.ModuleProvider(bootImage, java.BootImageInfoProvider).(java.BootImageInfo)
|
bootImageInfo := result.ModuleProvider(bootclasspathFragment, java.BootImageInfoProvider).(java.BootImageInfo)
|
||||||
modules := bootImageInfo.Modules()
|
modules := bootImageInfo.Modules()
|
||||||
android.AssertStringEquals(t, "invalid modules for "+moduleName, expectedConfiguredModules, modules.String())
|
android.AssertStringEquals(t, "invalid modules for "+moduleName, expectedConfiguredModules, modules.String())
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) {
|
|||||||
prepareForTestWithBootclasspathFragment,
|
prepareForTestWithBootclasspathFragment,
|
||||||
prepareForTestWithArtApex,
|
prepareForTestWithArtApex,
|
||||||
|
|
||||||
// Configure some libraries in the art boot image.
|
// Configure some libraries in the art bootclasspath_fragment.
|
||||||
java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"),
|
java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"),
|
||||||
).RunTestWithBp(t, `
|
).RunTestWithBp(t, `
|
||||||
apex {
|
apex {
|
||||||
@@ -176,8 +176,8 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) {
|
|||||||
"mybootclasspathfragment",
|
"mybootclasspathfragment",
|
||||||
],
|
],
|
||||||
// bar (like foo) should be transitively included in this apex because it is part of the
|
// bar (like foo) should be transitively included in this apex because it is part of the
|
||||||
// mybootclasspathfragment boot_image. However, it is kept here to ensure that the apex dedups the files
|
// mybootclasspathfragment bootclasspath_fragment. However, it is kept here to ensure that the
|
||||||
// correctly.
|
// apex dedups the files correctly.
|
||||||
java_libs: [
|
java_libs: [
|
||||||
"bar",
|
"bar",
|
||||||
],
|
],
|
||||||
@@ -208,7 +208,7 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
boot_image {
|
bootclasspath_fragment {
|
||||||
name: "mybootclasspathfragment",
|
name: "mybootclasspathfragment",
|
||||||
image_name: "art",
|
image_name: "art",
|
||||||
apex_available: [
|
apex_available: [
|
||||||
@@ -233,7 +233,7 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make sure that a preferred prebuilt doesn't affect the apex.
|
// Make sure that a preferred prebuilt doesn't affect the apex.
|
||||||
prebuilt_boot_image {
|
prebuilt_bootclasspath_fragment {
|
||||||
name: "mybootclasspathfragment",
|
name: "mybootclasspathfragment",
|
||||||
image_name: "art",
|
image_name: "art",
|
||||||
prefer: true,
|
prefer: true,
|
||||||
@@ -277,7 +277,7 @@ func TestBootclasspathFragmentInPrebuiltArtApex(t *testing.T) {
|
|||||||
"com.android.art-arm.apex": nil,
|
"com.android.art-arm.apex": nil,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// Configure some libraries in the art boot image.
|
// Configure some libraries in the art bootclasspath_fragment.
|
||||||
java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"),
|
java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"),
|
||||||
).RunTestWithBp(t, `
|
).RunTestWithBp(t, `
|
||||||
prebuilt_apex {
|
prebuilt_apex {
|
||||||
@@ -309,7 +309,7 @@ func TestBootclasspathFragmentInPrebuiltArtApex(t *testing.T) {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
prebuilt_boot_image {
|
prebuilt_bootclasspath_fragment {
|
||||||
name: "mybootclasspathfragment",
|
name: "mybootclasspathfragment",
|
||||||
image_name: "art",
|
image_name: "art",
|
||||||
apex_available: [
|
apex_available: [
|
||||||
@@ -369,7 +369,7 @@ func TestBootclasspathFragmentContentsNoName(t *testing.T) {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
boot_image {
|
bootclasspath_fragment {
|
||||||
name: "mybootclasspathfragment",
|
name: "mybootclasspathfragment",
|
||||||
contents: [
|
contents: [
|
||||||
"foo",
|
"foo",
|
@@ -29,9 +29,9 @@ bootstrap_go_package {
|
|||||||
"app_import.go",
|
"app_import.go",
|
||||||
"app_set.go",
|
"app_set.go",
|
||||||
"base.go",
|
"base.go",
|
||||||
"boot_image.go",
|
|
||||||
"boot_jars.go",
|
"boot_jars.go",
|
||||||
"bootclasspath.go",
|
"bootclasspath.go",
|
||||||
|
"bootclasspath_fragment.go",
|
||||||
"builder.go",
|
"builder.go",
|
||||||
"classpath_fragment.go",
|
"classpath_fragment.go",
|
||||||
"device_host_converter.go",
|
"device_host_converter.go",
|
||||||
@@ -73,7 +73,7 @@ bootstrap_go_package {
|
|||||||
"app_import_test.go",
|
"app_import_test.go",
|
||||||
"app_set_test.go",
|
"app_set_test.go",
|
||||||
"app_test.go",
|
"app_test.go",
|
||||||
"boot_image_test.go",
|
"bootclasspath_fragment_test.go",
|
||||||
"device_host_converter_test.go",
|
"device_host_converter_test.go",
|
||||||
"dexpreopt_test.go",
|
"dexpreopt_test.go",
|
||||||
"dexpreopt_bootjars_test.go",
|
"dexpreopt_bootjars_test.go",
|
||||||
|
@@ -27,17 +27,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
RegisterBootImageBuildComponents(android.InitRegistrationContext)
|
registerBootclasspathFragmentBuildComponents(android.InitRegistrationContext)
|
||||||
|
|
||||||
// TODO(b/177892522): Remove after has been replaced by bootclasspath_fragments
|
// TODO(b/177892522): Remove after has been replaced by bootclasspath_fragments
|
||||||
android.RegisterSdkMemberType(&bootImageMemberType{
|
android.RegisterSdkMemberType(&bootclasspathFragmentMemberType{
|
||||||
SdkMemberTypeBase: android.SdkMemberTypeBase{
|
SdkMemberTypeBase: android.SdkMemberTypeBase{
|
||||||
PropertyName: "boot_images",
|
PropertyName: "boot_images",
|
||||||
SupportsSdk: true,
|
SupportsSdk: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
android.RegisterSdkMemberType(&bootImageMemberType{
|
android.RegisterSdkMemberType(&bootclasspathFragmentMemberType{
|
||||||
SdkMemberTypeBase: android.SdkMemberTypeBase{
|
SdkMemberTypeBase: android.SdkMemberTypeBase{
|
||||||
PropertyName: "bootclasspath_fragments",
|
PropertyName: "bootclasspath_fragments",
|
||||||
SupportsSdk: true,
|
SupportsSdk: true,
|
||||||
@@ -45,23 +45,23 @@ func init() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterBootImageBuildComponents(ctx android.RegistrationContext) {
|
func registerBootclasspathFragmentBuildComponents(ctx android.RegistrationContext) {
|
||||||
// TODO(b/177892522): Remove after has been replaced by bootclasspath_fragment
|
// TODO(b/177892522): Remove after has been replaced by bootclasspath_fragment
|
||||||
ctx.RegisterModuleType("boot_image", bootImageFactory)
|
ctx.RegisterModuleType("boot_image", bootclasspathFragmentFactory)
|
||||||
ctx.RegisterModuleType("prebuilt_boot_image", prebuiltBootImageFactory)
|
ctx.RegisterModuleType("prebuilt_boot_image", prebuiltBootclasspathFragmentFactory)
|
||||||
|
|
||||||
ctx.RegisterModuleType("bootclasspath_fragment", bootImageFactory)
|
ctx.RegisterModuleType("bootclasspath_fragment", bootclasspathFragmentFactory)
|
||||||
ctx.RegisterModuleType("prebuilt_bootclasspath_fragment", prebuiltBootImageFactory)
|
ctx.RegisterModuleType("prebuilt_bootclasspath_fragment", prebuiltBootclasspathFragmentFactory)
|
||||||
}
|
}
|
||||||
|
|
||||||
type bootclasspathFragmentContentDependencyTag struct {
|
type bootclasspathFragmentContentDependencyTag struct {
|
||||||
blueprint.BaseDependencyTag
|
blueprint.BaseDependencyTag
|
||||||
}
|
}
|
||||||
|
|
||||||
// Avoid having to make boot image content visible to the boot image.
|
// Avoid having to make bootclasspath_fragment content visible to the bootclasspath_fragment.
|
||||||
//
|
//
|
||||||
// This is a temporary workaround to make it easier to migrate to boot image modules with proper
|
// This is a temporary workaround to make it easier to migrate to bootclasspath_fragment modules
|
||||||
// dependencies.
|
// with proper dependencies.
|
||||||
// TODO(b/177892522): Remove this and add needed visibility.
|
// TODO(b/177892522): Remove this and add needed visibility.
|
||||||
func (b bootclasspathFragmentContentDependencyTag) ExcludeFromVisibilityEnforcement() {
|
func (b bootclasspathFragmentContentDependencyTag) ExcludeFromVisibilityEnforcement() {
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@ func (b bootclasspathFragmentContentDependencyTag) ReplaceSourceWithPrebuilt() b
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// The tag used for the dependency between the boot image module and its contents.
|
// The tag used for the dependency between the bootclasspath_fragment module and its contents.
|
||||||
var bootclasspathFragmentContentDepTag = bootclasspathFragmentContentDependencyTag{}
|
var bootclasspathFragmentContentDepTag = bootclasspathFragmentContentDependencyTag{}
|
||||||
|
|
||||||
var _ android.ExcludeFromVisibilityEnforcementTag = bootclasspathFragmentContentDepTag
|
var _ android.ExcludeFromVisibilityEnforcementTag = bootclasspathFragmentContentDepTag
|
||||||
@@ -81,13 +81,13 @@ func IsBootclasspathFragmentContentDepTag(tag blueprint.DependencyTag) bool {
|
|||||||
return tag == bootclasspathFragmentContentDepTag
|
return tag == bootclasspathFragmentContentDepTag
|
||||||
}
|
}
|
||||||
|
|
||||||
type bootImageProperties struct {
|
type bootclasspathFragmentProperties struct {
|
||||||
// The name of the image this represents.
|
// The name of the image this represents.
|
||||||
//
|
//
|
||||||
// If specified then it must be one of "art" or "boot".
|
// If specified then it must be one of "art" or "boot".
|
||||||
Image_name *string
|
Image_name *string
|
||||||
|
|
||||||
// The contents of this boot image, could be either java_library, java_sdk_library, or boot_image.
|
// The contents of this bootclasspath_fragment, 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.
|
// The order of this list matters as it is the order that is used in the bootclasspath.
|
||||||
Contents []string
|
Contents []string
|
||||||
@@ -95,28 +95,30 @@ type bootImageProperties struct {
|
|||||||
Hidden_api HiddenAPIFlagFileProperties
|
Hidden_api HiddenAPIFlagFileProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
type BootImageModule struct {
|
type BootclasspathFragmentModule struct {
|
||||||
android.ModuleBase
|
android.ModuleBase
|
||||||
android.ApexModuleBase
|
android.ApexModuleBase
|
||||||
android.SdkBase
|
android.SdkBase
|
||||||
properties bootImageProperties
|
properties bootclasspathFragmentProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
func bootImageFactory() android.Module {
|
func bootclasspathFragmentFactory() android.Module {
|
||||||
m := &BootImageModule{}
|
m := &BootclasspathFragmentModule{}
|
||||||
m.AddProperties(&m.properties)
|
m.AddProperties(&m.properties)
|
||||||
android.InitApexModule(m)
|
android.InitApexModule(m)
|
||||||
android.InitSdkAwareModule(m)
|
android.InitSdkAwareModule(m)
|
||||||
android.InitAndroidArchModule(m, android.HostAndDeviceSupported, android.MultilibCommon)
|
android.InitAndroidArchModule(m, android.HostAndDeviceSupported, android.MultilibCommon)
|
||||||
|
|
||||||
// Perform some consistency checking to ensure that the configuration is correct.
|
// Initialize the contents property from the image_name.
|
||||||
android.AddLoadHook(m, func(ctx android.LoadHookContext) {
|
android.AddLoadHook(m, func(ctx android.LoadHookContext) {
|
||||||
bootImageConsistencyCheck(ctx, m)
|
bootclasspathFragmentInitContentsFromImage(ctx, m)
|
||||||
})
|
})
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
func bootImageConsistencyCheck(ctx android.EarlyModuleContext, m *BootImageModule) {
|
// bootclasspathFragmentInitContentsFromImage will initialize the contents property from the image_name if
|
||||||
|
// necessary.
|
||||||
|
func bootclasspathFragmentInitContentsFromImage(ctx android.EarlyModuleContext, m *BootclasspathFragmentModule) {
|
||||||
contents := m.properties.Contents
|
contents := m.properties.Contents
|
||||||
if m.properties.Image_name == nil && len(contents) == 0 {
|
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`)
|
ctx.ModuleErrorf(`neither of the "image_name" and "contents" properties have been supplied, please supply exactly one`)
|
||||||
@@ -206,7 +208,7 @@ func (i BootImageInfo) AndroidBootImageFilesByArchType() map[android.ArchType]an
|
|||||||
return files
|
return files
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BootImageModule) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
|
func (b *BootclasspathFragmentModule) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
|
||||||
tag := ctx.OtherModuleDependencyTag(dep)
|
tag := ctx.OtherModuleDependencyTag(dep)
|
||||||
if IsBootclasspathFragmentContentDepTag(tag) {
|
if IsBootclasspathFragmentContentDepTag(tag) {
|
||||||
// Boot image contents are automatically added to apex.
|
// Boot image contents are automatically added to apex.
|
||||||
@@ -219,7 +221,7 @@ func (b *BootImageModule) DepIsInSameApex(ctx android.BaseModuleContext, dep and
|
|||||||
panic(fmt.Errorf("boot_image module %q should not have a dependency on %q via tag %s", b, dep, android.PrettyPrintTag(tag)))
|
panic(fmt.Errorf("boot_image module %q should not have a dependency on %q via tag %s", b, dep, android.PrettyPrintTag(tag)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BootImageModule) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error {
|
func (b *BootclasspathFragmentModule) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,9 +229,9 @@ func (b *BootImageModule) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
|
|||||||
// corresponding source module are renamed. This means that adding a dependency using a name without
|
// corresponding source module are renamed. This means that adding a dependency using a name without
|
||||||
// a prebuilt_ prefix will always resolve to a source module and when using a name with that prefix
|
// a prebuilt_ prefix will always resolve to a source module and when using a name with that prefix
|
||||||
// it will always resolve to a prebuilt module.
|
// it will always resolve to a prebuilt module.
|
||||||
func (b *BootImageModule) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
|
func (b *BootclasspathFragmentModule) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
module := ctx.Module()
|
module := ctx.Module()
|
||||||
_, isSourceModule := module.(*BootImageModule)
|
_, isSourceModule := module.(*BootclasspathFragmentModule)
|
||||||
|
|
||||||
for _, name := range b.properties.Contents {
|
for _, name := range b.properties.Contents {
|
||||||
// A bootclasspath_fragment must depend only on other source modules, while the
|
// A bootclasspath_fragment must depend only on other source modules, while the
|
||||||
@@ -244,7 +246,7 @@ func (b *BootImageModule) ComponentDepsMutator(ctx android.BottomUpMutatorContex
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BootImageModule) DepsMutator(ctx android.BottomUpMutatorContext) {
|
func (b *BootclasspathFragmentModule) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
|
|
||||||
if SkipDexpreoptBootJars(ctx) {
|
if SkipDexpreoptBootJars(ctx) {
|
||||||
return
|
return
|
||||||
@@ -255,7 +257,7 @@ func (b *BootImageModule) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
dexpreopt.RegisterToolDeps(ctx)
|
dexpreopt.RegisterToolDeps(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BootImageModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
// Perform hidden API processing.
|
// Perform hidden API processing.
|
||||||
b.generateHiddenAPIBuildActions(ctx)
|
b.generateHiddenAPIBuildActions(ctx)
|
||||||
|
|
||||||
@@ -280,7 +282,7 @@ func (b *BootImageModule) GenerateAndroidBuildActions(ctx android.ModuleContext)
|
|||||||
ctx.SetProvider(BootImageInfoProvider, info)
|
ctx.SetProvider(BootImageInfoProvider, info)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BootImageModule) getImageConfig(ctx android.EarlyModuleContext) *bootImageConfig {
|
func (b *BootclasspathFragmentModule) getImageConfig(ctx android.EarlyModuleContext) *bootImageConfig {
|
||||||
// Get a map of the image configs that are supported.
|
// Get a map of the image configs that are supported.
|
||||||
imageConfigs := genBootImageConfigs(ctx)
|
imageConfigs := genBootImageConfigs(ctx)
|
||||||
|
|
||||||
@@ -300,7 +302,7 @@ func (b *BootImageModule) getImageConfig(ctx android.EarlyModuleContext) *bootIm
|
|||||||
}
|
}
|
||||||
|
|
||||||
// generateHiddenAPIBuildActions generates all the hidden API related build rules.
|
// generateHiddenAPIBuildActions generates all the hidden API related build rules.
|
||||||
func (b *BootImageModule) generateHiddenAPIBuildActions(ctx android.ModuleContext) {
|
func (b *BootclasspathFragmentModule) generateHiddenAPIBuildActions(ctx android.ModuleContext) {
|
||||||
// Resolve the properties to paths.
|
// Resolve the properties to paths.
|
||||||
flagFileInfo := b.properties.Hidden_api.hiddenAPIFlagFileInfo(ctx)
|
flagFileInfo := b.properties.Hidden_api.hiddenAPIFlagFileInfo(ctx)
|
||||||
|
|
||||||
@@ -308,20 +310,20 @@ func (b *BootImageModule) generateHiddenAPIBuildActions(ctx android.ModuleContex
|
|||||||
ctx.SetProvider(hiddenAPIFlagFileInfoProvider, flagFileInfo)
|
ctx.SetProvider(hiddenAPIFlagFileInfoProvider, flagFileInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
type bootImageMemberType struct {
|
type bootclasspathFragmentMemberType struct {
|
||||||
android.SdkMemberTypeBase
|
android.SdkMemberTypeBase
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *bootImageMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) {
|
func (b *bootclasspathFragmentMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) {
|
||||||
mctx.AddVariationDependencies(nil, dependencyTag, names...)
|
mctx.AddVariationDependencies(nil, dependencyTag, names...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *bootImageMemberType) IsInstance(module android.Module) bool {
|
func (b *bootclasspathFragmentMemberType) IsInstance(module android.Module) bool {
|
||||||
_, ok := module.(*BootImageModule)
|
_, ok := module.(*BootclasspathFragmentModule)
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *bootImageMemberType) AddPrebuiltModule(ctx android.SdkMemberContext, member android.SdkMember) android.BpModule {
|
func (b *bootclasspathFragmentMemberType) AddPrebuiltModule(ctx android.SdkMemberContext, member android.SdkMember) android.BpModule {
|
||||||
if b.PropertyName == "boot_images" {
|
if b.PropertyName == "boot_images" {
|
||||||
return ctx.SnapshotBuilder().AddPrebuiltModule(member, "prebuilt_boot_image")
|
return ctx.SnapshotBuilder().AddPrebuiltModule(member, "prebuilt_boot_image")
|
||||||
} else {
|
} else {
|
||||||
@@ -329,11 +331,11 @@ func (b *bootImageMemberType) AddPrebuiltModule(ctx android.SdkMemberContext, me
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *bootImageMemberType) CreateVariantPropertiesStruct() android.SdkMemberProperties {
|
func (b *bootclasspathFragmentMemberType) CreateVariantPropertiesStruct() android.SdkMemberProperties {
|
||||||
return &bootImageSdkMemberProperties{}
|
return &bootclasspathFragmentSdkMemberProperties{}
|
||||||
}
|
}
|
||||||
|
|
||||||
type bootImageSdkMemberProperties struct {
|
type bootclasspathFragmentSdkMemberProperties struct {
|
||||||
android.SdkMemberPropertiesBase
|
android.SdkMemberPropertiesBase
|
||||||
|
|
||||||
// The image name
|
// The image name
|
||||||
@@ -346,8 +348,8 @@ type bootImageSdkMemberProperties struct {
|
|||||||
Flag_files_by_category map[*hiddenAPIFlagFileCategory]android.Paths
|
Flag_files_by_category map[*hiddenAPIFlagFileCategory]android.Paths
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *bootImageSdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) {
|
func (b *bootclasspathFragmentSdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) {
|
||||||
module := variant.(*BootImageModule)
|
module := variant.(*BootclasspathFragmentModule)
|
||||||
|
|
||||||
b.Image_name = module.properties.Image_name
|
b.Image_name = module.properties.Image_name
|
||||||
if b.Image_name == nil {
|
if b.Image_name == nil {
|
||||||
@@ -363,7 +365,7 @@ func (b *bootImageSdkMemberProperties) PopulateFromVariant(ctx android.SdkMember
|
|||||||
b.Flag_files_by_category = flagFileInfo.categoryToPaths
|
b.Flag_files_by_category = flagFileInfo.categoryToPaths
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *bootImageSdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
|
func (b *bootclasspathFragmentSdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
|
||||||
if b.Image_name != nil {
|
if b.Image_name != nil {
|
||||||
propertySet.AddProperty("image_name", *b.Image_name)
|
propertySet.AddProperty("image_name", *b.Image_name)
|
||||||
}
|
}
|
||||||
@@ -390,28 +392,28 @@ func (b *bootImageSdkMemberProperties) AddToPropertySet(ctx android.SdkMemberCon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ android.SdkMemberType = (*bootImageMemberType)(nil)
|
var _ android.SdkMemberType = (*bootclasspathFragmentMemberType)(nil)
|
||||||
|
|
||||||
// A prebuilt version of the boot image module.
|
// A prebuilt version of the bootclasspath_fragment module.
|
||||||
//
|
//
|
||||||
// At the moment this is basically just a boot image module that can be used as a prebuilt.
|
// At the moment this is basically just a bootclasspath_fragment module that can be used as a
|
||||||
// Eventually as more functionality is migrated into the boot image module from the singleton then
|
// prebuilt. Eventually as more functionality is migrated into the bootclasspath_fragment module
|
||||||
// this will diverge.
|
// type from the various singletons then this will diverge.
|
||||||
type prebuiltBootImageModule struct {
|
type prebuiltBootclasspathFragmentModule struct {
|
||||||
BootImageModule
|
BootclasspathFragmentModule
|
||||||
prebuilt android.Prebuilt
|
prebuilt android.Prebuilt
|
||||||
}
|
}
|
||||||
|
|
||||||
func (module *prebuiltBootImageModule) Prebuilt() *android.Prebuilt {
|
func (module *prebuiltBootclasspathFragmentModule) Prebuilt() *android.Prebuilt {
|
||||||
return &module.prebuilt
|
return &module.prebuilt
|
||||||
}
|
}
|
||||||
|
|
||||||
func (module *prebuiltBootImageModule) Name() string {
|
func (module *prebuiltBootclasspathFragmentModule) Name() string {
|
||||||
return module.prebuilt.Name(module.ModuleBase.Name())
|
return module.prebuilt.Name(module.ModuleBase.Name())
|
||||||
}
|
}
|
||||||
|
|
||||||
func prebuiltBootImageFactory() android.Module {
|
func prebuiltBootclasspathFragmentFactory() android.Module {
|
||||||
m := &prebuiltBootImageModule{}
|
m := &prebuiltBootclasspathFragmentModule{}
|
||||||
m.AddProperties(&m.properties)
|
m.AddProperties(&m.properties)
|
||||||
// This doesn't actually have any prebuilt files of its own so pass a placeholder for the srcs
|
// This doesn't actually have any prebuilt files of its own so pass a placeholder for the srcs
|
||||||
// array.
|
// array.
|
||||||
@@ -420,9 +422,9 @@ func prebuiltBootImageFactory() android.Module {
|
|||||||
android.InitSdkAwareModule(m)
|
android.InitSdkAwareModule(m)
|
||||||
android.InitAndroidArchModule(m, android.HostAndDeviceSupported, android.MultilibCommon)
|
android.InitAndroidArchModule(m, android.HostAndDeviceSupported, android.MultilibCommon)
|
||||||
|
|
||||||
// Perform some consistency checking to ensure that the configuration is correct.
|
// Initialize the contents property from the image_name.
|
||||||
android.AddLoadHook(m, func(ctx android.LoadHookContext) {
|
android.AddLoadHook(m, func(ctx android.LoadHookContext) {
|
||||||
bootImageConsistencyCheck(ctx, &m.BootImageModule)
|
bootclasspathFragmentInitContentsFromImage(ctx, &m.BootclasspathFragmentModule)
|
||||||
})
|
})
|
||||||
return m
|
return m
|
||||||
}
|
}
|
@@ -21,60 +21,60 @@ import (
|
|||||||
"android/soong/dexpreopt"
|
"android/soong/dexpreopt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Contains some simple tests for boot_image logic, additional tests can be found in
|
// Contains some simple tests for bootclasspath_fragment logic, additional tests can be found in
|
||||||
// apex/boot_image_test.go as the ART boot image requires modules from the ART apex.
|
// apex/bootclasspath_fragment_test.go as the ART boot image requires modules from the ART apex.
|
||||||
|
|
||||||
var prepareForTestWithBootImage = android.GroupFixturePreparers(
|
var prepareForTestWithBootclasspathFragment = android.GroupFixturePreparers(
|
||||||
PrepareForTestWithJavaDefaultModules,
|
PrepareForTestWithJavaDefaultModules,
|
||||||
dexpreopt.PrepareForTestByEnablingDexpreopt,
|
dexpreopt.PrepareForTestByEnablingDexpreopt,
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestUnknownBootImage(t *testing.T) {
|
func TestUnknownBootclasspathFragment(t *testing.T) {
|
||||||
prepareForTestWithBootImage.
|
prepareForTestWithBootclasspathFragment.
|
||||||
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
||||||
`\Qimage_name: Unknown image name "unknown", expected one of art, boot\E`)).
|
`\Qimage_name: Unknown image name "unknown", expected one of art, boot\E`)).
|
||||||
RunTestWithBp(t, `
|
RunTestWithBp(t, `
|
||||||
boot_image {
|
bootclasspath_fragment {
|
||||||
name: "unknown-boot-image",
|
name: "unknown-bootclasspath-fragment",
|
||||||
image_name: "unknown",
|
image_name: "unknown",
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUnknownBootclasspathFragmentImageName(t *testing.T) {
|
func TestUnknownBootclasspathFragmentImageName(t *testing.T) {
|
||||||
prepareForTestWithBootImage.
|
prepareForTestWithBootclasspathFragment.
|
||||||
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
||||||
`\Qimage_name: Unknown image name "unknown", expected one of art, boot\E`)).
|
`\Qimage_name: Unknown image name "unknown", expected one of art, boot\E`)).
|
||||||
RunTestWithBp(t, `
|
RunTestWithBp(t, `
|
||||||
bootclasspath_fragment {
|
bootclasspath_fragment {
|
||||||
name: "unknown-boot-image",
|
name: "unknown-bootclasspath-fragment",
|
||||||
image_name: "unknown",
|
image_name: "unknown",
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUnknownPrebuiltBootImage(t *testing.T) {
|
func TestUnknownPrebuiltBootclasspathFragment(t *testing.T) {
|
||||||
prepareForTestWithBootImage.
|
prepareForTestWithBootclasspathFragment.
|
||||||
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
||||||
`\Qimage_name: Unknown image name "unknown", expected one of art, boot\E`)).
|
`\Qimage_name: Unknown image name "unknown", expected one of art, boot\E`)).
|
||||||
RunTestWithBp(t, `
|
RunTestWithBp(t, `
|
||||||
prebuilt_boot_image {
|
prebuilt_bootclasspath_fragment {
|
||||||
name: "unknown-boot-image",
|
name: "unknown-bootclasspath-fragment",
|
||||||
image_name: "unknown",
|
image_name: "unknown",
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBootImageInconsistentArtConfiguration_Platform(t *testing.T) {
|
func TestBootclasspathFragmentInconsistentArtConfiguration_Platform(t *testing.T) {
|
||||||
android.GroupFixturePreparers(
|
android.GroupFixturePreparers(
|
||||||
prepareForTestWithBootImage,
|
prepareForTestWithBootclasspathFragment,
|
||||||
dexpreopt.FixtureSetArtBootJars("platform:foo", "apex:bar"),
|
dexpreopt.FixtureSetArtBootJars("platform:foo", "apex:bar"),
|
||||||
).
|
).
|
||||||
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
||||||
`\QArtApexJars is invalid as it requests a platform variant of "foo"\E`)).
|
`\QArtApexJars is invalid as it requests a platform variant of "foo"\E`)).
|
||||||
RunTestWithBp(t, `
|
RunTestWithBp(t, `
|
||||||
boot_image {
|
bootclasspath_fragment {
|
||||||
name: "boot-image",
|
name: "bootclasspath-fragment",
|
||||||
image_name: "art",
|
image_name: "art",
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"apex",
|
"apex",
|
||||||
@@ -83,16 +83,16 @@ func TestBootImageInconsistentArtConfiguration_Platform(t *testing.T) {
|
|||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBootImageInconsistentArtConfiguration_ApexMixture(t *testing.T) {
|
func TestBootclasspathFragmentInconsistentArtConfiguration_ApexMixture(t *testing.T) {
|
||||||
android.GroupFixturePreparers(
|
android.GroupFixturePreparers(
|
||||||
prepareForTestWithBootImage,
|
prepareForTestWithBootclasspathFragment,
|
||||||
dexpreopt.FixtureSetArtBootJars("apex1:foo", "apex2:bar"),
|
dexpreopt.FixtureSetArtBootJars("apex1:foo", "apex2:bar"),
|
||||||
).
|
).
|
||||||
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
||||||
`\QArtApexJars configuration is inconsistent, expected all jars to be in the same apex but it specifies apex "apex1" and "apex2"\E`)).
|
`\QArtApexJars configuration is inconsistent, expected all jars to be in the same apex but it specifies apex "apex1" and "apex2"\E`)).
|
||||||
RunTestWithBp(t, `
|
RunTestWithBp(t, `
|
||||||
boot_image {
|
bootclasspath_fragment {
|
||||||
name: "boot-image",
|
name: "bootclasspath-fragment",
|
||||||
image_name: "art",
|
image_name: "art",
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"apex1",
|
"apex1",
|
||||||
@@ -102,24 +102,24 @@ func TestBootImageInconsistentArtConfiguration_ApexMixture(t *testing.T) {
|
|||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBootImageWithoutImageNameOrContents(t *testing.T) {
|
func TestBootclasspathFragmentWithoutImageNameOrContents(t *testing.T) {
|
||||||
prepareForTestWithBootImage.
|
prepareForTestWithBootclasspathFragment.
|
||||||
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
||||||
`\Qneither of the "image_name" and "contents" properties\E`)).
|
`\Qneither of the "image_name" and "contents" properties\E`)).
|
||||||
RunTestWithBp(t, `
|
RunTestWithBp(t, `
|
||||||
boot_image {
|
bootclasspath_fragment {
|
||||||
name: "boot-image",
|
name: "bootclasspath-fragment",
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBootImageWithImageNameAndContents(t *testing.T) {
|
func TestBootclasspathFragmentWithImageNameAndContents(t *testing.T) {
|
||||||
prepareForTestWithBootImage.
|
prepareForTestWithBootclasspathFragment.
|
||||||
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
||||||
`\Qboth of the "image_name" and "contents" properties\E`)).
|
`\Qboth of the "image_name" and "contents" properties\E`)).
|
||||||
RunTestWithBp(t, `
|
RunTestWithBp(t, `
|
||||||
boot_image {
|
bootclasspath_fragment {
|
||||||
name: "boot-image",
|
name: "bootclasspath-fragment",
|
||||||
image_name: "boot",
|
image_name: "boot",
|
||||||
contents: ["other"],
|
contents: ["other"],
|
||||||
}
|
}
|
@@ -233,7 +233,7 @@ func registerRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
|
|||||||
RegisterAppImportBuildComponents(ctx)
|
RegisterAppImportBuildComponents(ctx)
|
||||||
RegisterAppSetBuildComponents(ctx)
|
RegisterAppSetBuildComponents(ctx)
|
||||||
registerBootclasspathBuildComponents(ctx)
|
registerBootclasspathBuildComponents(ctx)
|
||||||
RegisterBootImageBuildComponents(ctx)
|
registerBootclasspathFragmentBuildComponents(ctx)
|
||||||
RegisterDexpreoptBootJarsComponents(ctx)
|
RegisterDexpreoptBootJarsComponents(ctx)
|
||||||
RegisterDocsBuildComponents(ctx)
|
RegisterDocsBuildComponents(ctx)
|
||||||
RegisterGenRuleBuildComponents(ctx)
|
RegisterGenRuleBuildComponents(ctx)
|
||||||
|
Reference in New Issue
Block a user