summaryrefslogtreecommitdiff
path: root/filesystem/filesystem.go
diff options
context:
space:
mode:
Diffstat (limited to 'filesystem/filesystem.go')
-rw-r--r--filesystem/filesystem.go69
1 files changed, 62 insertions, 7 deletions
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index 7ffdf69a9..5845d5931 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -155,6 +155,11 @@ type FilesystemProperties struct {
// Directories to be created under root. e.g. /dev, /proc, etc.
Dirs proptools.Configurable[[]string]
+ // List of filesystem modules to include in creating the partition. The root directory of
+ // the provided filesystem modules are included in creating the partition.
+ // This is only supported for cpio and compressed cpio filesystem types.
+ Include_files_of []string
+
// Symbolic links to be created under root with "ln -sf <target> <name>".
Symlinks []SymlinkDefinition
@@ -286,6 +291,8 @@ type interPartitionDepTag struct {
var interPartitionDependencyTag = interPartitionDepTag{}
+var interPartitionInstallDependencyTag = interPartitionDepTag{}
+
var _ android.ExcludeFromVisibilityEnforcementTag = (*depTagWithVisibilityEnforcementBypass)(nil)
func (t depTagWithVisibilityEnforcementBypass) ExcludeFromVisibilityEnforcement() {}
@@ -317,6 +324,9 @@ func (f *filesystem) DepsMutator(ctx android.BottomUpMutatorContext) {
for _, partition := range f.properties.Import_aconfig_flags_from {
ctx.AddDependency(ctx.Module(), importAconfigDependencyTag, partition)
}
+ for _, partition := range f.properties.Include_files_of {
+ ctx.AddDependency(ctx.Module(), interPartitionInstallDependencyTag, partition)
+ }
}
type fsType int
@@ -335,8 +345,14 @@ func (fs fsType) IsUnknown() bool {
}
type FilesystemInfo struct {
+ // The built filesystem image
+ Output android.Path
// A text file containing the list of paths installed on the partition.
FileListFile android.Path
+ // The root staging directory used to build the output filesystem. If consuming this, make sure
+ // to add a dependency on the Output file, as you cannot add dependencies on directories
+ // in ninja.
+ RootDir android.Path
}
var FilesystemProvider = blueprint.NewProvider[FilesystemInfo]()
@@ -410,13 +426,19 @@ func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if f.filesystemBuilder.ShouldUseVintfFragmentModuleOnly() {
f.validateVintfFragments(ctx)
}
+
+ if len(f.properties.Include_files_of) > 0 && !android.InList(f.fsType(ctx), []fsType{compressedCpioType, cpioType}) {
+ ctx.PropertyErrorf("include_files_of", "include_files_of is only supported for cpio and compressed cpio filesystem types.")
+ }
+
+ var rootDir android.OutputPath
switch f.fsType(ctx) {
case ext4Type, erofsType, f2fsType:
- f.output = f.buildImageUsingBuildImage(ctx)
+ f.output, rootDir = f.buildImageUsingBuildImage(ctx)
case compressedCpioType:
- f.output = f.buildCpioImage(ctx, true)
+ f.output, rootDir = f.buildCpioImage(ctx, true)
case cpioType:
- f.output = f.buildCpioImage(ctx, false)
+ f.output, rootDir = f.buildCpioImage(ctx, false)
default:
return
}
@@ -425,11 +447,17 @@ func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) {
ctx.InstallFile(f.installDir, f.installFileName(), f.output)
ctx.SetOutputFiles([]android.Path{f.output}, "")
+ if f.partitionName() == "recovery" {
+ rootDir = rootDir.Join(ctx, "root")
+ }
+
fileListFile := android.PathForModuleOut(ctx, "fileList")
android.WriteFileRule(ctx, fileListFile, f.installedFilesList())
android.SetProvider(ctx, FilesystemProvider, FilesystemInfo{
+ Output: f.output,
FileListFile: fileListFile,
+ RootDir: rootDir,
})
f.fileListFile = fileListFile
@@ -537,6 +565,12 @@ func (f *filesystem) buildNonDepsFiles(ctx android.ModuleContext, builder *andro
builder.Command().Text("ln -sf").Text(proptools.ShellEscape(target)).Text(dst.String())
f.appendToEntry(ctx, dst)
}
+
+ // https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/Makefile;l=2835;drc=b186569ef00ff2f2a1fab28aedc75ebc32bcd67b
+ if f.partitionName() == "recovery" {
+ builder.Command().Text("mkdir -p").Text(rootDir.Join(ctx, "root/linkerconfig").String())
+ builder.Command().Text("touch").Text(rootDir.Join(ctx, "root/linkerconfig/ld.config.txt").String())
+ }
}
func (f *filesystem) copyPackagingSpecs(ctx android.ModuleContext, builder *android.RuleBuilder, specs map[string]android.PackagingSpec, rootDir, rebasedDir android.WritablePath) []string {
@@ -570,7 +604,7 @@ func (f *filesystem) rootDirString() string {
return f.partitionName()
}
-func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) android.Path {
+func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) (android.Path, android.OutputPath) {
rootDir := android.PathForModuleOut(ctx, f.rootDirString()).OutputPath
rebasedDir := rootDir
if f.properties.Base_dir != nil {
@@ -621,7 +655,7 @@ func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) androi
// rootDir is not deleted. Might be useful for quick inspection.
builder.Build("build_filesystem_image", fmt.Sprintf("Creating filesystem %s", f.BaseModuleName()))
- return output
+ return output, rootDir
}
func (f *filesystem) buildFileContexts(ctx android.ModuleContext) android.Path {
@@ -783,7 +817,20 @@ func (f *filesystem) checkFsTypePropertyError(ctx android.ModuleContext, t fsTyp
}
}
-func (f *filesystem) buildCpioImage(ctx android.ModuleContext, compressed bool) android.Path {
+func includeFilesRootDir(ctx android.ModuleContext) (rootDirs android.Paths, partitions android.Paths) {
+ ctx.VisitDirectDepsWithTag(interPartitionInstallDependencyTag, func(m android.Module) {
+ if fsProvider, ok := android.OtherModuleProvider(ctx, m, FilesystemProvider); ok {
+ rootDirs = append(rootDirs, fsProvider.RootDir)
+ partitions = append(partitions, fsProvider.Output)
+ } else {
+ ctx.PropertyErrorf("include_files_of", "only filesystem modules can be listed in "+
+ "include_files_of but %s is not a filesystem module", m.Name())
+ }
+ })
+ return rootDirs, partitions
+}
+
+func (f *filesystem) buildCpioImage(ctx android.ModuleContext, compressed bool) (android.Path, android.OutputPath) {
if proptools.Bool(f.properties.Use_avb) {
ctx.PropertyErrorf("use_avb", "signing compresed cpio image using avbtool is not supported."+
"Consider adding this to bootimg module and signing the entire boot image.")
@@ -815,10 +862,18 @@ func (f *filesystem) buildCpioImage(ctx android.ModuleContext, compressed bool)
f.filesystemBuilder.BuildLinkerConfigFile(ctx, builder, rebasedDir)
f.copyFilesToProductOut(ctx, builder, rebasedDir)
+ rootDirs, partitions := includeFilesRootDir(ctx)
+
output := android.PathForModuleOut(ctx, f.installFileName())
cmd := builder.Command().
BuiltTool("mkbootfs").
Text(rootDir.String()) // input directory
+
+ for i := range len(rootDirs) {
+ cmd.Text(rootDirs[i].String())
+ }
+ cmd.Implicits(partitions)
+
if nodeList := f.properties.Dev_nodes_description_file; nodeList != nil {
cmd.FlagWithInput("-n ", android.PathForModuleSrc(ctx, proptools.String(nodeList)))
}
@@ -836,7 +891,7 @@ func (f *filesystem) buildCpioImage(ctx android.ModuleContext, compressed bool)
// rootDir is not deleted. Might be useful for quick inspection.
builder.Build("build_cpio_image", fmt.Sprintf("Creating filesystem %s", f.BaseModuleName()))
- return output
+ return output, rootDir
}
var validPartitions = []string{