summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-03-12 14:07:11 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-03-12 14:07:11 +0200
commitb82ba002326f1c541876acc7efec650bac7f6403 (patch)
tree8905ed8078665ac826c350f9ea7cda77001d93ca
parente031550cf9f15bd838517471604d058d2634687e (diff)
downloadbuild2-b82ba002326f1c541876acc7efec650bac7f6403.zip
build2-b82ba002326f1c541876acc7efec650bac7f6403.tar.gz
build2-b82ba002326f1c541876acc7efec650bac7f6403.tar.xz
Diagnose out of project inclusion
-rw-r--r--build2/parser.cxx19
1 files changed, 14 insertions, 5 deletions
diff --git a/build2/parser.cxx b/build2/parser.cxx
index ef6691d..3acff37 100644
--- a/build2/parser.cxx
+++ b/build2/parser.cxx
@@ -1293,8 +1293,11 @@ namespace build2
const dir_path* opb (pbase_);
switch_scope (out_base);
- // Use the new scope's src_base to get absolute buildfile path
- // if it is relative.
+ if (root_ == nullptr)
+ fail (l) << "out of project include from " << out_base;
+
+ // Use the new scope's src_base to get absolute buildfile path if it is
+ // relative.
//
if (p.relative ())
p = scope_->src_path () / p.leaf ();
@@ -5152,12 +5155,18 @@ namespace build2
auto p (build2::switch_scope (*root_, d));
scope_ = &p.first;
- pbase_ = scope_->src_path_;
+ pbase_ = scope_->src_path_ != nullptr ? scope_->src_path_ : &d;
- if (p.second != nullptr && p.second != root_)
+ if (p.second != root_)
{
root_ = p.second;
- l5 ([&]{trace << "switching to root scope " << root_->out_path ();});
+ l5 ([&]
+ {
+ if (root_ != nullptr)
+ trace << "switching to root scope " << root_->out_path ();
+ else
+ trace << "switching to out of project scope";
+ });
}
}