diff options
author | 2024-11-08 03:26:45 +0000 | |
---|---|---|
committer | 2024-11-08 22:35:02 +0000 | |
commit | ad402925e037e10a47ce128ce5b89e38ab1d26df (patch) | |
tree | ca7a4ce8caf9b861c31266c0af8bb6ad0e64f57f /kernel | |
parent | 912d26bd303ea4633378f652d30e14eba4b286b9 (diff) |
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
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/prebuilt_kernel_modules.go | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/kernel/prebuilt_kernel_modules.go b/kernel/prebuilt_kernel_modules.go index 4c0a9112b..5893211fb 100644 --- a/kernel/prebuilt_kernel_modules.go +++ b/kernel/prebuilt_kernel_modules.go @@ -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,14 +157,20 @@ func runDepmod(ctx android.ModuleContext, modules android.Paths) depmodOutputs { // 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") |