From 68f96f9213e849d0d7c4cedf3edeaec99743ee27 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 24 Aug 2015 09:51:15 +0200 Subject: New variable architecture --- build/cxx/compile.cxx | 46 ++++++++++++++++++------------------- build/cxx/link.cxx | 40 ++++++++++++-------------------- build/cxx/module.cxx | 63 ++++++++++++++++++++++++++++++++++++++++----------- build/cxx/utility.txx | 4 ++-- 4 files changed, 89 insertions(+), 64 deletions(-) (limited to 'build/cxx') diff --git a/build/cxx/compile.cxx b/build/cxx/compile.cxx index 8dcad1e..65806ed 100644 --- a/build/cxx/compile.cxx +++ b/build/cxx/compile.cxx @@ -166,23 +166,23 @@ namespace build { ext_map m; - if (auto val = r["h.ext"]) - m[&extension_pool.find (val.as ())] = &h::static_type; + if (auto l = r["h.ext"]) + m[&extension_pool.find (as (*l))] = &h::static_type; - if (auto val = r["c.ext"]) - m[&extension_pool.find (val.as ())] = &c::static_type; + if (auto l = r["c.ext"]) + m[&extension_pool.find (as (*l))] = &c::static_type; - if (auto val = r["hxx.ext"]) - m[&extension_pool.find (val.as ())] = &hxx::static_type; + if (auto l = r["hxx.ext"]) + m[&extension_pool.find (as (*l))] = &hxx::static_type; - if (auto val = r["ixx.ext"]) - m[&extension_pool.find (val.as ())] = &ixx::static_type; + if (auto l = r["ixx.ext"]) + m[&extension_pool.find (as (*l))] = &ixx::static_type; - if (auto val = r["txx.ext"]) - m[&extension_pool.find (val.as ())] = &txx::static_type; + if (auto l = r["txx.ext"]) + m[&extension_pool.find (as (*l))] = &txx::static_type; - if (auto val = r["cxx.ext"]) - m[&extension_pool.find (val.as ())] = &cxx::static_type; + if (auto l = r["cxx.ext"]) + m[&extension_pool.find (as (*l))] = &cxx::static_type; return m; } @@ -215,26 +215,24 @@ namespace build const dir_path& out_base (t.dir); const dir_path& out_root (rs->path ()); - if (auto val = t[var]) + if (auto l = t[var]) { - const list_value& l (val.template as ()); + const auto& v (as (*l)); - // Assume the names have already been vetted by append_options(). - // - for (auto i (l.begin ()), e (l.end ()); i != e; ++i) + for (auto i (v.begin ()), e (v.end ()); i != e; ++i) { - // -I can either be in the -Ifoo or -I foo form. + // -I can either be in the "-Ifoo" or "-I foo" form. // dir_path d; - if (i->value == "-I") + if (*i == "-I") { if (++i == e) break; // Let the compiler complain. - d = i->simple () ? dir_path (i->value) : i->dir; + d = dir_path (*i); } - else if (i->value.compare (0, 2, "-I") == 0) - d = dir_path (i->value, 2, string::npos); + else if (i->compare (0, 2, "-I") == 0) + d = dir_path (*i, 2, string::npos); else continue; @@ -368,7 +366,7 @@ namespace build tracer trace ("cxx::compile::inject_prerequisites"); scope& rs (t.root_scope ()); - const string& cxx (rs["config.cxx"].as ()); + const string& cxx (as (*rs["config.cxx"])); cstrings args {cxx.c_str ()}; @@ -715,7 +713,7 @@ namespace build path rels (relative (s->path ())); scope& rs (t.root_scope ()); - const string& cxx (rs["config.cxx"].as ()); + const string& cxx (as (*rs["config.cxx"])); cstrings args {cxx.c_str ()}; diff --git a/build/cxx/link.cxx b/build/cxx/link.cxx index 97c9696..1b900c2 100644 --- a/build/cxx/link.cxx +++ b/build/cxx/link.cxx @@ -59,10 +59,10 @@ namespace build case type::so: var = "bin.libso.lib"; break; } - const list_value& lv (t[var].as ()); - return lv[0].value == "shared" - ? lv.size () > 1 && lv[1].value == "static" ? order::so_a : order::so - : lv.size () > 1 && lv[1].value == "shared" ? order::a_so : order::a; + const auto& v (as (*t[var])); + return v[0] == "shared" + ? v.size () > 1 && v[1] == "static" ? order::so_a : order::so + : v.size () > 1 && v[1] == "shared" ? order::a_so : order::a; } link::search_paths link:: @@ -73,32 +73,24 @@ namespace build // Extract user-supplied search paths (i.e., -L). // - if (auto val = bs["cxx.loptions"]) + if (auto l = bs["cxx.loptions"]) { - const list_value& l (val.as ()); + const auto& v (as (*l)); - for (auto i (l.begin ()), e (l.end ()); i != e; ++i) + for (auto i (v.begin ()), e (v.end ()); i != e; ++i) { - if (!i->simple ()) - continue; - - // -L can either be in the -Lfoo or -L foo form. + // -L can either be in the "-Lfoo" or "-L foo" form. // dir_path d; - if (i->value == "-L") + if (*i == "-L") { if (++i == e) break; // Let the compiler complain. - if (i->simple ()) - d = dir_path (i->value); - else if (i->directory ()) - d = i->dir; - else - break; // Let the compiler complain. + d = dir_path (*i); } - else if (i->value.compare (0, 2, "-L") == 0) - d = dir_path (i->value, 2, string::npos); + else if (i->compare (0, 2, "-L") == 0) + d = dir_path (*i, 2, string::npos); else continue; @@ -114,7 +106,7 @@ namespace build cstrings args; string std_storage; - args.push_back (rs["config.cxx"].as ().c_str ()); + args.push_back (as (*rs["config.cxx"]).c_str ()); append_options (args, bs, "cxx.coptions"); append_std (args, bs, std_storage); append_options (args, bs, "cxx.loptions"); @@ -550,7 +542,7 @@ namespace build // Determine the library type to link. // bool lso (true); - const string& at ((*l)["bin.lib"].as ()); + const string& at (as (*(*l)["bin.lib"])); if (!lo) lo = link_order (t); @@ -776,10 +768,8 @@ namespace build } else { - args.push_back (rs["config.cxx"].as ().c_str ()); - + args.push_back (as (*rs["config.cxx"]).c_str ()); append_options (args, t, "cxx.coptions"); - append_std (args, t, storage1); if (so) diff --git a/build/cxx/module.cxx b/build/cxx/module.cxx index 042fb53..7f200cd 100644 --- a/build/cxx/module.cxx +++ b/build/cxx/module.cxx @@ -91,6 +91,43 @@ namespace build rs.insert (install_id, "cxx.install", install::instance); } + // Enter module variables. + // + // @@ Probably should only be done on load; make sure reset() unloads + // modules. + // + // @@ Should probably cache the variable pointers so we don't have + // to keep looking them up. + // + if (first) + { + variable_pool.find ("config.cxx", string_type); //@@ VAR type + + variable_pool.find ("config.cxx.poptions", strings_type); + variable_pool.find ("config.cxx.coptions", strings_type); + variable_pool.find ("config.cxx.loptions", strings_type); + variable_pool.find ("config.cxx.libs", strings_type); + + variable_pool.find ("cxx.poptions", strings_type); + variable_pool.find ("cxx.coptions", strings_type); + variable_pool.find ("cxx.loptions", strings_type); + variable_pool.find ("cxx.libs", strings_type); + + variable_pool.find ("cxx.export.poptions", strings_type); + variable_pool.find ("cxx.export.coptions", strings_type); + variable_pool.find ("cxx.export.loptions", strings_type); + variable_pool.find ("cxx.export.libs", strings_type); + + variable_pool.find ("cxx.std", string_type); + + variable_pool.find ("h.ext", string_type); + variable_pool.find ("c.ext", string_type); + variable_pool.find ("hxx.ext", string_type); + variable_pool.find ("ixx.ext", string_type); + variable_pool.find ("txx.ext", string_type); + variable_pool.find ("cxx.ext", string_type); + } + // Configure. // @@ -104,7 +141,7 @@ namespace build // if (p.second) { - const string& cxx (p.first); + const string& cxx (as (p.first)); const char* args[] = {cxx.c_str (), "-dumpversion", nullptr}; if (verb) @@ -157,27 +194,27 @@ namespace build // using cxx // cxx.coptions += # Note: '+='. // - if (auto* v = config::optional (r, "config.cxx.poptions")) - b.assign ("cxx.poptions") += *v; + if (const value& v = config::optional (r, "config.cxx.poptions")) + b.assign ("cxx.poptions") += as (v); - if (auto* v = config::optional (r, "config.cxx.coptions")) - b.assign ("cxx.coptions") += *v; + if (const value& v = config::optional (r, "config.cxx.coptions")) + b.assign ("cxx.coptions") += as (v); - if (auto* v = config::optional (r, "config.cxx.loptions")) - b.assign ("cxx.loptions") += *v; + if (const value& v = config::optional (r, "config.cxx.loptions")) + b.assign ("cxx.loptions") += as (v); - if (auto* v = config::optional (r, "config.cxx.libs")) - b.assign ("cxx.libs") += *v; + if (const value& v = config::optional (r, "config.cxx.libs")) + b.assign ("cxx.libs") += as (v); // Configure "installability" of our target types. // { using build::install::path; - path (b, "include"); // Install into install.include. - path (b, "include"); - path (b, "include"); - path (b, "include"); + path (b, dir_path ("include")); // Install into install.include. + path (b, dir_path ("include")); + path (b, dir_path ("include")); + path (b, dir_path ("include")); } } } diff --git a/build/cxx/utility.txx b/build/cxx/utility.txx index 7d9d686..561a54e 100644 --- a/build/cxx/utility.txx +++ b/build/cxx/utility.txx @@ -12,9 +12,9 @@ namespace build void append_std (cstrings& args, T& t, std::string& s) { - if (auto val = t["cxx.std"]) + if (auto l = t["cxx.std"]) { - const std::string& v (val.template as ()); + const std::string& v (as (*l)); // Translate 11 to 0x and 14 to 1y for compatibility with // older versions of the compiler. -- cgit v1.1