Add relative_install_path property to prebuilt_etc
This supports a more consistent property across modules for specifying a
subdirectory to install a file into for prebuilt_etc modules.
Updates bpfix to rewrite `sub_dir` to `relative_install_path`.
Test: gotest prebuilt_etc_test
Test: gotest bpfix_test
Bug: 156568187
Change-Id: Idd05cd2178c46e290764a3b708faa8275818ca1e
diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go
index df6d79d..0f7b8df 100644
--- a/etc/prebuilt_etc.go
+++ b/etc/prebuilt_etc.go
@@ -42,9 +42,12 @@
// Source file of this prebuilt.
Src *string `android:"path,arch_variant"`
- // optional subdirectory under which this file is installed into
+ // optional subdirectory under which this file is installed into, cannot be specified with relative_install_path, prefer relative_install_path
Sub_dir *string `android:"arch_variant"`
+ // optional subdirectory under which this file is installed into, cannot be specified with sub_dir
+ Relative_install_path *string `android:"arch_variant"`
+
// optional name for the installed file. If unspecified, name of the module is used as the file name
Filename *string `android:"arch_variant"`
@@ -158,7 +161,10 @@
}
func (p *PrebuiltEtc) SubDir() string {
- return android.String(p.properties.Sub_dir)
+ if subDir := proptools.String(p.properties.Sub_dir); subDir != "" {
+ return subDir
+ }
+ return proptools.String(p.properties.Relative_install_path)
}
func (p *PrebuiltEtc) Installable() bool {
@@ -181,13 +187,17 @@
}
p.outputFilePath = android.PathForModuleOut(ctx, filename).OutputPath
+ if p.properties.Sub_dir != nil && p.properties.Relative_install_path != nil {
+ ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
+ }
+
// If soc install dir was specified and SOC specific is set, set the installDirPath to the specified
// socInstallDirBase.
installBaseDir := p.installDirBase
if ctx.SocSpecific() && p.socInstallDirBase != "" {
installBaseDir = p.socInstallDirBase
}
- p.installDirPath = android.PathForModuleInstall(ctx, installBaseDir, proptools.String(p.properties.Sub_dir))
+ p.installDirPath = android.PathForModuleInstall(ctx, installBaseDir, p.SubDir())
// This ensures that outputFilePath has the correct name for others to
// use, as the source file may have a different name.