aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/install/init.cxx1
-rw-r--r--libbuild2/install/utility.cxx2
-rw-r--r--libbuild2/scope.hxx9
-rw-r--r--libbuild2/scope.ixx40
-rw-r--r--libbuild2/target.hxx6
5 files changed, 58 insertions, 0 deletions
diff --git a/libbuild2/install/init.cxx b/libbuild2/install/init.cxx
index 50c0a05..25dc845 100644
--- a/libbuild2/install/init.cxx
+++ b/libbuild2/install/init.cxx
@@ -421,6 +421,7 @@ namespace build2
// of this scope. Valid values are:
//
// project -- project scope
+ // bundle -- bundle amalgamation
// strong -- strong amalgamation
// weak -- weak amalgamation
// global -- all projects (default)
diff --git a/libbuild2/install/utility.cxx b/libbuild2/install/utility.cxx
index 12215f8..17b1365 100644
--- a/libbuild2/install/utility.cxx
+++ b/libbuild2/install/utility.cxx
@@ -18,6 +18,8 @@ namespace build2
{
if (*s == "project")
return &t.root_scope ();
+ else if (*s == "bundle")
+ return &t.bundle_scope ();
else if (*s == "strong")
return &t.strong_scope ();
else if (*s == "weak")
diff --git a/libbuild2/scope.hxx b/libbuild2/scope.hxx
index 97c7be5..f82db72 100644
--- a/libbuild2/scope.hxx
+++ b/libbuild2/scope.hxx
@@ -69,6 +69,15 @@ namespace build2
const scope* root_scope () const;
// Root scope of the outermost "strong" (source-based) amalgamation of
+ // this scope that has a project name or NULL if this scope is not (yet)
+ // in any (known) project. If there is no bundle amalgamation, then this
+ // function returns the root scope of the project (in other words, in this
+ // case a project is treated as its own bundle, even if it's unnamed).
+ //
+ scope* bundle_scope ();
+ const scope* bundle_scope () const;
+
+ // Root scope of the outermost "strong" (source-based) amalgamation of
// this scope or NULL if this scope is not (yet) in any (known) project.
// If there is no strong amalgamation, then this function returns the root
// scope of the project (in other words, in this case a project is treated
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_);
diff --git a/libbuild2/target.hxx b/libbuild2/target.hxx
index 5f0165e..1c10621 100644
--- a/libbuild2/target.hxx
+++ b/libbuild2/target.hxx
@@ -337,6 +337,12 @@ namespace build2
const scope&
root_scope () const;
+ // Root scope of a bundle amalgamation that contains this target. The
+ // same notes as to root_scope() apply.
+ //
+ const scope&
+ bundle_scope () const {return *root_scope ().bundle_scope ();}
+
// Root scope of a strong amalgamation that contains this target.
// The same notes as to root_scope() apply.
//