diff options
-rw-r--r-- | android/neverallow.go | 2 | ||||
-rw-r--r-- | etc/prebuilt_etc.go | 15 | ||||
-rw-r--r-- | fsgen/filesystem_creator_test.go | 2 | ||||
-rw-r--r-- | fsgen/prebuilt_etc_modules_gen.go | 8 |
4 files changed, 26 insertions, 1 deletions
diff --git a/android/neverallow.go b/android/neverallow.go index 8995a0ffe..e418d5c65 100644 --- a/android/neverallow.go +++ b/android/neverallow.go @@ -251,6 +251,7 @@ func createInstallInRootAllowingRules() []Rule { NotModuleType("prebuilt_system"). NotModuleType("prebuilt_first_stage_ramdisk"). NotModuleType("prebuilt_res"). + NotModuleType("prebuilt_any"). Because("install_in_root is only for init_first_stage or librecovery_ui_ext."), } } @@ -363,6 +364,7 @@ func createKotlinPluginRule() []Rule { func createPrebuiltEtcBpDefineRule() Rule { return NeverAllow(). ModuleType( + "prebuilt_any", "prebuilt_usr_srec", "prebuilt_priv_app", "prebuilt_rfs", diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go index fad8f0779..f2bf0d243 100644 --- a/etc/prebuilt_etc.go +++ b/etc/prebuilt_etc.go @@ -87,6 +87,7 @@ func RegisterPrebuiltEtcBuildComponents(ctx android.RegistrationContext) { ctx.RegisterModuleType("prebuilt_sbin", PrebuiltSbinFactory) ctx.RegisterModuleType("prebuilt_system", PrebuiltSystemFactory) ctx.RegisterModuleType("prebuilt_first_stage_ramdisk", PrebuiltFirstStageRamdiskFactory) + ctx.RegisterModuleType("prebuilt_any", PrebuiltAnyFactory) ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory) @@ -664,6 +665,20 @@ func PrebuiltEtcHostFactory() android.Module { return module } +// prebuilt_any is a special module where the module can define the subdirectory that the files +// are installed to. This is only used for converting the PRODUCT_COPY_FILES entries to Soong +// modules, and should never be defined in the bp files. If none of the existing prebuilt_* +// modules allow installing the file at the desired location, introduce a new prebuilt_* module +// type instead. +func PrebuiltAnyFactory() android.Module { + module := &PrebuiltEtc{} + InitPrebuiltEtcModule(module, ".") + // This module is device-only + android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) + android.InitDefaultableModule(module) + return module +} + // prebuilt_etc_host is for a host prebuilt artifact that is installed in // <partition>/etc/<sub_dir> directory. func PrebuiltEtcCaCertsFactory() android.Module { diff --git a/fsgen/filesystem_creator_test.go b/fsgen/filesystem_creator_test.go index 418e48bcd..ba40f3f5e 100644 --- a/fsgen/filesystem_creator_test.go +++ b/fsgen/filesystem_creator_test.go @@ -287,6 +287,8 @@ func TestPrebuiltEtcModuleGen(t *testing.T) { "some/non/existing/file.txt:system/etc/file.txt", "device/sample/etc/apns-full-conf.xml:product/etc/apns-conf.xml:google", "device/sample/etc/apns-full-conf.xml:product/etc/apns-conf-2.xml", + "device/sample/etc/apns-full-conf.xml:system/foo/file.txt", + "device/sample/etc/apns-full-conf.xml:system/foo/apns-full-conf.xml", } config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.PartitionQualifiedVariables = map[string]android.PartitionQualifiedVariablesType{ diff --git a/fsgen/prebuilt_etc_modules_gen.go b/fsgen/prebuilt_etc_modules_gen.go index e028b1d5a..0adf7a1e3 100644 --- a/fsgen/prebuilt_etc_modules_gen.go +++ b/fsgen/prebuilt_etc_modules_gen.go @@ -299,6 +299,7 @@ func createPrebuiltEtcModulesInDirectory(ctx android.LoadHookContext, partition, etcInstallPathKey = etcInstallPath } } + moduleFactory := etcInstallPathToFactoryList[etcInstallPathKey] relDestDirFromInstallDirBase, _ := filepath.Rel(etcInstallPathKey, destDir) for fileIndex := range maxLen { @@ -348,6 +349,11 @@ func createPrebuiltEtcModulesInDirectory(ctx android.LoadHookContext, partition, }) } } 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 := []string{} for _, installBaseFile := range installBaseFiles { @@ -356,7 +362,7 @@ func createPrebuiltEtcModulesInDirectory(ctx android.LoadHookContext, partition, modulePropsPtr.Dsts = dsts } - ctx.CreateModuleInDirectory(etcInstallPathToFactoryList[etcInstallPathKey], srcDir, propsList...) + ctx.CreateModuleInDirectory(moduleFactory, srcDir, propsList...) moduleNames = append(moduleNames, moduleName) } |