diff options
author | 2024-10-11 01:18:41 +0000 | |
---|---|---|
committer | 2024-10-11 01:18:41 +0000 | |
commit | a893932e1e3f679b4394cb653b61d181bc5aeccc (patch) | |
tree | 6f18c6324eeccb7894c4bfbaf49d0c44ef7f9de6 /filesystem/filesystem.go | |
parent | 004074db579a9e1abf07fe4c45f35d4d5247cac0 (diff) | |
parent | c35d6fb14192ea72bae0177ae57a3a1d72384aca (diff) |
Merge "Add erofs support to Soong filesystem modules" into main
Diffstat (limited to 'filesystem/filesystem.go')
-rw-r--r-- | filesystem/filesystem.go | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index 9b3eae471..87c6381c0 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -92,7 +92,7 @@ type FilesystemProperties struct { // Name of the partition stored in vbmeta desc. Defaults to the name of this module. Partition_name *string - // Type of the filesystem. Currently, ext4, cpio, and compressed_cpio are supported. Default + // Type of the filesystem. Currently, ext4, erofs, cpio, and compressed_cpio are supported. Default // is ext4. Type *string @@ -143,6 +143,20 @@ type FilesystemProperties struct { // build modules, where we want to emit some not-yet-working filesystems and we don't want them // to be built. Unchecked_module *bool `blueprint:"mutated"` + + Erofs ErofsProperties +} + +// Additional properties required to generate erofs FS partitions. +type ErofsProperties struct { + // Compressor and Compression level passed to mkfs.erofs. e.g. (lz4hc,9) + // Please see external/erofs-utils/README for complete documentation. + Compressor *string + + // Used as --compress-hints for mkfs.erofs + Compress_hints *string `android:"path"` + + Sparse *bool } // android_filesystem packages a set of modules and their transitive dependencies into a filesystem @@ -178,6 +192,7 @@ type fsType int const ( ext4Type fsType = iota + erofsType compressedCpioType cpioType // uncompressed unknown @@ -195,6 +210,8 @@ func (f *filesystem) fsType(ctx android.ModuleContext) fsType { switch typeStr { case "ext4": return ext4Type + case "erofs": + return erofsType case "compressed_cpio": return compressedCpioType case "cpio": @@ -224,7 +241,7 @@ var pctx = android.NewPackageContext("android/soong/filesystem") func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) { validatePartitionType(ctx, f) switch f.fsType(ctx) { - case ext4Type: + case ext4Type, erofsType: f.output = f.buildImageUsingBuildImage(ctx) case compressedCpioType: f.output = f.buildCpioImage(ctx, true) @@ -437,6 +454,8 @@ func (f *filesystem) buildPropFile(ctx android.ModuleContext) (propFile android. // TODO(372522486): add more types like f2fs, erofs, etc. case ext4Type: return "ext4" + case erofsType: + return "erofs" } panic(fmt.Errorf("unsupported fs type %v", t)) } @@ -486,6 +505,24 @@ func (f *filesystem) buildPropFile(ctx android.ModuleContext) (propFile android. addStr("uuid", uuid) addStr("hash_seed", uuid) } + // Add erofs properties + if f.fsType(ctx) == erofsType { + if compressor := f.properties.Erofs.Compressor; compressor != nil { + addStr("erofs_default_compressor", proptools.String(compressor)) + } + if compressHints := f.properties.Erofs.Compress_hints; compressHints != nil { + addStr("erofs_default_compress_hints", android.PathForModuleSrc(ctx, *compressHints).String()) + } + if proptools.BoolDefault(f.properties.Erofs.Sparse, true) { + // https://source.corp.google.com/h/googleplex-android/platform/build/+/88b1c67239ca545b11580237242774b411f2fed9:core/Makefile;l=2292;bpv=1;bpt=0;drc=ea8f34bc1d6e63656b4ec32f2391e9d54b3ebb6b + addStr("erofs_sparse_flag", "-s") + } + } + // Raise an exception if the propfile contains erofs properties, but the fstype is not erofs + if fs := fsTypeStr(f.fsType(ctx)); fs != "erofs" && (f.properties.Erofs.Compressor != nil || f.properties.Erofs.Compress_hints != nil || f.properties.Erofs.Sparse != nil) { + ctx.PropertyErrorf("erofs", "erofs is non-empty, but FS type is %s\n. Please delete erofs properties if this partition should use %s\n", fs, fs) + } + propFile = android.PathForModuleOut(ctx, "prop").OutputPath android.WriteFileRuleVerbatim(ctx, propFile, propFileString.String()) return propFile, deps |