From 3be1716f397ab1777ba749f4f9891d3e6324bfd2 Mon Sep 17 00:00:00 2001 From: Jihoon Kang Date: Thu, 9 Jan 2025 20:51:54 +0000 Subject: Copy bootloader to PRODUCT_OUT Implementation details: - Import BOARD_PREBUILT_BOOTLOADER to Soong, and create a filegroup module - Introduce `bootloader` property in android_device - Introduce file copying (to PRODUCT_OUT) mechanism in android_device Test: m aosp_cf_x86_64_phone_generated_device --soong-only Bug: 388852084 Change-Id: I89a08590e39e771019e507b419fafae37bc4bb97 --- fsgen/filesystem_creator.go | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'fsgen/filesystem_creator.go') diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go index 41faf948a..0fcb22f9e 100644 --- a/fsgen/filesystem_creator.go +++ b/fsgen/filesystem_creator.go @@ -180,6 +180,26 @@ func generatedModuleNameForPartition(cfg android.Config, partitionType string) s return generatedModuleName(cfg, fmt.Sprintf("%s_image", partitionType)) } +func (f *filesystemCreator) createBootloaderFilegroup(ctx android.LoadHookContext) (string, bool) { + bootloaderPath := ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.PrebuiltBootloader + if len(bootloaderPath) == 0 { + return "", false + } + + bootloaderFilegroupName := generatedModuleName(ctx.Config(), "bootloader") + filegroupProps := &struct { + Name *string + Srcs []string + Visibility []string + }{ + Name: proptools.StringPtr(bootloaderFilegroupName), + Srcs: []string{bootloaderPath}, + Visibility: []string{"//visibility:public"}, + } + ctx.CreateModuleInDirectory(android.FileGroupFactory, ".", filegroupProps) + return bootloaderFilegroupName, true +} + func (f *filesystemCreator) createDeviceModule( ctx android.LoadHookContext, generatedPartitionTypes []string, @@ -234,7 +254,12 @@ func (f *filesystemCreator) createDeviceModule( } partitionProps.Vbmeta_partitions = vbmetaPartitions - ctx.CreateModule(filesystem.AndroidDeviceFactory, baseProps, partitionProps) + deviceProps := &filesystem.DeviceProperties{} + if bootloader, ok := f.createBootloaderFilegroup(ctx); ok { + deviceProps.Bootloader = proptools.StringPtr(":" + bootloader) + } + + ctx.CreateModule(filesystem.AndroidDeviceFactory, baseProps, partitionProps, deviceProps) } func partitionSpecificFsProps(ctx android.EarlyModuleContext, fsProps *filesystem.FilesystemProperties, partitionVars android.PartitionVariables, partitionType string) { -- cgit v1.2.3-59-g8ed1b