Specify bootconfig property in vendor_boot.img

bootconfig is a path to the text file, created based on
`INTERNAL_BOOTCONFIG` and `INTERNAL_BOOTCONFIG_FILE`. This is done by
auto generating a newly introduced bootconfig module. The
output file of the genrule module is passed as a property to the
vendor_boot.img module.

Test: Inspect the content of the generated vendor-bootconfig.img file
Test: Inspect the ninja command of the autogen vendor_boot.img
Bug: 379945468
Change-Id: I9c693de681e6dad7399f80df05825cce9b0c1c22
diff --git a/fsgen/boot_imgs.go b/fsgen/boot_imgs.go
index 799dbc9..4e80720 100644
--- a/fsgen/boot_imgs.go
+++ b/fsgen/boot_imgs.go
@@ -104,6 +104,11 @@
 
 	cmdline := partitionVariables.InternalKernelCmdline
 
+	var vendorBootConfigImg *string
+	if name, ok := createVendorBootConfigImg(ctx); ok {
+		vendorBootConfigImg = proptools.StringPtr(":" + name)
+	}
+
 	ctx.CreateModule(
 		filesystem.BootimgFactory,
 		&filesystem.BootimgProperties{
@@ -117,6 +122,7 @@
 			Avb_algorithm:      avbInfo.avbAlgorithm,
 			Dtb_prebuilt:       dtbPrebuilt,
 			Cmdline:            cmdline,
+			Bootconfig:         vendorBootConfigImg,
 		},
 		&struct {
 			Name *string
@@ -283,3 +289,29 @@
 	}
 	return dtbImg{include: false}
 }
+
+func createVendorBootConfigImg(ctx android.LoadHookContext) (string, bool) {
+	partitionVars := ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse
+	bootconfig := partitionVars.InternalBootconfig
+	bootconfigFile := partitionVars.InternalBootconfigFile
+	if len(bootconfig) == 0 && len(bootconfigFile) == 0 {
+		return "", false
+	}
+
+	vendorBootconfigImgModuleName := generatedModuleName(ctx.Config(), "vendor_bootconfig_image")
+
+	ctx.CreateModule(
+		filesystem.BootconfigModuleFactory,
+		&struct {
+			Name             *string
+			Boot_config      []string
+			Boot_config_file *string
+		}{
+			Name:             proptools.StringPtr(vendorBootconfigImgModuleName),
+			Boot_config:      bootconfig,
+			Boot_config_file: proptools.StringPtr(bootconfigFile),
+		},
+	)
+
+	return vendorBootconfigImgModuleName, true
+}