Provide config helpers for environment variables

am: 99d7c23006

Change-Id: I982ed5896d997913b8b3f0d947e92dd3eb9814be
This commit is contained in:
Colin Cross 2016-11-30 05:14:29 +00:00 committed by android-build-merger
commit 8c093e5034

View file

@ -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