diff options
author | 2025-02-12 12:14:21 -0800 | |
---|---|---|
committer | 2025-02-12 12:14:21 -0800 | |
commit | 5044707143ed635ac4ed17576657a0df9cc9db34 (patch) | |
tree | 6bbd80cd2329ba5203901bfd5fcde8b6a0f8bc50 /filesystem/filesystem.go | |
parent | b8f248dfee89ebc047bc031eb969303c3793f2f9 (diff) | |
parent | f67b7dea4af97e8d46aded5d75989147de37b9d0 (diff) |
Merge "Dist installed-files.* in soong only build" into main
Diffstat (limited to 'filesystem/filesystem.go')
-rw-r--r-- | filesystem/filesystem.go | 70 |
1 files changed, 65 insertions, 5 deletions
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index 3f774331d..84daab037 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -36,6 +36,7 @@ import ( func init() { registerBuildComponents(android.InitRegistrationContext) registerMutators(android.InitRegistrationContext) + pctx.HostBinToolVariable("fileslist", "fileslist") } func registerBuildComponents(ctx android.RegistrationContext) { @@ -54,11 +55,24 @@ func registerMutators(ctx android.RegistrationContext) { }) } -// Remember to add referenced files to implicits! -var textFileProcessorRule = pctx.AndroidStaticRule("text_file_processing", blueprint.RuleParams{ - Command: "build/soong/scripts/text_file_processor.py $in $out", - CommandDeps: []string{"build/soong/scripts/text_file_processor.py"}, -}) +var ( + // Remember to add referenced files to implicits! + textFileProcessorRule = pctx.AndroidStaticRule("text_file_processing", blueprint.RuleParams{ + Command: "build/soong/scripts/text_file_processor.py $in $out", + CommandDeps: []string{"build/soong/scripts/text_file_processor.py"}, + }) + + // Remember to add the output image file as an implicit dependency! + installedFilesJsonRule = pctx.AndroidStaticRule("installed_files_json", blueprint.RuleParams{ + Command: `${fileslist} ${rootDir} > ${out}`, + CommandDeps: []string{"${fileslist}"}, + }, "rootDir") + + installedFilesTxtRule = pctx.AndroidStaticRule("installed_files_txt", blueprint.RuleParams{ + Command: `build/make/tools/fileslist_util.py -c ${in} > ${out}`, + CommandDeps: []string{"build/make/tools/fileslist_util.py"}, + }) +) type filesystem struct { android.ModuleBase @@ -358,6 +372,11 @@ func (fs fsType) IsUnknown() bool { return fs == unknown } +type InstalledFilesStruct struct { + Txt android.Path + Json android.Path +} + type FilesystemInfo struct { // The built filesystem image Output android.Path @@ -391,6 +410,9 @@ type FilesystemInfo struct { SpecsForSystemOther map[string]android.PackagingSpec FullInstallPaths []FullInstallPathInfo + + // Installed files list + InstalledFiles InstalledFilesStruct } // FullInstallPathInfo contains information about the "full install" paths of all the files @@ -498,6 +520,34 @@ func (f *filesystem) ModifyPackagingSpec(ps *android.PackagingSpec) { } } +func buildInstalledFiles(ctx android.ModuleContext, partition string, rootDir android.Path, image android.Path) (txt android.ModuleOutPath, json android.ModuleOutPath) { + fileName := "installed-files" + if len(partition) > 0 { + fileName += fmt.Sprintf("-%s", partition) + } + txt = android.PathForModuleOut(ctx, fmt.Sprintf("%s.txt", fileName)) + json = android.PathForModuleOut(ctx, fmt.Sprintf("%s.json", fileName)) + + ctx.Build(pctx, android.BuildParams{ + Rule: installedFilesJsonRule, + Implicit: image, + Output: json, + Description: "Installed file list json", + Args: map[string]string{ + "rootDir": rootDir.String(), + }, + }) + + ctx.Build(pctx, android.BuildParams{ + Rule: installedFilesTxtRule, + Input: json, + Output: txt, + Description: "Installed file list txt", + }) + + return txt, json +} + var pctx = android.NewPackageContext("android/soong/filesystem") func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) { @@ -578,6 +628,12 @@ func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) { fileListFile := android.PathForModuleOut(ctx, "fileList") android.WriteFileRule(ctx, fileListFile, f.installedFilesList()) + partitionName := f.partitionName() + if partitionName == "system" { + partitionName = "" + } + installedFileTxt, installedFileJson := buildInstalledFiles(ctx, partitionName, rootDir, f.output) + fsInfo := FilesystemInfo{ Output: f.output, OutputHermetic: outputHermetic, @@ -590,6 +646,10 @@ func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) { BuildImagePropFileDeps: buildImagePropFileDeps, SpecsForSystemOther: f.systemOtherFiles(ctx), FullInstallPaths: fullInstallPaths, + InstalledFiles: InstalledFilesStruct{ + Txt: installedFileTxt, + Json: installedFileJson, + }, } android.SetProvider(ctx, FilesystemProvider, fsInfo) |