diff options
author | 2024-11-11 18:43:07 +0000 | |
---|---|---|
committer | 2024-11-11 19:47:21 +0000 | |
commit | 6dfcbdfc5075b7672e61269ddbc49da6f12692b6 (patch) | |
tree | 4dae672129d6671a92469db02cbcf120ba3eb3a7 /kernel/prebuilt_kernel_modules.go | |
parent | 3f6305935f623bb150605c2d0342751e78924b4e (diff) |
Build and install modules.blocklist in prebuilt_kernel_modules
This ports `build-image-kernel-modules-blocklist-file` to Soong
fsgen has been updated to set this property on the autogenerated dlkm
filesystem modules.
Test: verified that /vendor_dlkm/lib/modules.blocklist is same between
kati and soong built vendor_dlkm
Bug: 377562851
Bug: 377362016
Change-Id: I99425b8cc48128ac72aaad5a3fa09bf8e3a015eb
Diffstat (limited to 'kernel/prebuilt_kernel_modules.go')
-rw-r--r-- | kernel/prebuilt_kernel_modules.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/kernel/prebuilt_kernel_modules.go b/kernel/prebuilt_kernel_modules.go index 78a463f75..13d648235 100644 --- a/kernel/prebuilt_kernel_modules.go +++ b/kernel/prebuilt_kernel_modules.go @@ -56,6 +56,8 @@ type prebuiltKernelModulesProperties struct { // This feature is used by system_dlkm Load_by_default *bool + Blocklist_file *string `android:"path"` + // 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 @@ -109,10 +111,25 @@ func (pkm *prebuiltKernelModules) GenerateAndroidBuildActions(ctx android.Module ctx.InstallFile(installDir, "modules.dep", depmodOut.modulesDep) ctx.InstallFile(installDir, "modules.softdep", depmodOut.modulesSoftdep) ctx.InstallFile(installDir, "modules.alias", depmodOut.modulesAlias) + pkm.installBlocklistFile(ctx, installDir) ctx.SetOutputFiles(modules, ".modules") } +func (pkm *prebuiltKernelModules) installBlocklistFile(ctx android.ModuleContext, installDir android.InstallPath) { + if pkm.properties.Blocklist_file == nil { + return + } + blocklistOut := android.PathForModuleOut(ctx, "modules.blocklist") + + ctx.Build(pctx, android.BuildParams{ + Rule: processBlocklistFile, + Input: android.PathForModuleSrc(ctx, proptools.String(pkm.properties.Blocklist_file)), + Output: blocklistOut, + }) + ctx.InstallFile(installDir, "modules.blocklist", blocklistOut) +} + var ( pctx = android.NewPackageContext("android/soong/kernel") @@ -159,6 +176,19 @@ var ( Command: `sed -e 's|\([^: ]*lib/modules/[^: ]*\)|/\1|g' $in > $out`, }, ) + // Remove empty lines. Raise an exception if line is _not_ formatted as `blocklist $name.ko` + processBlocklistFile = pctx.AndroidStaticRule("process_blocklist_file", + blueprint.RuleParams{ + Command: `rm -rf $out && awk <$in > $out` + + ` '/^#/ { print; next }` + + ` NF == 0 { next }` + + ` NF != 2 || $$1 != "blocklist"` + + ` { print "Invalid blocklist line " FNR ": " $$0 >"/dev/stderr";` + + ` exit_status = 1; next }` + + ` { $$1 = $$1; print }` + + ` END { exit exit_status }'`, + }, + ) ) // This is the path in soong intermediates where the .ko files will be copied. |