diff options
Diffstat (limited to 'build/cxx')
-rw-r--r-- | build/cxx/compile.cxx | 46 | ||||
-rw-r--r-- | build/cxx/link.cxx | 40 | ||||
-rw-r--r-- | build/cxx/module.cxx | 63 | ||||
-rw-r--r-- | build/cxx/utility.txx | 4 |
4 files changed, 89 insertions, 64 deletions
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<const string&> ())] = &h::static_type; + if (auto l = r["h.ext"]) + m[&extension_pool.find (as<string> (*l))] = &h::static_type; - if (auto val = r["c.ext"]) - m[&extension_pool.find (val.as<const string&> ())] = &c::static_type; + if (auto l = r["c.ext"]) + m[&extension_pool.find (as<string> (*l))] = &c::static_type; - if (auto val = r["hxx.ext"]) - m[&extension_pool.find (val.as<const string&> ())] = &hxx::static_type; + if (auto l = r["hxx.ext"]) + m[&extension_pool.find (as<string> (*l))] = &hxx::static_type; - if (auto val = r["ixx.ext"]) - m[&extension_pool.find (val.as<const string&> ())] = &ixx::static_type; + if (auto l = r["ixx.ext"]) + m[&extension_pool.find (as<string> (*l))] = &ixx::static_type; - if (auto val = r["txx.ext"]) - m[&extension_pool.find (val.as<const string&> ())] = &txx::static_type; + if (auto l = r["txx.ext"]) + m[&extension_pool.find (as<string> (*l))] = &txx::static_type; - if (auto val = r["cxx.ext"]) - m[&extension_pool.find (val.as<const string&> ())] = &cxx::static_type; + if (auto l = r["cxx.ext"]) + m[&extension_pool.find (as<string> (*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 list_value&> ()); + const auto& v (as<strings> (*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&> ()); + const string& cxx (as<string> (*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&> ()); + const string& cxx (as<string> (*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<const list_value&> ()); - 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<strings> (*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 list_value&> ()); + const auto& v (as<strings> (*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<const string&> ().c_str ()); + args.push_back (as<string> (*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&> ()); + const string& at (as<string> (*(*l)["bin.lib"])); if (!lo) lo = link_order (t); @@ -776,10 +768,8 @@ namespace build } else { - args.push_back (rs["config.cxx"].as<const string&> ().c_str ()); - + args.push_back (as<string> (*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<libso> (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<string> (p.first)); const char* args[] = {cxx.c_str (), "-dumpversion", nullptr}; if (verb) @@ -157,27 +194,27 @@ namespace build // using cxx // cxx.coptions += <overriding options> # Note: '+='. // - if (auto* v = config::optional<list_value> (r, "config.cxx.poptions")) - b.assign ("cxx.poptions") += *v; + if (const value& v = config::optional (r, "config.cxx.poptions")) + b.assign ("cxx.poptions") += as<strings> (v); - if (auto* v = config::optional<list_value> (r, "config.cxx.coptions")) - b.assign ("cxx.coptions") += *v; + if (const value& v = config::optional (r, "config.cxx.coptions")) + b.assign ("cxx.coptions") += as<strings> (v); - if (auto* v = config::optional<list_value> (r, "config.cxx.loptions")) - b.assign ("cxx.loptions") += *v; + if (const value& v = config::optional (r, "config.cxx.loptions")) + b.assign ("cxx.loptions") += as<strings> (v); - if (auto* v = config::optional<list_value> (r, "config.cxx.libs")) - b.assign ("cxx.libs") += *v; + if (const value& v = config::optional (r, "config.cxx.libs")) + b.assign ("cxx.libs") += as<strings> (v); // Configure "installability" of our target types. // { using build::install::path; - path<hxx> (b, "include"); // Install into install.include. - path<ixx> (b, "include"); - path<txx> (b, "include"); - path<h> (b, "include"); + path<hxx> (b, dir_path ("include")); // Install into install.include. + path<ixx> (b, dir_path ("include")); + path<txx> (b, dir_path ("include")); + path<h> (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 string&> ()); + const std::string& v (as<string> (*l)); // Translate 11 to 0x and 14 to 1y for compatibility with // older versions of the compiler. |