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
diff --git a/kernel/prebuilt_kernel_modules.go b/kernel/prebuilt_kernel_modules.go
index 4c0a911..5893211 100644
--- a/kernel/prebuilt_kernel_modules.go
+++ b/kernel/prebuilt_kernel_modules.go
@@ -47,6 +47,10 @@
// 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 @@
}
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 @@
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,14 +157,20 @@
// Enumerate modules to load
modulesLoad := modulesDir.Join(ctx, "modules.load")
- var basenames []string
- for _, m := range modules {
- basenames = append(basenames, filepath.Base(m.String()))
+ // 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()))
+ }
+ builder.Command().
+ Text("echo").Flag("\"" + strings.Join(basenames, " ") + "\"").
+ Text("|").Text("tr").Flag("\" \"").Flag("\"\\n\"").
+ Text(">").Output(modulesLoad)
}
- builder.Command().
- 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")