Revert "Revert "Ensure environment dependencies are correct""

This reverts commit 4068a5db6c60d890e4d49379d600fd34ee94fdec.

Now the Mac xcode-select and xcrun goes through Config.HostSystemTool,
which will grab $PATH through Config.Getenv

Test: m -j (on mac)
Change-Id: I2632c4fdb2ec961e59944cf02ff165e0fd3c869d
diff --git a/android/config.go b/android/config.go
index 8be16cf..b83ffd4 100644
--- a/android/config.go
+++ b/android/config.go
@@ -249,6 +249,20 @@
 	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 @@
 		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