export Java variables to Bazel

Test: build/bazel/bp2build.sh
Change-Id: Ia06f9265c9f96e6add6edbd0cee925fe37b430d3
This commit is contained in:
Sam Delmerico
2022-03-25 16:33:26 +00:00
parent 7f88956c16
commit 932c01cf9e
9 changed files with 262 additions and 38 deletions

View File

@@ -16,8 +16,6 @@ package config
import (
"strings"
"android/soong/android"
)
var (
@@ -31,23 +29,23 @@ var (
)
// Wrapper that grabs value of val late so it can be initialized by a later module's init function
func errorProneVar(name string, val *[]string, sep string) {
pctx.VariableFunc(name, func(android.PackageVarContext) string {
func errorProneVar(val *[]string, sep string) func() string {
return func() string {
return strings.Join(*val, sep)
})
}
}
func init() {
errorProneVar("ErrorProneClasspath", &ErrorProneClasspath, ":")
errorProneVar("ErrorProneChecksError", &ErrorProneChecksError, " ")
errorProneVar("ErrorProneChecksWarning", &ErrorProneChecksWarning, " ")
errorProneVar("ErrorProneChecksDefaultDisabled", &ErrorProneChecksDefaultDisabled, " ")
errorProneVar("ErrorProneChecksOff", &ErrorProneChecksOff, " ")
errorProneVar("ErrorProneFlags", &ErrorProneFlags, " ")
pctx.StaticVariable("ErrorProneChecks", strings.Join([]string{
exportedVars.ExportVariableFuncVariable("ErrorProneClasspath", errorProneVar(&ErrorProneClasspath, ":"))
exportedVars.ExportVariableFuncVariable("ErrorProneChecksError", errorProneVar(&ErrorProneChecksError, " "))
exportedVars.ExportVariableFuncVariable("ErrorProneChecksWarning", errorProneVar(&ErrorProneChecksWarning, " "))
exportedVars.ExportVariableFuncVariable("ErrorProneChecksDefaultDisabled", errorProneVar(&ErrorProneChecksDefaultDisabled, " "))
exportedVars.ExportVariableFuncVariable("ErrorProneChecksOff", errorProneVar(&ErrorProneChecksOff, " "))
exportedVars.ExportVariableFuncVariable("ErrorProneFlags", errorProneVar(&ErrorProneFlags, " "))
exportedVars.ExportStringListStaticVariable("ErrorProneChecks", []string{
"${ErrorProneChecksOff}",
"${ErrorProneChecksError}",
"${ErrorProneChecksWarning}",
"${ErrorProneChecksDefaultDisabled}",
}, " "))
})
}