Loading java/boot_image.go +81 −1 Original line number Diff line number Diff line Loading @@ -25,10 +25,18 @@ import ( func init() { RegisterBootImageBuildComponents(android.InitRegistrationContext) android.RegisterSdkMemberType(&bootImageMemberType{ SdkMemberTypeBase: android.SdkMemberTypeBase{ PropertyName: "boot_images", SupportsSdk: true, }, }) } func RegisterBootImageBuildComponents(ctx android.RegistrationContext) { ctx.RegisterModuleType("boot_image", bootImageFactory) ctx.RegisterModuleType("prebuilt_boot_image", prebuiltBootImageFactory) } type bootImageProperties struct { Loading @@ -41,7 +49,7 @@ type bootImageProperties struct { type BootImageModule struct { android.ModuleBase android.ApexModuleBase android.SdkBase properties bootImageProperties } Loading @@ -50,6 +58,7 @@ func bootImageFactory() android.Module { m.AddProperties(&m.properties) android.InitAndroidArchModule(m, android.HostAndDeviceSupported, android.MultilibCommon) android.InitApexModule(m) android.InitSdkAwareModule(m) return m } Loading Loading @@ -138,3 +147,74 @@ func (b *BootImageModule) GenerateAndroidBuildActions(ctx android.ModuleContext) // Make it available for other modules. ctx.SetProvider(BootImageInfoProvider, info) } type bootImageMemberType struct { android.SdkMemberTypeBase } func (b *bootImageMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) { mctx.AddVariationDependencies(nil, dependencyTag, names...) } func (b *bootImageMemberType) IsInstance(module android.Module) bool { _, ok := module.(*BootImageModule) return ok } func (b *bootImageMemberType) AddPrebuiltModule(ctx android.SdkMemberContext, member android.SdkMember) android.BpModule { return ctx.SnapshotBuilder().AddPrebuiltModule(member, "prebuilt_boot_image") } func (b *bootImageMemberType) CreateVariantPropertiesStruct() android.SdkMemberProperties { return &bootImageSdkMemberProperties{} } type bootImageSdkMemberProperties struct { android.SdkMemberPropertiesBase Image_name string } func (b *bootImageSdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) { module := variant.(*BootImageModule) b.Image_name = module.properties.Image_name } func (b *bootImageSdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) { if b.Image_name != "" { propertySet.AddProperty("image_name", b.Image_name) } } var _ android.SdkMemberType = (*bootImageMemberType)(nil) // A prebuilt version of the boot image module. // // At the moment this is basically just a boot image module that can be used as a prebuilt. // Eventually as more functionality is migrated into the boot image module from the singleton then // this will diverge. type prebuiltBootImageModule struct { BootImageModule prebuilt android.Prebuilt } func (module *prebuiltBootImageModule) Prebuilt() *android.Prebuilt { return &module.prebuilt } func (module *prebuiltBootImageModule) Name() string { return module.prebuilt.Name(module.ModuleBase.Name()) } func prebuiltBootImageFactory() android.Module { m := &prebuiltBootImageModule{} m.AddProperties(&m.properties) android.InitAndroidArchModule(m, android.HostAndDeviceSupported, android.MultilibCommon) // This doesn't actually have any prebuilt files of its own so pass a placeholder for the srcs // array. android.InitPrebuiltModule(m, &[]string{"placeholder"}) android.InitApexModule(m) android.InitSdkAwareModule(m) return m } java/boot_image_test.go +9 −0 Original line number Diff line number Diff line Loading @@ -29,3 +29,12 @@ func TestUnknownBootImage(t *testing.T) { } `) } func TestUnknownPrebuiltBootImage(t *testing.T) { testJavaError(t, "image_name: Unknown image name \\\"unknown\\\", expected one of art, boot", ` prebuilt_boot_image { name: "unknown-boot-image", image_name: "unknown", } `) } sdk/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ bootstrap_go_package { "update.go", ], testSrcs: [ "boot_image_sdk_test.go", "bp_test.go", "cc_sdk_test.go", "exports_test.go", Loading sdk/boot_image_sdk_test.go 0 → 100644 +63 −0 Original line number Diff line number Diff line // Copyright (C) 2021 The Android Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package sdk import "testing" func TestSnapshotWithBootImage(t *testing.T) { result := testSdkWithJava(t, ` sdk { name: "mysdk", boot_images: ["mybootimage"], } boot_image { name: "mybootimage", image_name: "art", } `) result.CheckSnapshot("mysdk", "", checkUnversionedAndroidBpContents(` // This is auto-generated. DO NOT EDIT. prebuilt_boot_image { name: "mybootimage", prefer: false, visibility: ["//visibility:public"], apex_available: ["//apex_available:platform"], image_name: "art", } `), checkVersionedAndroidBpContents(` // This is auto-generated. DO NOT EDIT. prebuilt_boot_image { name: "mysdk_mybootimage@current", sdk_member_name: "mybootimage", visibility: ["//visibility:public"], apex_available: ["//apex_available:platform"], image_name: "art", } sdk_snapshot { name: "mysdk@current", visibility: ["//visibility:public"], boot_images: ["mysdk_mybootimage@current"], } `), checkAllCopyRules(""), ) } Loading
java/boot_image.go +81 −1 Original line number Diff line number Diff line Loading @@ -25,10 +25,18 @@ import ( func init() { RegisterBootImageBuildComponents(android.InitRegistrationContext) android.RegisterSdkMemberType(&bootImageMemberType{ SdkMemberTypeBase: android.SdkMemberTypeBase{ PropertyName: "boot_images", SupportsSdk: true, }, }) } func RegisterBootImageBuildComponents(ctx android.RegistrationContext) { ctx.RegisterModuleType("boot_image", bootImageFactory) ctx.RegisterModuleType("prebuilt_boot_image", prebuiltBootImageFactory) } type bootImageProperties struct { Loading @@ -41,7 +49,7 @@ type bootImageProperties struct { type BootImageModule struct { android.ModuleBase android.ApexModuleBase android.SdkBase properties bootImageProperties } Loading @@ -50,6 +58,7 @@ func bootImageFactory() android.Module { m.AddProperties(&m.properties) android.InitAndroidArchModule(m, android.HostAndDeviceSupported, android.MultilibCommon) android.InitApexModule(m) android.InitSdkAwareModule(m) return m } Loading Loading @@ -138,3 +147,74 @@ func (b *BootImageModule) GenerateAndroidBuildActions(ctx android.ModuleContext) // Make it available for other modules. ctx.SetProvider(BootImageInfoProvider, info) } type bootImageMemberType struct { android.SdkMemberTypeBase } func (b *bootImageMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) { mctx.AddVariationDependencies(nil, dependencyTag, names...) } func (b *bootImageMemberType) IsInstance(module android.Module) bool { _, ok := module.(*BootImageModule) return ok } func (b *bootImageMemberType) AddPrebuiltModule(ctx android.SdkMemberContext, member android.SdkMember) android.BpModule { return ctx.SnapshotBuilder().AddPrebuiltModule(member, "prebuilt_boot_image") } func (b *bootImageMemberType) CreateVariantPropertiesStruct() android.SdkMemberProperties { return &bootImageSdkMemberProperties{} } type bootImageSdkMemberProperties struct { android.SdkMemberPropertiesBase Image_name string } func (b *bootImageSdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) { module := variant.(*BootImageModule) b.Image_name = module.properties.Image_name } func (b *bootImageSdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) { if b.Image_name != "" { propertySet.AddProperty("image_name", b.Image_name) } } var _ android.SdkMemberType = (*bootImageMemberType)(nil) // A prebuilt version of the boot image module. // // At the moment this is basically just a boot image module that can be used as a prebuilt. // Eventually as more functionality is migrated into the boot image module from the singleton then // this will diverge. type prebuiltBootImageModule struct { BootImageModule prebuilt android.Prebuilt } func (module *prebuiltBootImageModule) Prebuilt() *android.Prebuilt { return &module.prebuilt } func (module *prebuiltBootImageModule) Name() string { return module.prebuilt.Name(module.ModuleBase.Name()) } func prebuiltBootImageFactory() android.Module { m := &prebuiltBootImageModule{} m.AddProperties(&m.properties) android.InitAndroidArchModule(m, android.HostAndDeviceSupported, android.MultilibCommon) // This doesn't actually have any prebuilt files of its own so pass a placeholder for the srcs // array. android.InitPrebuiltModule(m, &[]string{"placeholder"}) android.InitApexModule(m) android.InitSdkAwareModule(m) return m }
java/boot_image_test.go +9 −0 Original line number Diff line number Diff line Loading @@ -29,3 +29,12 @@ func TestUnknownBootImage(t *testing.T) { } `) } func TestUnknownPrebuiltBootImage(t *testing.T) { testJavaError(t, "image_name: Unknown image name \\\"unknown\\\", expected one of art, boot", ` prebuilt_boot_image { name: "unknown-boot-image", image_name: "unknown", } `) }
sdk/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ bootstrap_go_package { "update.go", ], testSrcs: [ "boot_image_sdk_test.go", "bp_test.go", "cc_sdk_test.go", "exports_test.go", Loading
sdk/boot_image_sdk_test.go 0 → 100644 +63 −0 Original line number Diff line number Diff line // Copyright (C) 2021 The Android Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package sdk import "testing" func TestSnapshotWithBootImage(t *testing.T) { result := testSdkWithJava(t, ` sdk { name: "mysdk", boot_images: ["mybootimage"], } boot_image { name: "mybootimage", image_name: "art", } `) result.CheckSnapshot("mysdk", "", checkUnversionedAndroidBpContents(` // This is auto-generated. DO NOT EDIT. prebuilt_boot_image { name: "mybootimage", prefer: false, visibility: ["//visibility:public"], apex_available: ["//apex_available:platform"], image_name: "art", } `), checkVersionedAndroidBpContents(` // This is auto-generated. DO NOT EDIT. prebuilt_boot_image { name: "mysdk_mybootimage@current", sdk_member_name: "mybootimage", visibility: ["//visibility:public"], apex_available: ["//apex_available:platform"], image_name: "art", } sdk_snapshot { name: "mysdk@current", visibility: ["//visibility:public"], boot_images: ["mysdk_mybootimage@current"], } `), checkAllCopyRules(""), ) }