summaryrefslogtreecommitdiff
path: root/filesystem/filesystem.go
diff options
context:
space:
mode:
author Jihoon Kang <jihoonkang@google.com> 2025-02-12 01:01:09 +0000
committer Jihoon Kang <jihoonkang@google.com> 2025-02-12 18:42:36 +0000
commitf67b7dea4af97e8d46aded5d75989147de37b9d0 (patch)
treefef8952634bced51c8aef1f1f407e78991ff6cc3 /filesystem/filesystem.go
parent4b92926bd8c3171d0e0c9a15bf7e15cb2c03c0f8 (diff)
Dist installed-files.* in soong only build
Implementation details: - Define static rules for building installed-files.txt and installed-files.json - Avoided adding dependency on the root dir and added dependency on the output image file instead - Propagate the generated installed-files.* via filesystem info provider and generate the dist rule in the main android device Test: m droid dist --soong-only && ls -l out/dist Bug: 395162005 Bug: 394365683 Change-Id: I615b0374c557fd11c19fcd190232cab411e2d299
Diffstat (limited to 'filesystem/filesystem.go')
-rw-r--r--filesystem/filesystem.go70
1 files changed, 65 insertions, 5 deletions
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index 0ce31b293..21c0689a2 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) {
@@ -565,6 +615,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,
@@ -577,6 +633,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)