Generate board-specific launchers in mk2rbc
Board config works slightly differently from product config.
It requires the product config variables to be passed into
it. Currently the only generic way to pass info into an RBC
script is via the arguments to rbcrun, which get passed
as global variables, not the product (cfg) variables.
Add a new form of launcher that reads the product variables
from a separate rbc file that is generated in make.
The board configuration also doesn't need inheritance, so it
doesn't call rblf.product_configuration() either.
Bug: 201700692
Test: build/bazel/ci/rbc_product_config.sh -b sdk_phone_x86_64-userdebug
Change-Id: I52fd65b33cf99b45a563284e2849da75a8af8688
diff --git a/mk2rbc/mk2rbc.go b/mk2rbc/mk2rbc.go
index 6227164..f2a0760 100644
--- a/mk2rbc/mk2rbc.go
+++ b/mk2rbc/mk2rbc.go
@@ -52,7 +52,9 @@
// And here are the functions and variables:
cfnGetCfg = baseName + ".cfg"
cfnMain = baseName + ".product_configuration"
+ cfnBoardMain = baseName + ".board_configuration"
cfnPrintVars = baseName + ".printvars"
+ cfnPrintGlobals = baseName + ".printglobals"
cfnWarning = baseName + ".warning"
cfnLocalAppend = baseName + ".local_append"
cfnLocalSetDefault = baseName + ".local_set_default"
@@ -1702,6 +1704,17 @@
return buf.String()
}
+func BoardLauncher(mainModuleUri string, inputVariablesUri string) string {
+ var buf bytes.Buffer
+ fmt.Fprintf(&buf, "load(%q, %q)\n", baseUri, baseName)
+ fmt.Fprintf(&buf, "load(%q, \"init\")\n", mainModuleUri)
+ fmt.Fprintf(&buf, "load(%q, input_variables_init = \"init\")\n", inputVariablesUri)
+ fmt.Fprintf(&buf, "globals, cfg, globals_base = %s(init, input_variables_init)\n", cfnBoardMain)
+ fmt.Fprintf(&buf, "# TODO: Some product config variables need to be printed, but most are readonly so we can't just print cfg here.\n")
+ fmt.Fprintf(&buf, "%s(globals, globals_base)\n", cfnPrintGlobals)
+ return buf.String()
+}
+
func MakePath2ModuleName(mkPath string) string {
return strings.TrimSuffix(mkPath, filepath.Ext(mkPath))
}