aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2015-09-15 23:57:07 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-09-15 23:57:07 +0000
commit8a12ccd282f6d64266bb487d247305df48487f53 (patch)
tree621e229b54539b0c6eb9dddc45b9cf78e646107c /common
parentf8e98b0804ffa468f04fe7ff77c78371e9aba774 (diff)
parente7680babe2f768de10d1babaf90ba5b1f24d1a99 (diff)
downloadbuild_soong-8a12ccd282f6d64266bb487d247305df48487f53.tar.gz
build_soong-8a12ccd282f6d64266bb487d247305df48487f53.tar.bz2
build_soong-8a12ccd282f6d64266bb487d247305df48487f53.zip
Merge "Freeze environment reading after saving deps"
Diffstat (limited to 'common')
-rw-r--r--common/config.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/common/config.go b/common/config.go
index 348d0dbb..f8231f07 100644
--- a/common/config.go
+++ b/common/config.go
@@ -48,8 +48,9 @@ type config struct {
srcDir string // the path of the root source directory
- envLock sync.Mutex
- envDeps map[string]string
+ envLock sync.Mutex
+ envDeps map[string]string
+ envFrozen bool
}
type jsonConfigurable interface {
@@ -178,6 +179,9 @@ func (c *config) Getenv(key string) string {
var exists bool
c.envLock.Lock()
if val, exists = c.envDeps[key]; !exists {
+ if c.envFrozen {
+ panic("Cannot access new environment variables after envdeps are frozen")
+ }
val = os.Getenv(key)
c.envDeps[key] = val
}
@@ -186,6 +190,9 @@ func (c *config) Getenv(key string) string {
}
func (c *config) EnvDeps() map[string]string {
+ c.envLock.Lock()
+ c.envFrozen = true
+ c.envLock.Unlock()
return c.envDeps
}