From 02d902cb8e5e69b123fcdf170e5eeb9ca5605304 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 15 May 2020 12:11:30 +0200 Subject: Amalgamation cutoff support Now a project that disables amalgamation will not logically "see" an outer project even if it's physically inside its scope. --- libbuild2/scope.hxx | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'libbuild2/scope.hxx') diff --git a/libbuild2/scope.hxx b/libbuild2/scope.hxx index e7c2db7..473dde8 100644 --- a/libbuild2/scope.hxx +++ b/libbuild2/scope.hxx @@ -46,18 +46,21 @@ namespace build2 const dir_path* src_path_ = nullptr; bool - root () const {return root_ == this;} + root () const; - scope* parent_scope () {return parent_;} - const scope* parent_scope () const {return parent_;} + // Note that the *_scope() functions reaturn "logical" parent/root/etc + // scopes, taking into account the project's var_amalgamation value. + + scope* parent_scope (); + const scope* parent_scope () const; // Root scope of this scope or NULL if this scope is not (yet) in any // (known) project. Note that if the scope itself is root, then this // function return this. To get to the outer root, query the root scope of // the parent. // - scope* root_scope () {return root_;} - const scope* root_scope () const {return root_;} + scope* root_scope (); + const scope* root_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. @@ -413,6 +416,11 @@ namespace build2 public: struct root_extra_type { + // This project's amalgamation (var_amalgamation value). Absent means it + // is not yet determined. NULL means amalgamation is disabled. + // + optional amalgamation; + bool altn; // True if using alternative build file/directory naming. // Build file/directory naming scheme used by this project. @@ -506,6 +514,14 @@ namespace build2 scope (context& c, bool global) : ctx (c), vars (c, global), target_vars (c, global) {} + // Return true if this root scope can be amalgamated. + // + bool + amalgamatable () const; + + // Note that these values represent "physical" scoping relationships not + // taking into account the project's var_amalgamation value. + // scope* parent_; scope* root_; scope* strong_ = nullptr; // Only set on root scopes. -- cgit v1.1