diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-08-07 03:01:24 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-08-07 03:01:24 +0000 |
commit | 83aa1c689b4e1b193ea636701293afda3e5ec8c2 (patch) | |
tree | bfc7b29ff200d81db6a301e4bb8d8b66ef53a327 | |
parent | b89de4afa1c067f44c4952da484164f5f4a88d5a (diff) | |
parent | fe1d6c535c3aa92c2c12db9590ab8a8fae9bb9cd (diff) |
Snap for 7620055 from fe1d6c535c3aa92c2c12db9590ab8a8fae9bb9cd to sc-release
Change-Id: I7a2bfc3feaf0ceeffc2ad60cc00cf79c1cefb2dc
-rw-r--r-- | apex/prebuilt.go | 4 | ||||
-rw-r--r-- | cmd/soong_ui/main.go | 40 |
2 files changed, 40 insertions, 4 deletions
diff --git a/apex/prebuilt.go b/apex/prebuilt.go index 30fd359b5..c567fe012 100644 --- a/apex/prebuilt.go +++ b/apex/prebuilt.go @@ -133,10 +133,6 @@ func (p *prebuiltCommon) checkForceDisable(ctx android.ModuleContext) bool { // to build the prebuilts themselves. forceDisable = forceDisable || ctx.Config().UnbundledBuild() - // Force disable the prebuilts when coverage is enabled. - forceDisable = forceDisable || ctx.DeviceConfig().NativeCoverageEnabled() - forceDisable = forceDisable || ctx.Config().IsEnvTrue("EMMA_INSTRUMENT") - // b/137216042 don't use prebuilts when address sanitizer is on, unless the prebuilt has a sanitized source sanitized := ctx.Module().(sanitizedPrebuilt) forceDisable = forceDisable || (android.InList("address", ctx.Config().SanitizeDevice()) && !sanitized.hasSanitizedSource("address")) diff --git a/cmd/soong_ui/main.go b/cmd/soong_ui/main.go index 22922c0e5..8bcc71202 100644 --- a/cmd/soong_ui/main.go +++ b/cmd/soong_ui/main.go @@ -16,6 +16,7 @@ package main import ( "context" + "encoding/json" "flag" "fmt" "io/ioutil" @@ -34,6 +35,11 @@ import ( "android/soong/ui/tracer" ) +const ( + configDir = "vendor/google/tools/soong_config" + jsonSuffix = "json" +) + // A command represents an operation to be executed in the soong build // system. type command struct { @@ -110,6 +116,34 @@ func inList(s string, list []string) bool { return indexList(s, list) != -1 } +func loadEnvConfig() error { + bc := os.Getenv("ANDROID_BUILD_ENVIRONMENT_CONFIG") + if bc == "" { + return nil + } + cfgFile := filepath.Join(os.Getenv("TOP"), configDir, fmt.Sprintf("%s.%s", bc, jsonSuffix)) + + envVarsJSON, err := ioutil.ReadFile(cfgFile) + if err != nil { + fmt.Fprintf(os.Stderr, "\033[33mWARNING:\033[0m failed to open config file %s: %s\n", cfgFile, err.Error()) + return nil + } + + var envVars map[string]map[string]string + if err := json.Unmarshal(envVarsJSON, &envVars); err != nil { + return fmt.Errorf("env vars config file: %s did not parse correctly: %s", cfgFile, err.Error()) + } + for k, v := range envVars["env"] { + if os.Getenv(k) != "" { + continue + } + if err := os.Setenv(k, v); err != nil { + return err + } + } + return nil +} + // Main execution of soong_ui. The command format is as follows: // // soong_ui <command> [<arg 1> <arg 2> ... <arg n>] @@ -173,6 +207,12 @@ func main() { config := c.config(buildCtx, args...) + if err := loadEnvConfig(); err != nil { + fmt.Fprintf(os.Stderr, "failed to parse env config files: %v", err) + os.Exit(1) + } + + build.SetupOutDir(buildCtx, config) if config.UseBazel() && config.Dist() { |