Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1c79cae authored by Jihoon Kang's avatar Jihoon Kang
Browse files

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
parent c55e6881
Loading
Loading
Loading
Loading
+23 −2
Original line number Diff line number Diff line
@@ -66,14 +66,35 @@ func (f *filesystemCreator) createInternalModules(ctx android.LoadHookContext) {
			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