aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbuild2/parser.cxx18
-rw-r--r--libbuild2/parser.hxx14
2 files changed, 19 insertions, 13 deletions
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index 84b6366..fd7c10e 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -247,7 +247,6 @@ namespace build2
{
pre_parse_ = false;
attributes_.clear ();
- imported_ = false;
condition_ = nullopt;
default_target_ = nullptr;
peeked_ = false;
@@ -2372,9 +2371,7 @@ namespace build2
// Diagnose conditional prerequisites. Note that we want to diagnose this
// even if pns is empty (think empty variable expansion; the literal "no
- // prerequisites" case is handled elsewhere). We also want to omit this
- // check for imported buildfiles (export stub can reasonably wrap loading
- // of a buildfile in a condition).
+ // prerequisites" case is handled elsewhere).
//
// @@ TMP For now we only do it during the dist meta-operation. In the
// future we should tighten this to any meta-operation provided
@@ -2385,7 +2382,6 @@ namespace build2
// rewrite (cli.cxx{} is not always registered).
//
if (condition_ &&
- !imported_ &&
ctx->current_mif != nullptr &&
ctx->current_mif->id == dist_id)
{
@@ -2918,6 +2914,18 @@ namespace build2
continue;
}
+ // Clear/restore if/switch location.
+ //
+ // We do it here but not in parse_source since the included buildfile is
+ // in a sense expected to be a standalone entity (think a file included
+ // from an export stub).
+ //
+ auto g = make_guard ([this, old = condition_] () mutable
+ {
+ condition_ = old;
+ });
+ condition_ = nullopt;
+
try
{
ifdstream ifs (p);
diff --git a/libbuild2/parser.hxx b/libbuild2/parser.hxx
index 61ecd5b..5f762f7 100644
--- a/libbuild2/parser.hxx
+++ b/libbuild2/parser.hxx
@@ -91,12 +91,6 @@ namespace build2
parse_export_stub (istream& is, const path_name& name,
scope& rs, scope& bs)
{
- auto g = make_guard ([this, old = imported_] () mutable
- {
- imported_ = old;
- });
- imported_ = true;
-
parse_buildfile (is, name, &rs, bs);
return move (export_value);
}
@@ -912,8 +906,12 @@ namespace build2
small_vector<attributes, 2> attributes_;
- bool imported_ = false; // True if loaded via export stub.
- optional<location> condition_; // Innermost if/switch (but not in recipe).
+ // Innermost if/switch (but excluding recipes).
+ //
+ // Note also that this is cleared/restored when crossing the include
+ // (but not source) boundary.
+ //
+ optional<location> condition_;
target* default_target_ = nullptr;