summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Spandan Das <spandandas@google.com> 2024-11-05 02:11:23 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2024-11-05 02:11:23 +0000
commit0ff28b68a643b07ff21d9bfd7a22326b83cc75b9 (patch)
tree1b861cbc6cedb0a14f593a33a3eb7800ef9f1edd
parent45aeb5f9c08ae74dfb070640289721bbf1e81194 (diff)
parent5e336426d14d514e90146e32070f40c0b54213b9 (diff)
Merge "Autogenerate a system_dlkm android_filesystem" into main
-rw-r--r--android/variable.go3
-rw-r--r--fsgen/Android.bp1
-rw-r--r--fsgen/filesystem_creator.go50
-rw-r--r--kernel/prebuilt_kernel_modules.go4
4 files changed, 56 insertions, 2 deletions
diff --git a/android/variable.go b/android/variable.go
index a4ee88624..df9db7c22 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -605,6 +605,9 @@ type PartitionVariables struct {
ProductLinkerConfigSrcs []string `json:",omitempty"`
ProductCopyFiles map[string]string `json:",omitempty"`
+
+ BuildingSystemDlkmImage bool `json:",omitempty"`
+ SystemKernelModules []string `json:",omitempty"`
}
func boolPtr(v bool) *bool {
diff --git a/fsgen/Android.bp b/fsgen/Android.bp
index baf929164..e3cbdb375 100644
--- a/fsgen/Android.bp
+++ b/fsgen/Android.bp
@@ -10,6 +10,7 @@ bootstrap_go_package {
"soong",
"soong-android",
"soong-filesystem",
+ "soong-kernel",
],
srcs: [
"filesystem_creator.go",
diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go
index 06e154ac6..7ef7d9901 100644
--- a/fsgen/filesystem_creator.go
+++ b/fsgen/filesystem_creator.go
@@ -25,6 +25,7 @@ import (
"android/soong/android"
"android/soong/filesystem"
+ "android/soong/kernel"
"github.com/google/blueprint"
"github.com/google/blueprint/parser"
@@ -115,6 +116,9 @@ func createFsGenState(ctx android.LoadHookContext) *FsGenState {
if ctx.DeviceConfig().BuildingOdmImage() && ctx.DeviceConfig().OdmPath() == "odm" {
generatedPartitions = append(generatedPartitions, "odm")
}
+ if partitionVars.BuildingSystemDlkmImage {
+ generatedPartitions = append(generatedPartitions, "system_dlkm")
+ }
return &FsGenState{
depCandidates: candidates,
@@ -160,6 +164,7 @@ func createFsGenState(ctx android.LoadHookContext) *FsGenState {
"com.android.vndk.v33": defaultDepCandidateProps(ctx.Config()),
"com.android.vndk.v34": defaultDepCandidateProps(ctx.Config()),
},
+ "system_dlkm": {},
},
soongGeneratedPartitions: generatedPartitions,
fsDepsMutex: sync.Mutex{},
@@ -500,9 +505,19 @@ func (f *filesystemCreator) createPartition(ctx android.LoadHookContext, partiti
fsProps.Linkerconfig.Linker_config_srcs = f.createLinkerConfigSourceFilegroups(ctx, partitionType)
}
+ if partitionType == "system_dlkm" {
+ kernelModules := ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.SystemKernelModules
+ f.createPrebuiltKernelModules(ctx, partitionType, kernelModules)
+ }
+
var module android.Module
if partitionType == "system" {
module = ctx.CreateModule(filesystem.SystemImageFactory, baseProps, fsProps)
+ } else if partitionType == "system_dlkm" {
+ // Do not set partition_type. build/soong/android/paths#modulePartition currently does not support dlkm
+ // partitions. Since `android_filesystem` uses a partition based filter, setting the partition here
+ // would result in missing in entries.
+ module = ctx.CreateModule(filesystem.FilesystemFactory, baseProps, fsProps)
} else {
// Explicitly set the partition.
fsProps.Partition_type = proptools.StringPtr(partitionType)
@@ -531,6 +546,41 @@ func (f *filesystemCreator) createPartition(ctx android.LoadHookContext, partiti
return true
}
+// createPrebuiltKernelModules creates `prebuilt_kernel_modules`. These modules will be added to deps of the
+// autogenerated *_dlkm filsystem modules.
+// The input `kernelModules` is a space separated list of .ko files in the workspace. This will be partitioned per directory
+// and a `prebuilt_kernel_modules` will be created per partition.
+// These autogenerated modules will be subsequently added to the deps of the top level *_dlkm android_filesystem
+func (f *filesystemCreator) createPrebuiltKernelModules(ctx android.LoadHookContext, partitionType string, kernelModules []string) {
+ // Partition the files per directory
+ dirToFiles := map[string][]string{}
+ for _, kernelModule := range kernelModules {
+ dir := filepath.Dir(kernelModule)
+ base := filepath.Base(kernelModule)
+ dirToFiles[dir] = append(dirToFiles[dir], base)
+ }
+ // Create a prebuilt_kernel_modules module per partition
+ fsGenState := ctx.Config().Get(fsGenStateOnceKey).(*FsGenState)
+ for index, dir := range android.SortedKeys(dirToFiles) {
+ name := generatedModuleName(ctx.Config(), fmt.Sprintf("%s-kernel-modules-%s", partitionType, strconv.Itoa(index)))
+ props := &struct {
+ Name *string
+ Srcs []string
+ }{
+ Name: proptools.StringPtr(name),
+ Srcs: dirToFiles[dir],
+ }
+ kernelModule := ctx.CreateModuleInDirectory(
+ kernel.PrebuiltKernelModulesFactory,
+ dir,
+ props,
+ )
+ kernelModule.HideFromMake()
+ // Add to deps
+ (*fsGenState.fsDeps[partitionType])[name] = defaultDepCandidateProps(ctx.Config())
+ }
+}
+
// createLinkerConfigSourceFilegroups creates filegroup modules to generate linker.config.pb for the following partitions
// 1. vendor: Using PRODUCT_VENDOR_LINKER_CONFIG_FRAGMENTS (space separated file list)
// 1. product: Using PRODUCT_PRODUCT_LINKER_CONFIG_FRAGMENTS (space separated file list)
diff --git a/kernel/prebuilt_kernel_modules.go b/kernel/prebuilt_kernel_modules.go
index e200ee2c1..4c0a9112b 100644
--- a/kernel/prebuilt_kernel_modules.go
+++ b/kernel/prebuilt_kernel_modules.go
@@ -32,7 +32,7 @@ func init() {
}
func registerKernelBuildComponents(ctx android.RegistrationContext) {
- ctx.RegisterModuleType("prebuilt_kernel_modules", prebuiltKernelModulesFactory)
+ ctx.RegisterModuleType("prebuilt_kernel_modules", PrebuiltKernelModulesFactory)
}
type prebuiltKernelModules struct {
@@ -58,7 +58,7 @@ type prebuiltKernelModulesProperties struct {
// prebuilt_kernel_modules installs a set of prebuilt kernel module files to the correct directory.
// In addition, this module builds modules.load, modules.dep, modules.softdep and modules.alias
// using depmod and installs them as well.
-func prebuiltKernelModulesFactory() android.Module {
+func PrebuiltKernelModulesFactory() android.Module {
module := &prebuiltKernelModules{}
module.AddProperties(&module.properties)
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)