aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/config/module.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-08-18 08:04:07 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-08-18 08:04:07 +0200
commitb2df0b0663d0537dd3b4f2d28d145ccd90417cab (patch)
treeb58ff44bfa5a8423721d6b865541a2e3a3d27d60 /libbuild2/config/module.hxx
parent5521a0edd9a2ba8429f7d2e48f754c9d6f66cc3b (diff)
Add ability to mark config.* variables as "unsaved" (always transient)
Diffstat (limited to 'libbuild2/config/module.hxx')
-rw-r--r--libbuild2/config/module.hxx25
1 files changed, 15 insertions, 10 deletions
diff --git a/libbuild2/config/module.hxx b/libbuild2/config/module.hxx
index 96220ac..857a30c 100644
--- a/libbuild2/config/module.hxx
+++ b/libbuild2/config/module.hxx
@@ -25,12 +25,13 @@ namespace build2
// config.* variables and their "save flags" (see save_variable()) that
// are used (as opposed to just being specified) in this configuration.
// Populated by the config utility functions (required(), optional()) and
- // saved in the order populated.
+ // saved in the order populated. If flags are absent, then this variable
+ // was marked as "unsaved" (always transient).
//
struct saved_variable
{
reference_wrapper<const variable> var;
- uint64_t flags;
+ optional<uint64_t> flags;
};
struct saved_variables: vector<saved_variable>
@@ -75,10 +76,10 @@ namespace build2
// Return true if variable/module were newly inserted.
//
bool
- save_variable (const variable&, uint64_t flags = 0);
+ save_variable (const variable&, optional<uint64_t> flags);
static void
- save_variable (scope&, const variable&, uint64_t);
+ save_variable (scope&, const variable&, optional<uint64_t>);
bool
save_module (const char* name, int prio = 0);
@@ -86,14 +87,18 @@ namespace build2
static void
save_module (scope&, const char*, int);
- // Return true if the variable is already saved.
- //
- bool
- saved (const variable& var)
+ const saved_variable*
+ find_variable (const variable& var)
{
auto i (saved_modules.find_sup (var.name));
- return i != saved_modules.end () &&
- i->second.find (var) != i->second.end ();
+ if (i != saved_modules.end ())
+ {
+ auto j (i->second.find (var));
+ if (j != i->second.end ())
+ return &*j;
+ }
+
+ return nullptr;
}
// Configure/disfigure hooks.