summaryrefslogtreecommitdiff
path: root/filesystem/filesystem.go
diff options
context:
space:
mode:
Diffstat (limited to 'filesystem/filesystem.go')
-rw-r--r--filesystem/filesystem.go70
1 files changed, 46 insertions, 24 deletions
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index ad19cc6e0..68cbee95f 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -20,6 +20,7 @@ import (
"io"
"path/filepath"
"slices"
+ "sort"
"strconv"
"strings"
@@ -378,6 +379,13 @@ type FilesystemInfo struct {
// Name of the module that produced this FilesystemInfo origionally. (though it may be
// re-exported by super images or boot images)
ModuleName string
+ // The property file generated by this module and passed to build_image.
+ // It's exported here so that system_other can reuse system's property file.
+ BuildImagePropFile android.Path
+ // Paths to all the tools referenced inside of the build image property file.
+ BuildImagePropFileDeps android.Paths
+ // Packaging specs to be installed on the system_other image, for the initial boot's dexpreopt.
+ SpecsForSystemOther map[string]android.PackagingSpec
}
var FilesystemProvider = blueprint.NewProvider[FilesystemInfo]()
@@ -484,9 +492,11 @@ func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) {
var mapFile android.Path
var outputHermetic android.Path
+ var buildImagePropFile android.Path
+ var buildImagePropFileDeps android.Paths
switch f.fsType(ctx) {
case ext4Type, erofsType, f2fsType:
- f.output, outputHermetic = f.buildImageUsingBuildImage(ctx, builder, rootDir, rebasedDir)
+ f.output, outputHermetic, buildImagePropFile, buildImagePropFileDeps = f.buildImageUsingBuildImage(ctx, builder, rootDir, rebasedDir)
mapFile = f.getMapFile(ctx)
case compressedCpioType:
f.output = f.buildCpioImage(ctx, builder, rootDir, true)
@@ -508,17 +518,16 @@ func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) {
android.WriteFileRule(ctx, fileListFile, f.installedFilesList())
fsInfo := FilesystemInfo{
- Output: f.output,
- FileListFile: fileListFile,
- RootDir: rootDir,
- RebasedDir: rebasedDir,
- ModuleName: ctx.ModuleName(),
- }
- if mapFile != nil {
- fsInfo.MapFile = mapFile
- }
- if outputHermetic != nil {
- fsInfo.OutputHermetic = outputHermetic
+ Output: f.output,
+ OutputHermetic: outputHermetic,
+ FileListFile: fileListFile,
+ RootDir: rootDir,
+ RebasedDir: rebasedDir,
+ MapFile: mapFile,
+ ModuleName: ctx.ModuleName(),
+ BuildImagePropFile: buildImagePropFile,
+ BuildImagePropFileDeps: buildImagePropFileDeps,
+ SpecsForSystemOther: f.systemOtherFiles(ctx),
}
android.SetProvider(ctx, FilesystemProvider, fsInfo)
@@ -670,7 +679,7 @@ func (f *filesystem) buildImageUsingBuildImage(
builder *android.RuleBuilder,
rootDir android.OutputPath,
rebasedDir android.OutputPath,
-) (android.Path, android.Path) {
+) (android.Path, android.Path, android.Path, android.Paths) {
// run host_init_verifier
// Ideally we should have a concept of pluggable linters that verify the generated image.
// While such concept is not implement this will do.
@@ -701,7 +710,9 @@ func (f *filesystem) buildImageUsingBuildImage(
// Add an additional cmd to create a hermetic img file. This will contain pinned timestamps e.g.
propFilePinnedTimestamp := android.PathForModuleOut(ctx, "for_target_files", "prop")
- builder.Command().Textf("cat").Input(propFile).Flag(">").Output(propFilePinnedTimestamp).Textf(" && echo use_fixed_timestamp=true >> %s", propFilePinnedTimestamp)
+ builder.Command().Textf("cat").Input(propFile).Flag(">").Output(propFilePinnedTimestamp).
+ Textf(" && echo use_fixed_timestamp=true >> %s", propFilePinnedTimestamp).
+ Textf(" && echo block_list=%s >> %s", f.getMapFile(ctx).String(), propFilePinnedTimestamp) // mapfile will be an implicit output
outputHermetic := android.PathForModuleOut(ctx, "for_target_files", f.installFileName())
builder.Command().
@@ -721,7 +732,7 @@ func (f *filesystem) buildImageUsingBuildImage(
// rootDir is not deleted. Might be useful for quick inspection.
builder.Build("build_filesystem_image", fmt.Sprintf("Creating filesystem %s", f.BaseModuleName()))
- return output, outputHermetic
+ return output, outputHermetic, propFile, toolDeps
}
func (f *filesystem) buildFileContexts(ctx android.ModuleContext) android.Path {
@@ -736,12 +747,9 @@ func (f *filesystem) buildFileContexts(ctx android.ModuleContext) android.Path {
func (f *filesystem) buildPropFile(ctx android.ModuleContext) (android.Path, android.Paths) {
var deps android.Paths
- var propFileString strings.Builder
+ var lines []string
addStr := func(name string, value string) {
- propFileString.WriteString(name)
- propFileString.WriteRune('=')
- propFileString.WriteString(value)
- propFileString.WriteRune('\n')
+ lines = append(lines, fmt.Sprintf("%s=%s", name, value))
}
addPath := func(name string, path android.Path) {
addStr(name, path.String())
@@ -761,7 +769,6 @@ func (f *filesystem) buildPropFile(ctx android.ModuleContext) (android.Path, and
}
panic(fmt.Errorf("unsupported fs type %v", t))
}
- addStr("block_list", f.getMapFile(ctx).String()) // This will be an implicit output
addStr("fs_type", fsTypeStr(f.fsType(ctx)))
addStr("mount_point", proptools.StringDefault(f.properties.Mount_point, "/"))
@@ -871,8 +878,10 @@ func (f *filesystem) buildPropFile(ctx android.ModuleContext) (android.Path, and
addStr("needs_compress", "1")
}
+ sort.Strings(lines)
+
propFilePreProcessing := android.PathForModuleOut(ctx, "prop_pre_processing")
- android.WriteFileRuleVerbatim(ctx, propFilePreProcessing, propFileString.String())
+ android.WriteFileRule(ctx, propFilePreProcessing, strings.Join(lines, "\n"))
propFile := android.PathForModuleOut(ctx, "prop")
ctx.Build(pctx, android.BuildParams{
Rule: textFileProcessorRule,
@@ -1065,8 +1074,21 @@ func (f *filesystem) SignedOutputPath() android.Path {
// Note that "apex" module installs its contents to "apex"(fake partition) as well
// for symbol lookup by imitating "activated" paths.
func (f *filesystem) gatherFilteredPackagingSpecs(ctx android.ModuleContext) map[string]android.PackagingSpec {
- specs := f.PackagingBase.GatherPackagingSpecsWithFilterAndModifier(ctx, f.filesystemBuilder.FilterPackagingSpec, f.filesystemBuilder.ModifyPackagingSpec)
- return specs
+ return f.PackagingBase.GatherPackagingSpecsWithFilterAndModifier(ctx, f.filesystemBuilder.FilterPackagingSpec, f.filesystemBuilder.ModifyPackagingSpec)
+}
+
+// Dexpreopt files are installed to system_other. Collect the packaingSpecs for the dexpreopt files
+// from this partition to export to the system_other partition later.
+func (f *filesystem) systemOtherFiles(ctx android.ModuleContext) map[string]android.PackagingSpec {
+ filter := func(spec android.PackagingSpec) bool {
+ // For some reason system_other packaging specs don't set the partition field.
+ return strings.HasPrefix(spec.RelPathInPackage(), "system_other/")
+ }
+ modifier := func(spec *android.PackagingSpec) {
+ spec.SetRelPathInPackage(strings.TrimPrefix(spec.RelPathInPackage(), "system_other/"))
+ spec.SetPartition("system_other")
+ }
+ return f.PackagingBase.GatherPackagingSpecsWithFilterAndModifier(ctx, filter, modifier)
}
func sha1sum(values []string) string {