aboutsummaryrefslogtreecommitdiff
path: root/build2/config
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-01-25 15:41:44 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-02-13 12:39:24 +0200
commit88f0780e34116c0441a8d8c58b8a8fd9fde4b1f5 (patch)
tree1240b36211772479dc1220712e0daed4e35ecd85 /build2/config
parent61aa8e2b4bd7849838c04dc1f421c4760d88319f (diff)
Add model mutex, make var_pool const by default
Diffstat (limited to 'build2/config')
-rw-r--r--build2/config/init.cxx8
-rw-r--r--build2/config/operation.cxx37
-rw-r--r--build2/config/utility10
-rw-r--r--build2/config/utility.cxx19
4 files changed, 49 insertions, 25 deletions
diff --git a/build2/config/init.cxx b/build2/config/init.cxx
index d6cbe74..1f0b391 100644
--- a/build2/config/init.cxx
+++ b/build2/config/init.cxx
@@ -38,6 +38,8 @@ namespace build2
rs.meta_operations.insert (configure_id, configure);
rs.meta_operations.insert (disfigure_id, disfigure);
+ auto& vp (var_pool.rw (rs));
+
// Load config.build if one exists.
//
// Note that we have to do this during bootstrap since the order in
@@ -45,7 +47,7 @@ namespace build2
// possible that some module which needs the configuration will get
// called first.
//
- const variable& c_v (var_pool.insert<uint64_t> ("config.version"));
+ const variable& c_v (vp.insert<uint64_t> ("config.version"));
// Don't load it if we are disfiguring. This is a bit tricky since the
// build2 core may not yet know it is disfiguring. But we know.
@@ -68,7 +70,7 @@ namespace build2
{
// Assume missing version is 0.
//
- auto p (extract_variable (f, c_v.name.c_str ()));
+ auto p (extract_variable (f, c_v));
uint64_t v (p.second ? cast<uint64_t> (p.first) : 0);
if (v != module::version)
@@ -80,7 +82,7 @@ namespace build2
<< out_root;
}
- source (f, rs, rs);
+ source (rs, rs, f);
}
}
}
diff --git a/build2/config/operation.cxx b/build2/config/operation.cxx
index f74136c..175338a 100644
--- a/build2/config/operation.cxx
+++ b/build2/config/operation.cxx
@@ -82,7 +82,7 @@ namespace build2
ofs << "config.version = " << module::version << endl;
- if (auto l = root.vars["amalgamation"])
+ if (auto l = root.vars[var_amalgamation])
{
const dir_path& d (cast<dir_path> (l));
@@ -325,7 +325,7 @@ namespace build2
// Configure subprojects that have been loaded.
//
- if (auto l = root.vars["subprojects"])
+ if (auto l = root.vars[var_subprojects])
{
for (auto p: cast<subprojects> (l))
{
@@ -345,13 +345,13 @@ namespace build2
}
static void
- configure_match (action, action_targets&)
+ configure_match (ulock&, action, action_targets&)
{
// Don't match anything -- see execute ().
}
static void
- configure_execute (action a, const action_targets& ts, bool)
+ configure_execute (ulock& ml, action a, const action_targets& ts, bool)
{
// Match rules to configure every operation supported by each
// project. Note that we are not calling operation_pre/post()
@@ -360,6 +360,10 @@ namespace build2
//
set<scope*> projects;
+ // Relock for shared access.
+ //
+ ml.unlock ();
+
for (void* v: ts)
{
target& t (*static_cast<target*> (v));
@@ -368,6 +372,9 @@ namespace build2
if (rs == nullptr)
fail << "out of project target " << t;
+ slock sl (*ml.mutex ());
+ model_lock = &sl; // @@ Guard?
+
for (operations::size_type id (default_id + 1); // Skip default_id
id < rs->operations.size ();
++id)
@@ -379,11 +386,15 @@ namespace build2
set_current_oif (*oif);
dependency_count = 0;
- match (action (configure_id, id), t);
+ match (sl, action (configure_id, id), t);
}
+ model_lock = nullptr;
+
configure_project (a, *rs, projects);
}
+
+ ml.lock ();
}
const meta_operation_info configure {
@@ -414,8 +425,9 @@ namespace build2
}
static void
- disfigure_load (const path& bf,
+ disfigure_load (ulock&,
scope&,
+ const path& bf,
const dir_path&,
const dir_path&,
const location&)
@@ -425,7 +437,8 @@ namespace build2
}
static void
- disfigure_search (scope& root,
+ disfigure_search (ulock&,
+ scope& root,
const target_key&,
const location&,
action_targets& ts)
@@ -436,7 +449,9 @@ namespace build2
}
static void
- disfigure_match (action, action_targets&) {}
+ disfigure_match (ulock&, action, action_targets&)
+ {
+ }
static bool
disfigure_project (action a, scope& root, set<scope*>& projects)
@@ -457,7 +472,7 @@ namespace build2
// Disfigure subprojects. Since we don't load buildfiles during
// disfigure, we do it for all known subprojects.
//
- if (auto l = root.vars["subprojects"])
+ if (auto l = root.vars[var_subprojects])
{
for (auto p: cast<subprojects> (l))
{
@@ -475,7 +490,7 @@ namespace build2
{
bootstrap_out (nroot);
- value& val (nroot.assign ("src_root"));
+ value& val (nroot.assign (var_src_root));
if (!val)
val = is_src_root (out_nroot) ? out_nroot : (src_root / pd);
@@ -550,7 +565,7 @@ namespace build2
}
static void
- disfigure_execute (action a, const action_targets& ts, bool quiet)
+ disfigure_execute (ulock&, action a, const action_targets& ts, bool quiet)
{
tracer trace ("disfigure_execute");
diff --git a/build2/config/utility b/build2/config/utility
index 6c18715..e4e463d 100644
--- a/build2/config/utility
+++ b/build2/config/utility
@@ -44,6 +44,8 @@ namespace build2
bool override = false,
uint64_t save_flags = 0);
+ // Note that the variable is expected to have already been registered.
+ //
template <typename T>
inline pair<lookup, bool>
required (scope& root,
@@ -76,6 +78,8 @@ namespace build2
pair<lookup, bool>
omitted (scope& root, const variable&);
+ // Note that the variable is expected to have already been registered.
+ //
inline pair<lookup, bool>
omitted (scope& root, const string& name)
{
@@ -91,10 +95,12 @@ namespace build2
lookup
optional (scope& root, const variable&);
+ // Note that the variable is expected to have already been registered.
+ //
inline lookup
- optional (scope& root, const string& var)
+ optional (scope& root, const string& name)
{
- return optional (root, var_pool[var]);
+ return optional (root, var_pool[name]);
}
// Check whether there are any variables specified from the config
diff --git a/build2/config/utility.cxx b/build2/config/utility.cxx
index 7a3fa9c..7db4555 100644
--- a/build2/config/utility.cxx
+++ b/build2/config/utility.cxx
@@ -72,9 +72,10 @@ namespace build2
// any original values, they will be "visible"; see find_override() for
// details.
//
+ const variable& vns (var_pool.rw (r).insert (ns));
for (scope* s (&r); s != nullptr; s = s->parent_scope ())
{
- for (auto p (s->vars.find_namespace (ns));
+ for (auto p (s->vars.find_namespace (vns));
p.first != p.second;
++p.first)
{
@@ -92,30 +93,30 @@ namespace build2
}
bool
- unconfigured (scope& root, const string& ns)
+ unconfigured (scope& rs, const string& ns)
{
// Note: not overridable.
//
- const variable& var (var_pool.insert<bool> (ns + ".configured"));
+ const variable& var (var_pool.rw (rs).insert<bool> (ns + ".configured"));
if (current_mif->id == configure_id)
- save_variable (root, var);
+ save_variable (rs, var);
- auto l (root[var]); // Include inherited values.
+ auto l (rs[var]); // Include inherited values.
return l && !cast<bool> (l);
}
bool
- unconfigured (scope& root, const string& ns, bool v)
+ unconfigured (scope& rs, const string& ns, bool v)
{
// Note: not overridable.
//
- const variable& var (var_pool.insert<bool> (ns + ".configured"));
+ const variable& var (var_pool.rw (rs).insert<bool> (ns + ".configured"));
if (current_mif->id == configure_id)
- save_variable (root, var);
+ save_variable (rs, var);
- value& x (root.assign (var));
+ value& x (rs.assign (var));
if (x.null || cast<bool> (x) != !v)
{