Generate android_device module from filesystem_creator
Allows android_device module to be auto-generated, and replace the
product.mk file in the long run. The module depends on the
auto-generated partition filesystem modules.
Test: m nothing --no-skip-soong-tests
Bug: 372486444
Change-Id: Ice5c70e1f33b087248c525a1508380b51e24c5cf
diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go
index eb4f318..5014a10 100644
--- a/fsgen/filesystem_creator.go
+++ b/fsgen/filesystem_creator.go
@@ -66,14 +66,35 @@
f.properties.Unsupported_partition_types = append(f.properties.Unsupported_partition_types, partitionType)
}
}
+ f.createDeviceModule(ctx)
}
-func (f *filesystemCreator) generatedModuleNameForPartition(cfg android.Config, partitionType string) string {
+func (f *filesystemCreator) generatedModuleName(cfg android.Config, suffix string) string {
prefix := "soong"
if cfg.HasDeviceProduct() {
prefix = cfg.DeviceProduct()
}
- return fmt.Sprintf("%s_generated_%s_image", prefix, partitionType)
+ return fmt.Sprintf("%s_generated_%s", prefix, suffix)
+}
+
+func (f *filesystemCreator) generatedModuleNameForPartition(cfg android.Config, partitionType string) string {
+ return f.generatedModuleName(cfg, fmt.Sprintf("%s_image", partitionType))
+}
+
+func (f *filesystemCreator) createDeviceModule(ctx android.LoadHookContext) {
+ baseProps := &struct {
+ Name *string
+ }{
+ Name: proptools.StringPtr(f.generatedModuleName(ctx.Config(), "device")),
+ }
+
+ // Currently, only the system partition module is created.
+ partitionProps := &filesystem.PartitionNameProperties{}
+ if android.InList("system", f.properties.Generated_partition_types) {
+ partitionProps.System_partition_name = proptools.StringPtr(f.generatedModuleNameForPartition(ctx.Config(), "system"))
+ }
+
+ ctx.CreateModule(filesystem.AndroidDeviceFactory, baseProps, partitionProps)
}
// Creates a soong module to build the given partition. Returns false if we can't support building