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

Commit 167710ee authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add options_file support for prebuilt_kernel_modules" into main am: 91043357

parents bd58b506 91043357
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -58,6 +58,9 @@ type prebuiltKernelModulesProperties struct {

	Blocklist_file *string `android:"path"`

	// Path to the kernel module options file
	Options_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
@@ -119,6 +122,7 @@ func (pkm *prebuiltKernelModules) GenerateAndroidBuildActions(ctx android.Module
	ctx.InstallFile(installDir, "modules.softdep", depmodOut.modulesSoftdep)
	ctx.InstallFile(installDir, "modules.alias", depmodOut.modulesAlias)
	pkm.installBlocklistFile(ctx, installDir)
	pkm.installOptionsFile(ctx, installDir)

	ctx.SetOutputFiles(modules, ".modules")
}
@@ -137,6 +141,20 @@ func (pkm *prebuiltKernelModules) installBlocklistFile(ctx android.ModuleContext
	ctx.InstallFile(installDir, "modules.blocklist", blocklistOut)
}

func (pkm *prebuiltKernelModules) installOptionsFile(ctx android.ModuleContext, installDir android.InstallPath) {
	if pkm.properties.Options_file == nil {
		return
	}
	optionsOut := android.PathForModuleOut(ctx, "modules.options")

	ctx.Build(pctx, android.BuildParams{
		Rule:   processOptionsFile,
		Input:  android.PathForModuleSrc(ctx, proptools.String(pkm.properties.Options_file)),
		Output: optionsOut,
	})
	ctx.InstallFile(installDir, "modules.options", optionsOut)
}

var (
	pctx = android.NewPackageContext("android/soong/kernel")

@@ -196,6 +214,19 @@ var (
				` END { exit exit_status }'`,
		},
	)
	// Remove empty lines. Raise an exception if line is _not_ formatted as `options $name.ko`
	processOptionsFile = pctx.AndroidStaticRule("process_options_file",
		blueprint.RuleParams{
			Command: `rm -rf $out && awk <$in > $out` +
				` '/^#/ { print; next }` +
				` NF == 0 { next }` +
				` NF < 2 || $$1 != "options"` +
				` { print "Invalid options 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.