Build ramdisk with soong
This is the first step to build the ramdisk, it still has some diffs
with with the make-generated ramdisk though.
Bug: 378146476
Test: m soong_generated_ramdisk_filesystem_test
Change-Id: I767ea9d09e4d6413c2ec5af3120595e2001c9bb7
diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go
index d9b2973..660328f 100644
--- a/fsgen/filesystem_creator.go
+++ b/fsgen/filesystem_creator.go
@@ -421,13 +421,20 @@
fsProps := &filesystem.FilesystemProperties{}
partitionVars := ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse
- specificPartitionVars := partitionVars.PartitionQualifiedVariables[partitionType]
-
- // BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE
- fsType := specificPartitionVars.BoardFileSystemType
+ var specificPartitionVars android.PartitionQualifiedVariablesType
+ var boardAvbEnable bool
+ var fsType string
+ if strings.Contains(partitionType, "ramdisk") {
+ fsType = "compressed_cpio"
+ } else {
+ specificPartitionVars = partitionVars.PartitionQualifiedVariables[partitionType]
+ boardAvbEnable = partitionVars.BoardAvbEnable
+ fsType = specificPartitionVars.BoardFileSystemType
+ }
if fsType == "" {
fsType = "ext4" //default
}
+
fsProps.Type = proptools.StringPtr(fsType)
if filesystem.GetFsTypeFromString(ctx, *fsProps.Type).IsUnknown() {
// Currently the android_filesystem module type only supports a handful of FS types like ext4, erofs
@@ -439,7 +446,7 @@
fsProps.Unchecked_module = proptools.BoolPtr(true)
// BOARD_AVB_ENABLE
- fsProps.Use_avb = proptools.BoolPtr(partitionVars.BoardAvbEnable)
+ fsProps.Use_avb = proptools.BoolPtr(boardAvbEnable)
// BOARD_AVB_KEY_PATH
fsProps.Avb_private_key = proptools.StringPtr(specificPartitionVars.BoardAvbKeyPath)
// BOARD_AVB_ALGORITHM
diff --git a/fsgen/fsgen_mutators.go b/fsgen/fsgen_mutators.go
index 4440c63..b6ba6c4 100644
--- a/fsgen/fsgen_mutators.go
+++ b/fsgen/fsgen_mutators.go
@@ -80,7 +80,7 @@
}
func generatedPartitions(ctx android.LoadHookContext) []string {
- generatedPartitions := []string{"system"}
+ generatedPartitions := []string{"system", "ramdisk"}
if ctx.DeviceConfig().SystemExtPath() == "system_ext" {
generatedPartitions = append(generatedPartitions, "system_ext")
}
@@ -171,6 +171,7 @@
"fs_config_files_odm_dlkm": defaultDepCandidateProps(ctx.Config()),
"odm_dlkm-build.prop": defaultDepCandidateProps(ctx.Config()),
},
+ "ramdisk": {},
},
fsDepsMutex: sync.Mutex{},
moduleToInstallationProps: map[string]installationProperties{},
@@ -205,29 +206,31 @@
}
func collectDepsMutator(mctx android.BottomUpMutatorContext) {
+ m := mctx.Module()
+ if m.Target().Os.Class != android.Device {
+ return
+ }
fsGenState := mctx.Config().Get(fsGenStateOnceKey).(*FsGenState)
- m := mctx.Module()
- if m.Target().Os.Class == android.Device && slices.Contains(fsGenState.depCandidates, mctx.ModuleName()) {
+ fsGenState.fsDepsMutex.Lock()
+ defer fsGenState.fsDepsMutex.Unlock()
+
+ if slices.Contains(fsGenState.depCandidates, mctx.ModuleName()) {
installPartition := m.PartitionTag(mctx.DeviceConfig())
- fsGenState.fsDepsMutex.Lock()
// Only add the module as dependency when:
// - its enabled
// - its namespace is included in PRODUCT_SOONG_NAMESPACES
if m.Enabled(mctx) && m.ExportedToMake() {
appendDepIfAppropriate(mctx, fsGenState.fsDeps[installPartition], installPartition)
}
- fsGenState.fsDepsMutex.Unlock()
}
// store the map of module to (required,overrides) even if the module is not in PRODUCT_PACKAGES.
// the module might be installed transitively.
- if m.Target().Os.Class == android.Device && m.Enabled(mctx) && m.ExportedToMake() {
- fsGenState.fsDepsMutex.Lock()
+ if m.Enabled(mctx) && m.ExportedToMake() {
fsGenState.moduleToInstallationProps[m.Name()] = installationProperties{
Required: m.RequiredModuleNames(mctx),
Overrides: m.Overrides(),
}
- fsGenState.fsDepsMutex.Unlock()
}
}
diff --git a/fsgen/vbmeta_partitions.go b/fsgen/vbmeta_partitions.go
index 280e405..f7b4638 100644
--- a/fsgen/vbmeta_partitions.go
+++ b/fsgen/vbmeta_partitions.go
@@ -156,6 +156,10 @@
// Already handled by a chained vbmeta partition
continue
}
+ if partitionType == "ramdisk" {
+ // ramdisk is never signed with avb information
+ continue
+ }
partitionModules = append(partitionModules, generatedModuleNameForPartition(ctx.Config(), partitionType))
}