Create linker_config_srcs for autogenerated product partition
This will be used to create /product/etc/linker.config.pb. Since
`PRODUCT_PRODUCT_LINKER_CONFIG_FRAGMENTS` are relative to workspace top,
a filegroup soong module will be dynamically created.
Test: checked that /product/etc/linker.config.pb is present in autogenerated
product.img file list (with next CL in stack)
Bug: 376515221
Change-Id: If1cb0d27f79af76c8e5780ead12595518b154b9e
diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go
index e470e91..bf5dfd9 100644
--- a/fsgen/filesystem_creator.go
+++ b/fsgen/filesystem_creator.go
@@ -474,8 +474,8 @@
return false
}
- if partitionType == "vendor" {
- fsProps.Linker_config_srcs = f.createLinkerConfigSourceFilegroups(ctx)
+ if partitionType == "vendor" || partitionType == "product" {
+ fsProps.Linker_config_srcs = f.createLinkerConfigSourceFilegroups(ctx, partitionType)
}
var module android.Module
@@ -509,18 +509,29 @@
return true
}
-// createLinkerConfigSourceFilegroups creates filegroup modules to generate linker.config.pb for _vendor_
-// It creates a filegroup for each file in PRODUCT_VENDOR_LINKER_CONFIG_FRAGMENTS.
+// 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)
+// It creates a filegroup for each file in the fragment list
// The filegroup modules are then added to `linker_config_srcs` of the autogenerated vendor `android_filesystem`.
-func (f *filesystemCreator) createLinkerConfigSourceFilegroups(ctx android.LoadHookContext) []string {
+func (f *filesystemCreator) createLinkerConfigSourceFilegroups(ctx android.LoadHookContext, partitionType string) []string {
ret := []string{}
partitionVars := ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse
- if linkerConfigSrcs := android.FirstUniqueStrings(partitionVars.VendorLinkerConfigSrcs); len(linkerConfigSrcs) > 0 {
+ var linkerConfigSrcs []string
+ if partitionType == "vendor" {
+ linkerConfigSrcs = android.FirstUniqueStrings(partitionVars.VendorLinkerConfigSrcs)
+ } else if partitionType == "product" {
+ linkerConfigSrcs = android.FirstUniqueStrings(partitionVars.ProductLinkerConfigSrcs)
+ } else {
+ ctx.ModuleErrorf("linker.config.pb is only supported for vendor and product partitions. For system partition, use `android_system_image`")
+ }
+
+ if len(linkerConfigSrcs) > 0 {
// Create a filegroup, and add `:<filegroup_name>` to ret.
for index, linkerConfigSrc := range linkerConfigSrcs {
dir := filepath.Dir(linkerConfigSrc)
base := filepath.Base(linkerConfigSrc)
- fgName := generatedModuleName(ctx.Config(), "vendor-linker-config-src"+strconv.Itoa(index))
+ fgName := generatedModuleName(ctx.Config(), fmt.Sprintf("%s-linker-config-src%s", partitionType, strconv.Itoa(index)))
srcs := []string{base}
fgProps := &struct {
Name *string