From 88f0780e34116c0441a8d8c58b8a8fd9fde4b1f5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 25 Jan 2017 15:41:44 +0200 Subject: Add model mutex, make var_pool const by default --- build2/install/init.cxx | 66 ++++++++++++++++++++++++++----------------------- build2/install/rule | 10 ++++---- build2/install/rule.cxx | 20 +++++++-------- build2/install/utility | 18 +++++++++----- 4 files changed, 62 insertions(+), 52 deletions(-) (limited to 'build2/install') diff --git a/build2/install/init.cxx b/build2/install/init.cxx index 8c28dad..122eb54 100644 --- a/build2/install/init.cxx +++ b/build2/install/init.cxx @@ -52,6 +52,8 @@ namespace build2 if (spec) { + // Note: overridable. + // vn = "config.install"; if (!global) { @@ -59,7 +61,7 @@ namespace build2 vn += name; } vn += var; - const variable& vr (var_pool.insert (move (vn), true)); + const variable& vr (var_pool.rw (r).insert (move (vn), true)); l = dv != nullptr ? config::required (r, vr, *dv, override).first @@ -71,10 +73,12 @@ namespace build2 if (global) return; + // Note: not overridable. + // vn = "install."; vn += name; vn += var; - const variable& vr (var_pool.insert (move (vn))); // Not overridable. + const variable& vr (var_pool.rw (r).insert (move (vn))); value& v (r.assign (vr)); @@ -117,7 +121,7 @@ namespace build2 // This one doesn't have config.* value (only set in a buildfile). // if (!global) - var_pool.insert (string ("install.") + n + ".subdirs"); + var_pool.rw (r).insert (string ("install.") + n + ".subdirs"); } static const alias_rule alias_; @@ -153,8 +157,8 @@ namespace build2 static const dir_path dir_man1 (dir_path ("man") /= "man1"); bool - init (scope& r, - scope& b, + init (scope& rs, + scope& bs, const location& l, unique_ptr&, bool first, @@ -169,7 +173,7 @@ namespace build2 return true; } - const dir_path& out_root (r.out_path ()); + const dir_path& out_root (rs.out_path ()); l5 ([&]{trace << "for " << out_root;}); assert (config_hints.empty ()); // We don't known any hints. @@ -179,7 +183,7 @@ namespace build2 // Note that the set_dir() calls below enter some more. // { - auto& v (var_pool); + auto& v (var_pool.rw (rs)); // Note: not overridable. // @@ -196,11 +200,11 @@ namespace build2 // Register our alias and file rules. // - b.rules.insert (perform_install_id, "install.alias", alias_); - b.rules.insert (perform_uninstall_id, "uninstall.alias", alias_); + bs.rules.insert (perform_install_id, "install.alias", alias_); + bs.rules.insert (perform_uninstall_id, "uninstall.alias", alias_); - b.rules.insert (perform_install_id, "install.file", file_); - b.rules.insert (perform_uninstall_id, "uinstall.file", file_); + bs.rules.insert (perform_install_id, "install.file", file_); + bs.rules.insert (perform_uninstall_id, "uinstall.file", file_); // Configuration. // @@ -211,44 +215,44 @@ namespace build2 { using build2::path; - bool s (config::specified (r, "config.install")); + bool s (config::specified (rs, "config.install")); // Adjust module priority so that the (numerous) config.install.* // values are saved at the end of config.build. // if (s) - config::save_module (r, "install", INT32_MAX); + config::save_module (rs, "install", INT32_MAX); - const string& n (cast (r["project"])); + const string& n (project (rs)); // Global config.install.* values. // - set_dir (s, r, "", abs_dir_path (), false, "644", "755", cmd); + set_dir (s, rs, "", abs_dir_path (), false, "644", "755", cmd); - set_dir (s, r, "root", abs_dir_path ()); + set_dir (s, rs, "root", abs_dir_path ()); - set_dir (s, r, "data_root", dir_root); - set_dir (s, r, "exec_root", dir_root, false, "755"); + set_dir (s, rs, "data_root", dir_root); + set_dir (s, rs, "exec_root", dir_root, false, "755"); - set_dir (s, r, "sbin", dir_sbin); - set_dir (s, r, "bin", dir_bin); - set_dir (s, r, "lib", dir_lib); - set_dir (s, r, "libexec", dir_path (dir_libexec) /= n, true); + set_dir (s, rs, "sbin", dir_sbin); + set_dir (s, rs, "bin", dir_bin); + set_dir (s, rs, "lib", dir_lib); + set_dir (s, rs, "libexec", dir_path (dir_libexec) /= n, true); - set_dir (s, r, "data", dir_path (dir_data) /= n, true); - set_dir (s, r, "include", dir_include); + set_dir (s, rs, "data", dir_path (dir_data) /= n, true); + set_dir (s, rs, "include", dir_include); - set_dir (s, r, "doc", dir_path (dir_doc) /= n, true); - set_dir (s, r, "man", dir_man); - set_dir (s, r, "man1", dir_man1); + set_dir (s, rs, "doc", dir_path (dir_doc) /= n, true); + set_dir (s, rs, "man", dir_man); + set_dir (s, rs, "man1", dir_man1); } // Configure "installability" for built-in target types. // - install_path (b, dir_path ("bin")); // Install into install.bin. - install_path (b, dir_path ("doc")); // Install into install.doc. - install_path (b, dir_path ("man")); // Install into install.man. - install_path (b, dir_path ("man1")); // Install into install.man1. + install_path (bs, dir_path ("bin")); // Install into install.bin. + install_path (bs, dir_path ("doc")); // Install into install.doc. + install_path (bs, dir_path ("man")); // Install into install.man. + install_path (bs, dir_path ("man1")); // Install into install.man1. return true; } diff --git a/build2/install/rule b/build2/install/rule index aad5ee4..169c43a 100644 --- a/build2/install/rule +++ b/build2/install/rule @@ -22,10 +22,10 @@ namespace build2 alias_rule () {} virtual match_result - match (action, target&, const string&) const override; + match (slock&, action, target&, const string&) const override; virtual recipe - apply (action, target&) const override; + apply (slock&, action, target&) const override; }; struct install_dir; @@ -36,17 +36,17 @@ namespace build2 file_rule () {} virtual match_result - match (action, target&, const string&) const override; + match (slock&, action, target&, const string&) const override; virtual recipe - apply (action, target&) const override; + apply (slock&, action, target&) const override; // Return NULL if this prerequisite should be ignored and pointer to its // target otherwise. The default implementation ignores prerequsites that // are outside of this target's project. // virtual target* - filter (action, target&, prerequisite_member) const; + filter (slock&, action, target&, prerequisite_member) const; // Extra installation hooks. // diff --git a/build2/install/rule.cxx b/build2/install/rule.cxx index a727acc..13c93a7 100644 --- a/build2/install/rule.cxx +++ b/build2/install/rule.cxx @@ -39,13 +39,13 @@ namespace build2 // alias_rule // match_result alias_rule:: - match (action, target&, const string&) const + match (slock&, action, target&, const string&) const { return true; } recipe alias_rule:: - apply (action a, target& t) const + apply (slock& ml, action a, target& t) const { tracer trace ("install::alias_rule::apply"); @@ -73,7 +73,7 @@ namespace build2 continue; } - build2::match (a, pt); + build2::match (ml, a, pt); t.prerequisite_targets.push_back (&pt); } @@ -91,7 +91,7 @@ namespace build2 "insufficient space"); match_result file_rule:: - match (action a, target& t, const string&) const + match (slock&, action a, target& t, const string&) const { // First determine if this target should be installed (called // "installable" for short). @@ -119,14 +119,14 @@ namespace build2 } target* file_rule:: - filter (action, target& t, prerequisite_member p) const + filter (slock&, action, target& t, prerequisite_member p) const { target& pt (p.search ()); return pt.in (t.root_scope ()) ? &pt : nullptr; } recipe file_rule:: - apply (action a, target& t) const + apply (slock& ml, action a, target& t) const { match_data md (move (t.data ())); t.clear_data (); // In case delegated-to rule also uses aux storage. @@ -149,7 +149,7 @@ namespace build2 // run standard search_and_match()? Will need an indicator // that it was forced (e.g., [install]) for filter() below. // - auto r (group_prerequisite_members (a, t)); + auto r (group_prerequisite_members (ml, a, t)); for (auto i (r.begin ()); i != r.end (); ++i) { prerequisite_member p (*i); @@ -162,7 +162,7 @@ namespace build2 // Let a customized rule have its say. // - target* pt (filter (a, t, p)); + target* pt (filter (ml, a, t, p)); if (pt == nullptr) continue; @@ -172,7 +172,7 @@ namespace build2 if (l && cast (l).string () == "false") continue; - build2::match (a, *pt); + build2::match (ml, a, *pt); // If the matched rule returned noop_recipe, then the target // state will be set to unchanged as an optimization. Use this @@ -209,7 +209,7 @@ namespace build2 // have been found if we signalled that we do not match from // match() above. // - recipe d (match_delegate (a, t, *this).first); + recipe d (match_delegate (ml, a, t, *this).first); // If we have no installable prerequisites, then simply redirect // to it. diff --git a/build2/install/utility b/build2/install/utility index 713c3e8..239447e 100644 --- a/build2/install/utility +++ b/build2/install/utility @@ -17,9 +17,12 @@ namespace build2 // Set install path, mode for a target type. // inline void - install_path (const target_type& tt, scope& s, dir_path d) + install_path (scope& s, const target_type& tt, dir_path d) { - auto r (s.target_vars[tt]["*"].insert ("install")); + auto r ( + s.target_vars[tt]["*"].insert ( + var_pool.rw (s).insert ("install"))); + if (r.second) // Already set by the user? r.first.get () = path_cast (move (d)); } @@ -28,13 +31,16 @@ namespace build2 inline void install_path (scope& s, dir_path d) { - return install_path (T::static_type, s, move (d)); + return install_path (s, T::static_type, move (d)); } inline void - install_mode (const target_type& tt, scope& s, string m) + install_mode (scope& s, const target_type& tt, string m) { - auto r (s.target_vars[tt]["*"].insert ("install.mode")); + auto r ( + s.target_vars[tt]["*"].insert ( + var_pool.rw (s).insert ("install.mode"))); + if (r.second) // Already set by the user? r.first.get () = move (m); } @@ -43,7 +49,7 @@ namespace build2 inline void install_mode (scope& s, string m) { - return install_mode (T::static_type, s, move (m)); + return install_mode (s, T::static_type, move (m)); } } } -- cgit v1.1