From f63c0548281015ca1f7d71079c0880e3634063fb Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 29 Sep 2021 08:55:34 +0200 Subject: Add notion of bundle amalgamation scope --- libbuild2/scope.ixx | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'libbuild2/scope.ixx') diff --git a/libbuild2/scope.ixx b/libbuild2/scope.ixx index 01d239b..c8214f6 100644 --- a/libbuild2/scope.ixx +++ b/libbuild2/scope.ixx @@ -65,6 +65,46 @@ namespace build2 } inline scope* scope:: + bundle_scope () + { + if (auto r = root_) + { + for (auto s (r), a (strong_scope ()); s != a; ) + { + s = s->parent_scope ()->root_scope (); + + if (s->root_extra != nullptr && + s->root_extra->project && + *s->root_extra->project != nullptr && + !(*s->root_extra->project)->empty ()) + r = s; // Last named. + } + + return r; + } + } + + inline const scope* scope:: + bundle_scope () const + { + if (const auto* r = root_) + { + for (auto s (r), a (strong_scope ()); s != a; ) + { + s = s->parent_scope ()->root_scope (); + + if (s->root_extra != nullptr && + s->root_extra->project && + *s->root_extra->project != nullptr && + !(*s->root_extra->project)->empty ()) + r = s; // Last named. + } + + return r; + } + } + + inline scope* scope:: weak_scope () { scope* r (root_); -- cgit v1.1