Expand the usages of prebuilt_any in prebuilt_etc module gen
Currently, prebuilt_any is only used as a fallback behavior when the
generated prebuilt_root module tries to set the `Dsts` property, given
that prebuilt_root module type is no longer allowed to set `Dsts`
property with https://r.android.com/3540101.
This change expands the usages of the fallback behavior to when the
generated prebuilt_root module tries to set the `Relative_install_path`
property, given that this property is not also available to
prebuilt_root module type.
Test: m nothing --no-skip-soong-tests
Change-Id: I9344a8cb3e26bedbd0217a5344ac92b8def68554
diff --git a/fsgen/prebuilt_etc_modules_gen.go b/fsgen/prebuilt_etc_modules_gen.go
index df945b3..c98e225 100644
--- a/fsgen/prebuilt_etc_modules_gen.go
+++ b/fsgen/prebuilt_etc_modules_gen.go
@@ -337,9 +337,23 @@
// Set appropriate srcs, dsts, and releative_install_path based on
// the source and install file names
- if allCopyFileNamesUnchanged {
- modulePropsPtr.Srcs = srcBaseFiles
+ modulePropsPtr.Srcs = srcBaseFiles
+ // prebuilt_root should only be used in very limited cases in prebuilt_etc moddule gen, where:
+ // - all source file names are identical to the installed file names, and
+ // - all source files are installed in root, not the subdirectories of root
+ // prebuilt_root currently does not have a good way to specify the names of the multiple
+ // installed files, and prebuilt_root does not allow installing files at a subdirectory
+ // of the root.
+ // Use prebuilt_any instead of prebuilt_root if either of the conditions are not met as
+ // a fallback behavior.
+ if etcInstallPathKey == "" {
+ if !(allCopyFileNamesUnchanged && android.InList(relDestDirFromInstallDirBase, []string{"", "."})) {
+ moduleFactory = etc.PrebuiltAnyFactory
+ }
+ }
+
+ if allCopyFileNamesUnchanged {
// Specify relative_install_path if it is not installed in the root directory of the
// partition
if !android.InList(relDestDirFromInstallDirBase, []string{"", "."}) {
@@ -350,15 +364,10 @@
} else {
// If dsts property has to be set and the selected module type is prebuilt_root,
// use prebuilt_any instead.
- if etcInstallPathKey == "" {
- moduleFactory = etc.PrebuiltAnyFactory
- }
- modulePropsPtr.Srcs = srcBaseFiles
dsts := proptools.NewConfigurable[[]string](nil, nil)
for _, installBaseFile := range installBaseFiles {
dsts.AppendSimpleValue([]string{filepath.Join(relDestDirFromInstallDirBase, installBaseFile)})
}
-
propsList = append(propsList, &etc.PrebuiltDstsProperties{
Dsts: dsts,
})