summaryrefslogtreecommitdiff
path: root/android/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'android/config.go')
-rw-r--r--android/config.go41
1 files changed, 38 insertions, 3 deletions
diff --git a/android/config.go b/android/config.go
index 4472036da..877800a72 100644
--- a/android/config.go
+++ b/android/config.go
@@ -24,6 +24,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
+ "reflect"
"runtime"
"strconv"
"strings"
@@ -37,6 +38,7 @@ import (
"android/soong/android/soongconfig"
"android/soong/bazel"
"android/soong/remoteexec"
+ "android/soong/starlark_fmt"
)
// Bool re-exports proptools.Bool for the android package.
@@ -273,15 +275,43 @@ func saveToBazelConfigFile(config *productVariables, outDir string) error {
return fmt.Errorf("Could not create dir %s: %s", dir, err)
}
- data, err := json.MarshalIndent(&config, "", " ")
+ nonArchVariantProductVariables := []string{}
+ archVariantProductVariables := []string{}
+ p := variableProperties{}
+ t := reflect.TypeOf(p.Product_variables)
+ for i := 0; i < t.NumField(); i++ {
+ f := t.Field(i)
+ nonArchVariantProductVariables = append(nonArchVariantProductVariables, strings.ToLower(f.Name))
+ if proptools.HasTag(f, "android", "arch_variant") {
+ archVariantProductVariables = append(archVariantProductVariables, strings.ToLower(f.Name))
+ }
+ }
+
+ nonArchVariantProductVariablesJson := starlark_fmt.PrintStringList(nonArchVariantProductVariables, 0)
+ if err != nil {
+ return fmt.Errorf("cannot marshal product variable data: %s", err.Error())
+ }
+
+ archVariantProductVariablesJson := starlark_fmt.PrintStringList(archVariantProductVariables, 0)
+ if err != nil {
+ return fmt.Errorf("cannot marshal arch variant product variable data: %s", err.Error())
+ }
+
+ configJson, err := json.MarshalIndent(&config, "", " ")
if err != nil {
return fmt.Errorf("cannot marshal config data: %s", err.Error())
}
bzl := []string{
bazel.GeneratedBazelFileWarning,
- fmt.Sprintf(`_product_vars = json.decode("""%s""")`, data),
- "product_vars = _product_vars\n",
+ fmt.Sprintf(`_product_vars = json.decode("""%s""")`, configJson),
+ fmt.Sprintf(`_product_var_constraints = %s`, nonArchVariantProductVariablesJson),
+ fmt.Sprintf(`_arch_variant_product_var_constraints = %s`, archVariantProductVariablesJson),
+ "\n", `
+product_vars = _product_vars
+product_var_constraints = _product_var_constraints
+arch_variant_product_var_constraints = _arch_variant_product_var_constraints
+`,
}
err = ioutil.WriteFile(filepath.Join(dir, "product_variables.bzl"), []byte(strings.Join(bzl, "\n")), 0644)
if err != nil {
@@ -1952,3 +1982,8 @@ func (c *config) ApexBootJars() ConfiguredJarList {
func (c *config) RBEWrapper() string {
return c.GetenvWithDefault("RBE_WRAPPER", remoteexec.DefaultWrapperPath)
}
+
+// UseHostMusl returns true if the host target has been configured to build against musl libc.
+func (c *config) UseHostMusl() bool {
+ return Bool(c.productVariables.HostMusl)
+}