1:1 mapping between prebuilt_kernel_modules and _dlkm filesystem modules
This is a correction to the autogeneration logic introduced in
https://r.android.com/3329416, which would create multiple
prebuilt_kernel_modules for a specific partition if the .ko files are
distributed in the tree. In addition to assembling and installing the
.ko files, `prebuilt_kernel_modules` are also responsible for creating
dependency metadata files by running `depmod`. If we autogenerate
multiple prebuilt_kernel_modules for a specific partition, the
dependency metadata files will be incorrect, and we will also have
multiple installation rules for /lib/modules/modules.(load|dep|...)
To prevent introducing complexity of intermediate filegroups, the
`prebuilt_kernel_modules` will be generated in the root directory for
now.
Test: m nothing
Bug: 377562851
Change-Id: Ic5d0c95f2bf32a9a97ba0489801fe2bfd4928aef
diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go
index bdffabf..80f0955 100644
--- a/fsgen/filesystem_creator.go
+++ b/fsgen/filesystem_creator.go
@@ -211,38 +211,28 @@
}
// 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
+// autogenerated *_dlkm filsystem modules. Each _dlkm partition should have a single prebuilt_kernel_modules dependency.
+// This ensures that the depmod artifacts (modules.* installed in /lib/modules/) are generated with a complete view.
+
+// The input `kernelModules` is a space separated list of .ko files in the workspace.
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())
+ name := generatedModuleName(ctx.Config(), fmt.Sprintf("%s-kernel-modules", partitionType))
+ props := &struct {
+ Name *string
+ Srcs []string
+ }{
+ Name: proptools.StringPtr(name),
+ Srcs: kernelModules,
}
+ kernelModule := ctx.CreateModuleInDirectory(
+ kernel.PrebuiltKernelModulesFactory,
+ ".", // create in root directory for now
+ props,
+ )
+ kernelModule.HideFromMake()
+ // Add to deps
+ (*fsGenState.fsDeps[partitionType])[name] = defaultDepCandidateProps(ctx.Config())
}
// Create a build_prop and android_info module. This will be used to create /vendor/build.prop