diff options
author | Dan Willemsen <dwillemsen@google.com> | 2017-05-16 00:37:56 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-05-16 00:37:56 +0000 |
commit | 2e1859089aee8ad85cff79bab9ef11d478a9e09f (patch) | |
tree | c4dc1cdf4d359031697f9804c63ea3ee6149d747 /android | |
parent | c4492e364e3c081615e4a7178e8a9f8764ef0c45 (diff) | |
parent | 7a14f200f9192cefee5ad61248d1d41f3ec95135 (diff) | |
download | build_soong-2e1859089aee8ad85cff79bab9ef11d478a9e09f.tar.gz build_soong-2e1859089aee8ad85cff79bab9ef11d478a9e09f.tar.bz2 build_soong-2e1859089aee8ad85cff79bab9ef11d478a9e09f.zip |
Merge "Revert "Revert "Ensure environment dependencies are correct""" am: 04b830f133 am: 7ed05d634d
am: 7a14f200f9
Change-Id: I6268805e2cff406b0681e7277857ccf4eae2496e
Diffstat (limited to 'android')
-rw-r--r-- | android/config.go | 16 | ||||
-rw-r--r-- | android/env.go | 16 |
2 files changed, 31 insertions, 1 deletions
diff --git a/android/config.go b/android/config.go index 8be16cfd..b83ffd4a 100644 --- a/android/config.go +++ b/android/config.go @@ -249,6 +249,20 @@ func (c *config) BlueprintToolLocation() string { return filepath.Join(c.buildDir, "host", c.PrebuiltOS(), "bin") } +// HostSystemTool looks for non-hermetic tools from the system we're running on. +// Generally shouldn't be used, but useful to find the XCode SDK, etc. +func (c *config) HostSystemTool(name string) string { + for _, dir := range filepath.SplitList(c.Getenv("PATH")) { + path := filepath.Join(dir, name) + if s, err := os.Stat(path); err != nil { + continue + } else if m := s.Mode(); !s.IsDir() && m&0111 != 0 { + return path + } + } + return name +} + // PrebuiltOS returns the name of the host OS used in prebuilts directories func (c *config) PrebuiltOS() string { switch runtime.GOOS { @@ -289,7 +303,7 @@ func (c *config) Getenv(key string) string { if c.envFrozen { panic("Cannot access new environment variables after envdeps are frozen") } - val = os.Getenv(key) + val, _ = originalEnv[key] c.envDeps[key] = val } return val diff --git a/android/env.go b/android/env.go index c7409e87..ec5794e3 100644 --- a/android/env.go +++ b/android/env.go @@ -15,6 +15,9 @@ package android import ( + "os" + "strings" + "android/soong/env" "github.com/google/blueprint" @@ -27,6 +30,19 @@ import ( // compare the contents of the environment variables, rewriting the file if necessary to cause // a manifest regeneration. +var originalEnv map[string]string + +func init() { + originalEnv = make(map[string]string) + for _, env := range os.Environ() { + idx := strings.IndexRune(env, '=') + if idx != -1 { + originalEnv[env[:idx]] = env[idx+1:] + } + } + os.Clearenv() +} + func EnvSingleton() blueprint.Singleton { return &envSingleton{} } |