refactor Bazel variable export

Most of the variable export code for cc modules can be re-used for
exporting variables for java modules. Refactor this code into a more
composable structure for reuse.

Test: build/bazel/bp2build.sh
Test: manual comparison of
  out/soong/soong_injection/cc_toolchain/constants.bzl
  with previous output
Change-Id: Ie5a6fee08cc888b7dc69c3e324e5c3f8aa269a8f
This commit is contained in:
Sam Delmerico
2022-03-25 14:55:40 +00:00
parent 85b935eff2
commit 7f88956c16
12 changed files with 305 additions and 237 deletions

View File

@@ -19,6 +19,7 @@ import (
"fmt"
"strconv"
"android/soong/bazel"
"android/soong/starlark_fmt"
)
@@ -393,10 +394,10 @@ func printApiLevelsStarlarkDict(config Config) string {
}
func StarlarkApiLevelConfigs(config Config) string {
return fmt.Sprintf(`# GENERATED FOR BAZEL FROM SOONG. DO NOT EDIT.
return fmt.Sprintf(bazel.GeneratedBazelFileWarning+`
_api_levels = %s
api_levels = _api_levels
`, printApiLevelsStarlarkDict(config),
)
}
}