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

Commit c5717166 authored by Spandan Das's avatar Spandan Das
Browse files

Autogenerate a soong module to build odm.img

Test: With https://r.android.com/3326400, notice files are the only
diffs for AOSP CF odm.img
Bug: 376755916

Change-Id: I847f0dc8317d9693de39fed19aeac4e7f8a70152
parent b6d77bf6
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1549,6 +1549,10 @@ func (c *deviceConfig) OdmPath() string {
	return "odm"
}

func (c *deviceConfig) BuildingOdmImage() bool {
	return proptools.Bool(c.config.productVariables.BuildingOdmImage)
}

func (c *deviceConfig) ProductPath() string {
	if c.config.productVariables.ProductPath != nil {
		return *c.config.productVariables.ProductPath
+1 −0
Original line number Diff line number Diff line
@@ -341,6 +341,7 @@ type ProductVariables struct {
	VendorPath           *string `json:",omitempty"`
	BuildingVendorImage  *bool   `json:",omitempty"`
	OdmPath              *string `json:",omitempty"`
	BuildingOdmImage     *bool   `json:",omitempty"`
	ProductPath          *string `json:",omitempty"`
	BuildingProductImage *bool   `json:",omitempty"`
	SystemExtPath        *string `json:",omitempty"`
+3 −0
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@ type PartitionNameProperties struct {
	Product_partition_name *string
	// Name of the Vendor partition filesystem module
	Vendor_partition_name *string
	// Name of the Odm partition filesystem module
	Odm_partition_name *string
}

type androidDevice struct {
@@ -66,6 +68,7 @@ func (a *androidDevice) DepsMutator(ctx android.BottomUpMutatorContext) {
	addDependencyIfDefined(a.partitionProps.System_ext_partition_name)
	addDependencyIfDefined(a.partitionProps.Product_partition_name)
	addDependencyIfDefined(a.partitionProps.Vendor_partition_name)
	addDependencyIfDefined(a.partitionProps.Odm_partition_name)
}

func (a *androidDevice) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+22 −2
Original line number Diff line number Diff line
@@ -116,6 +116,9 @@ func createFsGenState(ctx android.LoadHookContext) *FsGenState {
		if ctx.DeviceConfig().BuildingProductImage() && ctx.DeviceConfig().ProductPath() == "product" {
			generatedPartitions = append(generatedPartitions, "product")
		}
		if ctx.DeviceConfig().BuildingOdmImage() && ctx.DeviceConfig().OdmPath() == "odm" {
			generatedPartitions = append(generatedPartitions, "odm")
		}

		return &FsGenState{
			depCandidates: candidates,
@@ -144,7 +147,12 @@ func createFsGenState(ctx android.LoadHookContext) *FsGenState {
					"fs_config_dirs_vendor":                                defaultDepCandidateProps(ctx.Config()),
					generatedModuleName(ctx.Config(), "vendor-build.prop"): defaultDepCandidateProps(ctx.Config()),
				},
				"odm":     newMultilibDeps(),
				"odm": &map[string]*depCandidateProps{
					// fs_config_* files are automatically installed for all products with odm partitions.
					// https://cs.android.com/android/_/android/platform/build/+/e4849e87ab660b59a6501b3928693db065ee873b:tools/fs_config/Android.mk;l=34;drc=8d6481b92c4b4e9b9f31a61545b6862090fcc14b;bpv=1;bpt=0
					"fs_config_files_odm": defaultDepCandidateProps(ctx.Config()),
					"fs_config_dirs_odm":  defaultDepCandidateProps(ctx.Config()),
				},
				"product": newMultilibDeps(),
				"system_ext": &map[string]*depCandidateProps{
					// VNDK apexes are automatically included.
@@ -418,6 +426,9 @@ func (f *filesystemCreator) createDeviceModule(ctx android.LoadHookContext) {
	if android.InList("product", f.properties.Generated_partition_types) {
		partitionProps.Product_partition_name = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "product"))
	}
	if android.InList("odm", f.properties.Generated_partition_types) {
		partitionProps.Odm_partition_name = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "odm"))
	}

	ctx.CreateModule(filesystem.AndroidDeviceFactory, baseProps, partitionProps)
}
@@ -461,6 +472,15 @@ func partitionSpecificFsProps(fsProps *filesystem.FilesystemProperties, partitio
			},
		}
		fsProps.Base_dir = proptools.StringPtr("vendor")
	case "odm":
		fsProps.Symlinks = []filesystem.SymlinkDefinition{
			filesystem.SymlinkDefinition{
				Target: proptools.StringPtr("/odm_dlkm/lib/modules"),
				Name:   proptools.StringPtr("odm/lib/modules"),
			},
		}
		fsProps.Base_dir = proptools.StringPtr("odm")

	}
}

@@ -702,7 +722,7 @@ func generateBpContent(ctx android.EarlyModuleContext, partitionType string) str
	if !fsTypeSupported {
		return ""
	}
	if partitionType == "vendor" {
	if partitionType == "vendor" || partitionType == "odm" {
		return "" // TODO: Handle struct props
	}