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

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

Make `runDepmod` behave more like `build-image-kernel-modules`

modules.load defaults to filenames of the .ko files listed in `srcs`.
This CL adds a property to skip this behvaior, thereby creating an empty
modules.load file. This will be used to build system_dlkm.img of some
products whose `BOARD_SYSTEM_KERNEL_MODULES_LOAD` is empty.

Bug: 377562851
Test: verified that /system_dlkm/lib/modules/modules.dep is empty for
both kati and soong for aosp cf
Test: verified that modules.* files are not created for odm_dlkm.img
built with soong (top of CL stack)

Change-Id: I8a0304fda1b5cc2ea0d1f36334877beca26f1d8a
parent 912d26bd
Loading
Loading
Loading
Loading
+19 −9
Original line number Diff line number Diff line
@@ -47,6 +47,10 @@ type prebuiltKernelModulesProperties struct {
	// List or filegroup of prebuilt kernel module files. Should have .ko suffix.
	Srcs []string `android:"path,arch_variant"`

	// If false, then srcs will not be included in modules.load.
	// This feature is used by system_dlkm
	Load_by_default *bool

	// Kernel version that these modules are for. Kernel modules are installed to
	// /lib/modules/<kernel_version> directory in the corresponding partition. Default is "".
	Kernel_version *string
@@ -83,7 +87,7 @@ func (pkm *prebuiltKernelModules) GenerateAndroidBuildActions(ctx android.Module
	}
	modules := android.PathsForModuleSrc(ctx, pkm.properties.Srcs)

	depmodOut := runDepmod(ctx, modules)
	depmodOut := pkm.runDepmod(ctx, modules, systemModules)
	strippedModules := stripDebugSymbols(ctx, modules)

	installDir := android.PathForModuleInstall(ctx, "lib", "modules")
@@ -137,7 +141,7 @@ type depmodOutputs struct {
	modulesAlias   android.OutputPath
}

func runDepmod(ctx android.ModuleContext, modules android.Paths) depmodOutputs {
func (pkm *prebuiltKernelModules) runDepmod(ctx android.ModuleContext, modules android.Paths, systemModules android.Paths) depmodOutputs {
	baseDir := android.PathForModuleOut(ctx, "depmod").OutputPath
	fakeVer := "0.0" // depmod demands this anyway
	modulesDir := baseDir.Join(ctx, "lib", "modules", fakeVer)
@@ -153,6 +157,11 @@ func runDepmod(ctx android.ModuleContext, modules android.Paths) depmodOutputs {

	// Enumerate modules to load
	modulesLoad := modulesDir.Join(ctx, "modules.load")
	// If Load_by_default is set to false explicitly, create an empty modules.load
	if pkm.properties.Load_by_default != nil && !*pkm.properties.Load_by_default {
		builder.Command().Text("rm").Flag("-rf").Text(modulesLoad.String())
		builder.Command().Text("touch").Output(modulesLoad)
	} else {
		var basenames []string
		for _, m := range modules {
			basenames = append(basenames, filepath.Base(m.String()))
@@ -161,6 +170,7 @@ func runDepmod(ctx android.ModuleContext, modules android.Paths) depmodOutputs {
			Text("echo").Flag("\"" + strings.Join(basenames, " ") + "\"").
			Text("|").Text("tr").Flag("\" \"").Flag("\"\\n\"").
			Text(">").Output(modulesLoad)
	}

	// Run depmod to build modules.dep/softdep/alias files
	modulesDep := modulesDir.Join(ctx, "modules.dep")