diff options
author | 2025-03-04 19:04:28 -0800 | |
---|---|---|
committer | 2025-03-04 19:04:28 -0800 | |
commit | 191dee0933fee8451fb571120f888c1cca06bcd3 (patch) | |
tree | 8b6bc65d64a1c7711b83ce4e8c5e717f9a7001e2 /filesystem/android_device.go | |
parent | d183d9f24bf0e9b2b59330a6fa1346bbbef7b1ce (diff) | |
parent | 4100dd081e6abd41e12eb000fdbd3785ac5bc4c3 (diff) |
Merge changes I1bfc1a73,I52b9c9ff into main
* changes:
Generate apex_info.pb,care_map.pb,vbmeta_digest.txt in target_files
Create a partial implementation of $PRODUCT_OUT/misc_info.txt
Diffstat (limited to 'filesystem/android_device.go')
-rw-r--r-- | filesystem/android_device.go | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/filesystem/android_device.go b/filesystem/android_device.go index 005dc3439..5911a4e68 100644 --- a/filesystem/android_device.go +++ b/filesystem/android_device.go @@ -111,6 +111,7 @@ type androidDevice struct { proguardUsageZip android.Path kernelConfig android.Path kernelVersion android.Path + miscInfo android.Path } func AndroidDeviceFactory() android.Module { @@ -186,6 +187,7 @@ func (a *androidDevice) GenerateAndroidBuildActions(ctx android.ModuleContext) { allInstalledModules := a.allInstalledModules(ctx) a.kernelConfig, a.kernelVersion = a.extractKernelVersionAndConfigs(ctx) + a.miscInfo = a.addMiscInfo(ctx) a.buildTargetFilesZip(ctx, allInstalledModules) a.buildProguardZips(ctx, allInstalledModules) @@ -646,6 +648,12 @@ func (a *androidDevice) copyMetadataToTargetZip(ctx android.ModuleContext, build if a.kernelVersion != nil { builder.Command().Textf("cp").Input(a.kernelVersion).Textf(" %s/META/", targetFilesDir.String()) } + // misc_info.txt + if a.miscInfo != nil { + builder.Command().Textf("cp").Input(a.miscInfo).Textf(" %s/META/", targetFilesDir.String()) + } + // apex_info.pb, care_map.pb, vbmeta_digest.txt + a.addImgToTargetFiles(ctx, builder, targetFilesDir.String()) if a.partitionProps.Super_partition_name != nil { superPartition := ctx.GetDirectDepProxyWithTag(*a.partitionProps.Super_partition_name, superPartitionDepTag) @@ -660,6 +668,59 @@ func (a *androidDevice) copyMetadataToTargetZip(ctx android.ModuleContext, build } +// A partial implementation of make's $PRODUCT_OUT/misc_info.txt +// https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/Makefile;l=5894?q=misc_info.txt%20f:build%2Fmake%2Fcore%2FMakefile&ss=android%2Fplatform%2Fsuperproject%2Fmain +// This file is subsequently used by add_img_to_target_files to create additioanl metadata files like apex_info.pb +// TODO (b/399788119): Complete the migration of misc_info.txt +func (a *androidDevice) addMiscInfo(ctx android.ModuleContext) android.Path { + builder := android.NewRuleBuilder(pctx, ctx) + miscInfo := android.PathForModuleOut(ctx, "misc_info.txt") + builder.Command(). + Textf("rm -f %s", miscInfo). + Textf("&& echo recovery_api_version=%s >> %s", ctx.Config().VendorConfig("recovery").String("recovery_api_version"), miscInfo). + Textf("&& echo fstab_version=%s >> %s", ctx.Config().VendorConfig("recovery").String("recovery_fstab_version"), miscInfo). + ImplicitOutput(miscInfo) + + if a.partitionProps.Recovery_partition_name == nil { + builder.Command().Textf("echo no_recovery=true >> %s", miscInfo) + } + fsInfos := a.getFsInfos(ctx) + for _, partition := range android.SortedKeys(fsInfos) { + if fsInfos[partition].UseAvb { + builder.Command().Textf("echo 'avb_%s_hashtree_enable=true' >> %s", partition, miscInfo) + } + } + if len(a.partitionProps.Vbmeta_partitions) > 0 { + builder.Command(). + Textf("echo avb_enable=true >> %s", miscInfo). + Textf("&& echo avb_building_vbmeta_image=true >> %s", miscInfo). + Textf("&& echo avb_avbtool=avbtool >> %s", miscInfo) + } + if a.partitionProps.Boot_partition_name != nil { + builder.Command().Textf("echo boot_images=boot.img >> %s", miscInfo) + } + + builder.Build("misc_info", "Building misc_info") + + return miscInfo +} + +// addImgToTargetFiles invokes `add_img_to_target_files` and creates the following files in META/ +// - apex_info.pb +// - care_map.pb +// - vbmeta_digest.txt +func (a *androidDevice) addImgToTargetFiles(ctx android.ModuleContext, builder *android.RuleBuilder, targetFilesDir string) { + mkbootimg := ctx.Config().HostToolPath(ctx, "mkbootimg") + builder.Command(). + Textf("PATH=%s:$PATH", ctx.Config().HostToolDir()). + Textf("MKBOOTIMG=%s", mkbootimg). + Implicit(mkbootimg). + BuiltTool("add_img_to_target_files"). + Flag("-a -v -p"). + Flag(ctx.Config().HostToolDir()). + Text(targetFilesDir) +} + type ApexKeyPathInfo struct { ApexKeyPath android.Path } |