Apply kati output rewriting to dumpvars
This way we strip out ANSI codes when using dumb terminals. It's likely overkill to use katiRewriteOutput, but we should rarely see any output on stderr while dumping variables. This also lets us turn on kati_stats. Bug: 71729611 Test: lunch missing-eng (colored error) Test: lunch missing-eng 2>&1 | cat (non-colored) Test: TERM=dumb lunch missing-eng (non-colored) Change-Id: Ic63fd42d82a4a64e5c68aecd9ae0f242a0d703f1
This commit is contained in:
@@ -42,6 +42,7 @@ func dumpMakeVars(ctx Context, config Config, goals, vars []string, write_soong_
|
||||
config.PrebuiltBuildTool("ckati"),
|
||||
"-f", "build/make/core/config.mk",
|
||||
"--color_warnings",
|
||||
"--kati_stats",
|
||||
"dump-many-vars",
|
||||
"MAKECMDGOALS="+strings.Join(goals, " "))
|
||||
cmd.Environment.Set("CALLED_FROM_SETUP", "true")
|
||||
@@ -51,15 +52,19 @@ func dumpMakeVars(ctx Context, config Config, goals, vars []string, write_soong_
|
||||
}
|
||||
cmd.Environment.Set("DUMP_MANY_VARS", strings.Join(vars, " "))
|
||||
cmd.Sandbox = dumpvarsSandbox
|
||||
// TODO: error out when Stderr contains any content
|
||||
cmd.Stderr = ctx.Stderr()
|
||||
output, err := cmd.Output()
|
||||
output := bytes.Buffer{}
|
||||
cmd.Stdout = &output
|
||||
pipe, err := cmd.StderrPipe()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
ctx.Fatalln("Error getting output pipe for ckati:", err)
|
||||
}
|
||||
cmd.StartOrFatal()
|
||||
// TODO: error out when Stderr contains any content
|
||||
katiRewriteOutput(ctx, pipe)
|
||||
cmd.WaitOrFatal()
|
||||
|
||||
ret := make(map[string]string, len(vars))
|
||||
for _, line := range strings.Split(string(output), "\n") {
|
||||
for _, line := range strings.Split(output.String(), "\n") {
|
||||
if len(line) == 0 {
|
||||
continue
|
||||
}
|
||||
|
Reference in New Issue
Block a user