From e06dd11bdc158417732c6bd14b0ef3c8790b7bd2 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Wed, 5 Mar 2025 01:29:04 +0000 Subject: Fix incrementality issues for root_filesystem_config.txt This file is generated by running fs_config on `out/soong/.intermediates/.../ROOT` directory assembled for target_files.zip, but this was not declared as implicit input. This was causing incorrect results for clean builds. To fix this, a duplicate rule is created to assemeble the ROOT/ directory in a separate intermediates. An output timestamp file is created for the aforementioned directory, and this timestamp file will be an implicit input for the fs_config call. Test: rm -rf out/soong/.intermediates/build/soong/fsgen && # build target_files.zip Change-Id: Id3f942c285d95148eba78c6010b42ca061b69072 --- filesystem/android_device.go | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'filesystem/android_device.go') diff --git a/filesystem/android_device.go b/filesystem/android_device.go index 5911a4e68..2807446c3 100644 --- a/filesystem/android_device.go +++ b/filesystem/android_device.go @@ -106,12 +106,14 @@ type androidDevice struct { allImagesZip android.Path - proguardDictZip android.Path - proguardDictMapping android.Path - proguardUsageZip android.Path - kernelConfig android.Path - kernelVersion android.Path - miscInfo android.Path + proguardDictZip android.Path + proguardDictMapping android.Path + proguardUsageZip android.Path + kernelConfig android.Path + kernelVersion android.Path + miscInfo android.Path + rootDirForFsConfig string + rootDirForFsConfigTimestamp android.Path } func AndroidDeviceFactory() android.Module { @@ -472,6 +474,17 @@ func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext, allInstal if toCopy.destSubdir == "SYSTEM" { // Create the ROOT partition in target_files.zip builder.Command().Textf("rsync --links --exclude=system/* %s/ -r %s/ROOT", toCopy.fsInfo.RootDir, targetFilesDir.String()) + // Add a duplicate rule to assemble the ROOT/ directory in separate intermediates. + // The output timestamp will be an input to a separate fs_config call. + a.rootDirForFsConfig = android.PathForModuleOut(ctx, "root_dir_for_fs_config").String() + rootDirBuilder := android.NewRuleBuilder(pctx, ctx) + rootDirForFsConfigTimestamp := android.PathForModuleOut(ctx, "root_dir_for_fs_config.timestamp") + rootDirBuilder.Command().Textf("rsync --links --exclude=system/* %s/ -r %s", toCopy.fsInfo.RootDir, a.rootDirForFsConfig). + Implicit(toCopy.fsInfo.Output). + Text("&& touch"). + Output(rootDirForFsConfigTimestamp) + rootDirBuilder.Build("assemble_root_dir_for_fs_config", "Assemble ROOT/ for fs_config") + a.rootDirForFsConfigTimestamp = rootDirForFsConfigTimestamp } } // Copy cmdline, kernel etc. files of boot images @@ -610,11 +623,11 @@ func (a *androidDevice) copyMetadataToTargetZip(ctx android.ModuleContext, build } if partition == "system" { // Create root_filesystem_config from the assembled ROOT/ intermediates directory - a.generateFilesystemConfigForTargetFiles(ctx, builder, targetFilesDir.String(), targetFilesDir.String()+"/ROOT", "root_filesystem_config.txt") + a.generateFilesystemConfigForTargetFiles(ctx, builder, a.rootDirForFsConfigTimestamp, targetFilesDir.String(), a.rootDirForFsConfig, "root_filesystem_config.txt") } if partition == "vendor_ramdisk" { // Create vendor_boot_filesystem_config from the assembled VENDOR_BOOT/RAMDISK intermediates directory - a.generateFilesystemConfigForTargetFiles(ctx, builder, targetFilesDir.String(), targetFilesDir.String()+"/VENDOR_BOOT/RAMDISK", "vendor_boot_filesystem_config.txt") + a.generateFilesystemConfigForTargetFiles(ctx, builder, nil, targetFilesDir.String(), targetFilesDir.String()+"/VENDOR_BOOT/RAMDISK", "vendor_boot_filesystem_config.txt") } } // Copy ramdisk_node_list @@ -727,11 +740,12 @@ type ApexKeyPathInfo struct { var ApexKeyPathInfoProvider = blueprint.NewProvider[ApexKeyPathInfo]() -func (a *androidDevice) generateFilesystemConfigForTargetFiles(ctx android.ModuleContext, builder *android.RuleBuilder, targetFilesDir, stagingDir, filename string) { +func (a *androidDevice) generateFilesystemConfigForTargetFiles(ctx android.ModuleContext, builder *android.RuleBuilder, stagingDirTimestamp android.Path, targetFilesDir, stagingDir, filename string) { fsConfigOut := android.PathForModuleOut(ctx, filename) ctx.Build(pctx, android.BuildParams{ - Rule: fsConfigRule, - Output: fsConfigOut, + Rule: fsConfigRule, + Implicit: stagingDirTimestamp, + Output: fsConfigOut, Args: map[string]string{ "rootDir": stagingDir, "prefix": "", -- cgit v1.2.3-59-g8ed1b