Sandbox soong_build by changing to root directory
Store the current working directory and then change to the root directory so that all file accesses must go through helpers in the android package that properly track dependencies. Fixes: 146437378 Test: m checkbuild Change-Id: I12a0f907753fefd1997ab8b4ea2ac331234093cf
This commit is contained in:
@@ -52,6 +52,17 @@ func init() {
|
||||
os.Clearenv()
|
||||
}
|
||||
|
||||
// getenv checks either os.Getenv or originalEnv so that it works before or after the init()
|
||||
// function above. It doesn't add any dependencies on the environment variable, so it should
|
||||
// only be used for values that won't change. For values that might change use ctx.Config().Getenv.
|
||||
func getenv(key string) string {
|
||||
if originalEnv == nil {
|
||||
return os.Getenv(key)
|
||||
} else {
|
||||
return originalEnv[key]
|
||||
}
|
||||
}
|
||||
|
||||
func EnvSingleton() Singleton {
|
||||
return &envSingleton{}
|
||||
}
|
||||
@@ -66,7 +77,12 @@ func (c *envSingleton) GenerateBuildActions(ctx SingletonContext) {
|
||||
return
|
||||
}
|
||||
|
||||
err := env.WriteEnvFile(envFile.String(), envDeps)
|
||||
data, err := env.EnvFileContents(envDeps)
|
||||
if err != nil {
|
||||
ctx.Errorf(err.Error())
|
||||
}
|
||||
|
||||
err = WriteFileToOutputDir(envFile, data, 0666)
|
||||
if err != nil {
|
||||
ctx.Errorf(err.Error())
|
||||
}
|
||||
|
Reference in New Issue
Block a user