aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/scope.ixx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-09-29 08:55:34 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-09-29 08:55:34 +0200
commitf63c0548281015ca1f7d71079c0880e3634063fb (patch)
treecb5cf0690e9d979c7fb98455f6a3320c7f0f53eb /libbuild2/scope.ixx
parent41273da120ef8e4a2bed7576de0532264b042ee1 (diff)
Add notion of bundle amalgamation scope
Diffstat (limited to 'libbuild2/scope.ixx')
-rw-r--r--libbuild2/scope.ixx40
1 files changed, 40 insertions, 0 deletions
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_);