Add option to limit environment variables given to ninja am: e333635983
am: 29b8eb2fd0
Change-Id: I2a3a8da1c800cd1892eacfc25108b57cc414727b
This commit is contained in:
commit
92afa2da33
3 changed files with 79 additions and 4 deletions
|
@ -55,8 +55,9 @@ type configImpl struct {
|
||||||
|
|
||||||
pdkBuild bool
|
pdkBuild bool
|
||||||
|
|
||||||
brokenDupRules bool
|
brokenDupRules bool
|
||||||
brokenUsesNetwork bool
|
brokenUsesNetwork bool
|
||||||
|
brokenNinjaEnvVars []string
|
||||||
|
|
||||||
pathReplaced bool
|
pathReplaced bool
|
||||||
}
|
}
|
||||||
|
@ -907,6 +908,14 @@ func (c *configImpl) BuildBrokenUsesNetwork() bool {
|
||||||
return c.brokenUsesNetwork
|
return c.brokenUsesNetwork
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *configImpl) SetBuildBrokenNinjaUsesEnvVars(val []string) {
|
||||||
|
c.brokenNinjaEnvVars = val
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *configImpl) BuildBrokenNinjaUsesEnvVars() []string {
|
||||||
|
return c.brokenNinjaEnvVars
|
||||||
|
}
|
||||||
|
|
||||||
func (c *configImpl) SetTargetDeviceDir(dir string) {
|
func (c *configImpl) SetTargetDeviceDir(dir string) {
|
||||||
c.targetDeviceDir = dir
|
c.targetDeviceDir = dir
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,6 +216,9 @@ func runMakeProductConfig(ctx Context, config Config) {
|
||||||
// Whether to enable the network during the build
|
// Whether to enable the network during the build
|
||||||
"BUILD_BROKEN_USES_NETWORK",
|
"BUILD_BROKEN_USES_NETWORK",
|
||||||
|
|
||||||
|
// Extra environment variables to be exported to ninja
|
||||||
|
"BUILD_BROKEN_NINJA_USES_ENV_VARS",
|
||||||
|
|
||||||
// Not used, but useful to be in the soong.log
|
// Not used, but useful to be in the soong.log
|
||||||
"BOARD_VNDK_VERSION",
|
"BOARD_VNDK_VERSION",
|
||||||
|
|
||||||
|
@ -284,4 +287,5 @@ func runMakeProductConfig(ctx Context, config Config) {
|
||||||
config.SetPdkBuild(make_vars["TARGET_BUILD_PDK"] == "true")
|
config.SetPdkBuild(make_vars["TARGET_BUILD_PDK"] == "true")
|
||||||
config.SetBuildBrokenDupRules(make_vars["BUILD_BROKEN_DUP_RULES"] == "true")
|
config.SetBuildBrokenDupRules(make_vars["BUILD_BROKEN_DUP_RULES"] == "true")
|
||||||
config.SetBuildBrokenUsesNetwork(make_vars["BUILD_BROKEN_USES_NETWORK"] == "true")
|
config.SetBuildBrokenUsesNetwork(make_vars["BUILD_BROKEN_USES_NETWORK"] == "true")
|
||||||
|
config.SetBuildBrokenNinjaUsesEnvVars(strings.Fields(make_vars["BUILD_BROKEN_NINJA_USES_ENV_VARS"]))
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -65,8 +66,6 @@ func runNinja(ctx Context, config Config) {
|
||||||
cmd.Environment.AppendFromKati(config.KatiEnvFile())
|
cmd.Environment.AppendFromKati(config.KatiEnvFile())
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Environment.Set("DIST_DIR", config.DistDir())
|
|
||||||
|
|
||||||
// Allow both NINJA_ARGS and NINJA_EXTRA_ARGS, since both have been
|
// Allow both NINJA_ARGS and NINJA_EXTRA_ARGS, since both have been
|
||||||
// used in the past to specify extra ninja arguments.
|
// used in the past to specify extra ninja arguments.
|
||||||
if extra, ok := cmd.Environment.Get("NINJA_ARGS"); ok {
|
if extra, ok := cmd.Environment.Get("NINJA_ARGS"); ok {
|
||||||
|
@ -85,6 +84,69 @@ func runNinja(ctx Context, config Config) {
|
||||||
ninjaHeartbeatDuration = overrideDuration
|
ninjaHeartbeatDuration = overrideDuration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filter the environment, as ninja does not rebuild files when environment variables change.
|
||||||
|
//
|
||||||
|
// Anything listed here must not change the output of rules/actions when the value changes,
|
||||||
|
// otherwise incremental builds may be unsafe. Vars explicitly set to stable values
|
||||||
|
// elsewhere in soong_ui are fine.
|
||||||
|
//
|
||||||
|
// For the majority of cases, either Soong or the makefiles should be replicating any
|
||||||
|
// necessary environment variables in the command line of each action that needs it.
|
||||||
|
if cmd.Environment.IsFalse("ALLOW_NINJA_ENV") {
|
||||||
|
cmd.Environment.Allow(append([]string{
|
||||||
|
"ASAN_SYMBOLIZER_PATH",
|
||||||
|
"HOME",
|
||||||
|
"JAVA_HOME",
|
||||||
|
"LANG",
|
||||||
|
"LC_MESSAGES",
|
||||||
|
"OUT_DIR",
|
||||||
|
"PATH",
|
||||||
|
"PWD",
|
||||||
|
"PYTHONDONTWRITEBYTECODE",
|
||||||
|
"TMPDIR",
|
||||||
|
"USER",
|
||||||
|
|
||||||
|
// TODO: remove these carefully
|
||||||
|
"TARGET_BUILD_APPS",
|
||||||
|
"TARGET_BUILD_VARIANT",
|
||||||
|
"TARGET_PRODUCT",
|
||||||
|
|
||||||
|
// Goma -- gomacc may not need all of these
|
||||||
|
"GOMA_DIR",
|
||||||
|
"GOMA_DISABLED",
|
||||||
|
"GOMA_FAIL_FAST",
|
||||||
|
"GOMA_FALLBACK",
|
||||||
|
"GOMA_GCE_SERVICE_ACCOUNT",
|
||||||
|
"GOMA_TMP_DIR",
|
||||||
|
"GOMA_USE_LOCAL",
|
||||||
|
|
||||||
|
// RBE client
|
||||||
|
"FLAG_exec_root",
|
||||||
|
"FLAG_exec_strategy",
|
||||||
|
"FLAG_invocation_id",
|
||||||
|
"FLAG_log_dir",
|
||||||
|
"FLAG_platform",
|
||||||
|
"FLAG_server_address",
|
||||||
|
|
||||||
|
// ccache settings
|
||||||
|
"CCACHE_COMPILERCHECK",
|
||||||
|
"CCACHE_SLOPPINESS",
|
||||||
|
"CCACHE_BASEDIR",
|
||||||
|
"CCACHE_CPP2",
|
||||||
|
}, config.BuildBrokenNinjaUsesEnvVars()...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Environment.Set("DIST_DIR", config.DistDir())
|
||||||
|
cmd.Environment.Set("SHELL", "/bin/bash")
|
||||||
|
|
||||||
|
ctx.Verboseln("Ninja environment: ")
|
||||||
|
envVars := cmd.Environment.Environ()
|
||||||
|
sort.Strings(envVars)
|
||||||
|
for _, envVar := range envVars {
|
||||||
|
ctx.Verbosef(" %s", envVar)
|
||||||
|
}
|
||||||
|
|
||||||
// Poll the ninja log for updates; if it isn't updated enough, then we want to show some diagnostics
|
// Poll the ninja log for updates; if it isn't updated enough, then we want to show some diagnostics
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
defer close(done)
|
defer close(done)
|
||||||
|
|
Loading…
Reference in a new issue