diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-04-24 12:29:20 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-04-24 12:29:20 +0200 |
commit | 2a0f9e035f673f1ee387924501a31990de37f18d (patch) | |
tree | b8e55ab74bc88b788e99d8649219b931b80432d5 /build/cxx/module.cxx | |
parent | 4c44c914d898af53152addad5530504548175e85 (diff) |
Implement lib/liba/libso{} target group, shared/static library build
Diffstat (limited to 'build/cxx/module.cxx')
-rw-r--r-- | build/cxx/module.cxx | 144 |
1 files changed, 42 insertions, 102 deletions
diff --git a/build/cxx/module.cxx b/build/cxx/module.cxx index 3e0101f..45f8271 100644 --- a/build/cxx/module.cxx +++ b/build/cxx/module.cxx @@ -12,6 +12,8 @@ #include <build/process> #include <build/diagnostics> +#include <build/config/utility> + using namespace std; namespace build @@ -41,130 +43,68 @@ namespace build // config.cxx // - for (bool f (true); f; f = false) { - auto val (root["config.cxx"]); - - string v; + auto r (config::required (root, "config.cxx", "g++")); - if (val) + // If we actually set a new value, test it by trying to execute. + // + if (r.second) { - if (!val.belongs (*global_scope)) - break; // A value from (some) config.build. - - v = val.as<const string&> (); - } - else - v = "g++"; // Default. + const string& cxx (r.first); + const char* args[] = {cxx.c_str (), "-dumpversion", nullptr}; - // Test it by trying to execute. - // - const char* args[] = {v.c_str (), "-dumpversion", nullptr}; + if (verb) + print_process (args); + else + text << "test " << cxx; - if (verb) - print_process (args); - else - text << "test " << v; + string ver; + try + { + process pr (args, false, false, true); - string ver; - try - { - process pr (args, false, false, true); + __gnu_cxx::stdio_filebuf<char> fb (pr.in_ofd, ios_base::in); + istream is (&fb); - __gnu_cxx::stdio_filebuf<char> fb (pr.in_ofd, ios_base::in); - istream is (&fb); + bool r (getline (is, ver)); - bool r (getline (is, ver)); + if (!pr.wait ()) + throw failed (); - if (!pr.wait ()) - throw failed (); + if (!r) + fail << "unexpected output from " << cxx; + } + catch (const process_error& e) + { + error << "unable to execute " << cxx << ": " << e.what (); - if (!r) - fail << "unexpected output from " << v; - } - catch (const process_error& e) - { - error << "unable to execute " << v << ": " << e.what (); + if (e.child ()) + exit (1); - if (e.child ()) - exit (1); + throw failed (); + } - throw failed (); + //text << "toolchain version " << ver; } - - //text << "toolchain version " << ver; - - // Set on the project root. - // - root.assign ("config.cxx") = move (v); } // config.cxx.{p,c,l}options // config.cxx.libs // - // These are optional so all we need to do is "import" them - // into the root scope if they were specified on the command - // line and set them to NULL if unspecified (the last part - // is important to distinguish between the "configured as - // unspecified" and "not configured" cases). - // - // We also merge them into the corresponding cxx.* variables. + // These are optional. We also merge them into the corresponding + // cxx.* variables. // - { - auto v (root["config.cxx.poptions"]); + if (auto* v = config::optional<list_value> (root, "config.cxx.poptions")) + root.append ("cxx.poptions") += *v; - if (v.defined ()) - { - if (v.belongs (*global_scope)) - root.assign ("config.cxx.poptions") = v; + if (auto* v = config::optional<list_value> (root, "config.cxx.coptions")) + root.append ("cxx.coptions") += *v; - root.append ("cxx.poptions") += v; - } - else - root.assign ("config.cxx.poptions") = nullptr; - } + if (auto* v = config::optional<list_value> (root, "config.cxx.loptions")) + root.append ("cxx.loptions") += *v; - { - auto v (root["config.cxx.coptions"]); - - if (v.defined ()) - { - if (v.belongs (*global_scope)) - root.assign ("config.cxx.coptions") = v; - - root.append ("cxx.coptions") += v; - } - else - root.assign ("config.cxx.coptions") = nullptr; - } - - { - auto v (root["config.cxx.loptions"]); - - if (v.defined ()) - { - if (v.belongs (*global_scope)) - root.assign ("config.cxx.loptions") = v; - - root.append ("cxx.loptions") += v; - } - else - root.assign ("config.cxx.loptions") = nullptr; - } - - { - auto v (root["config.cxx.libs"]); - - if (v.defined ()) - { - if (v.belongs (*global_scope)) - root.assign ("config.cxx.libs") = v; - - root.append ("cxx.libs") += v; - } - else - root.assign ("config.cxx.libs") = nullptr; - } + if (auto* v = config::optional<list_value> (root, "config.cxx.libs")) + root.append ("cxx.libs") += *v; } } } |