aboutsummaryrefslogtreecommitdiffstats
path: root/android/config.go
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2016-11-23 16:52:04 -0800
committerColin Cross <ccross@android.com>2016-11-29 15:29:34 -0800
commit99d7c2300646e9964c17dfec4692c336947f23e8 (patch)
treee93d7e3dbbb901f0f0b2548ea2a2d36b5164bb36 /android/config.go
parentbba99041dbe70a590f6c997bd488ae092fc0902d (diff)
downloadbuild_soong-99d7c2300646e9964c17dfec4692c336947f23e8.tar.gz
build_soong-99d7c2300646e9964c17dfec4692c336947f23e8.tar.bz2
build_soong-99d7c2300646e9964c17dfec4692c336947f23e8.zip
Provide config helpers for environment variables
Add GetenvWithDefault, IsEnvTrue, and IsEnvFalse helpers to Config. Test: m -j checkbuild Change-Id: Id855e5349115eb2a18b2e73cfd1bd84b5874ff93
Diffstat (limited to 'android/config.go')
-rw-r--r--android/config.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/android/config.go b/android/config.go
index fdc7375e..4a59bade 100644
--- a/android/config.go
+++ b/android/config.go
@@ -291,6 +291,24 @@ func (c *config) Getenv(key string) string {
return val
}
+func (c *config) GetenvWithDefault(key string, defaultValue string) string {
+ ret := c.Getenv(key)
+ if ret == "" {
+ return defaultValue
+ }
+ return ret
+}
+
+func (c *config) IsEnvTrue(key string) bool {
+ value := c.Getenv(key)
+ return value == "1" || value == "y" || value == "yes" || value == "on" || value == "true"
+}
+
+func (c *config) IsEnvFalse(key string) bool {
+ value := c.Getenv(key)
+ return value == "0" || value == "n" || value == "no" || value == "off" || value == "false"
+}
+
func (c *config) EnvDeps() map[string]string {
c.envLock.Lock()
c.envFrozen = true