Use a boolean to determine if linker.config.pb should be generated

vendor and product generate a linker.config.pb even if
`PRODUCT_VENDOR_LINKER_CONFIG_FRAGMENTS` or
`PRODUCT_PRODUCT_LINKER_CONFIG_FRAGMENTS` are empty respectively. This
CL introduces a new property to determine if a filesystem should
generate a linker.config.pb. The autogenerated vendor and product
filesystem modules will set this property to true.

Test: go test ./filesystem
Bug: 376515221

Change-Id: Ibd007df0d287034f4d227a6054bd83937570ec27
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index d0d4825..0e3c3a0 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -147,9 +147,7 @@
 
 	Erofs ErofsProperties
 
-	// List of files (in .json format) that will be converted to a linker config file (in .pb format).
-	// The linker config file be installed in the filesystem at /etc/linker.config.pb
-	Linker_config_srcs []string `android:"path"`
+	Linkerconfig LinkerConfigProperties
 
 	// Determines if the module is auto-generated from Soong or not. If the module is
 	// auto-generated, its deps are exempted from visibility enforcement.
@@ -168,6 +166,16 @@
 	Sparse *bool
 }
 
+type LinkerConfigProperties struct {
+
+	// Build a linker.config.pb file
+	Gen_linker_config *bool
+
+	// List of files (in .json format) that will be converted to a linker config file (in .pb format).
+	// The linker config file be installed in the filesystem at /etc/linker.config.pb
+	Linker_config_srcs []string `android:"path"`
+}
+
 // android_filesystem packages a set of modules and their transitive dependencies into a filesystem
 // image. The filesystem images are expected to be mounted in the target device, which means the
 // modules in the filesystem image are built for the target device (i.e. Android, not Linux host).
@@ -690,13 +698,13 @@
 }
 
 func (f *filesystem) buildLinkerConfigFile(ctx android.ModuleContext, builder *android.RuleBuilder, rebasedDir android.OutputPath) {
-	if len(f.properties.Linker_config_srcs) == 0 {
+	if !proptools.Bool(f.properties.Linkerconfig.Gen_linker_config) {
 		return
 	}
 
 	provideModules, _ := f.getLibsForLinkerConfig(ctx)
 	output := rebasedDir.Join(ctx, "etc", "linker.config.pb")
-	linkerconfig.BuildLinkerConfig(ctx, builder, android.PathsForModuleSrc(ctx, f.properties.Linker_config_srcs), provideModules, nil, output)
+	linkerconfig.BuildLinkerConfig(ctx, builder, android.PathsForModuleSrc(ctx, f.properties.Linkerconfig.Linker_config_srcs), provideModules, nil, output)
 
 	f.appendToEntry(ctx, output)
 }