aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Hubbard <dsp@google.com>2023-02-27 13:33:16 -0800
committerDavid Hubbard <dsp@google.com>2023-02-27 13:33:16 -0800
commitcdd5c80b94f89be8282b8bd43760239516c1c5ac (patch)
treeb2d76addefb2564b3dc53e5ba989dd6001e3925a
parent367e81abfaac84d9a821a5c412d3709bb4f28d8a (diff)
downloadninja-cdd5c80b94f89be8282b8bd43760239516c1c5ac.tar.gz
Bugfix for http://aosp/2319430 in subninjas
http://aosp/2319309 "Prework for --experimentalEnvvar" added the cmdEnviron_ member to every Scope. But the simple path only initialized it to NULL. While `subninja chdir` was correct, the more generic `subninja` (not a chdir) would get a NULL cmdEnviron_ leading to it omitting any `envvar` statements. This fixes the case where: 1. build.ninja with a "subninja chdir foo" *and* "envvar" 2. foo/build.ninja with a "subninja bar/build.ninja" 3. foo/bar/build.ninja builds something that depends on "envvar" Change-Id: Ie260ea5c728bcd07b5251c322084e52382819f0a
-rw-r--r--src/eval_env.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/eval_env.h b/src/eval_env.h
index d1f486d..51ef3e2 100644
--- a/src/eval_env.h
+++ b/src/eval_env.h
@@ -151,7 +151,7 @@ struct Scope {
// Simple constructor for a new Scope.
Scope(ScopePosition parent)
: parent_(parent)
- , cmdEnviron_(NULL)
+ , cmdEnviron_(parent.scope ? parent.scope->cmdEnviron_ : NULL)
, chdirParent_(nullptr)
, chdir_(parent.scope ? parent.scope->chdir_ : "") {}