From 41cad5bba8a718a0403c0578660c60e81c9f46e4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 27 Jun 2016 16:59:09 +0200 Subject: Add config.bin.target var/hint, use to decide libso{} install mode Normally the user doesn't need to specify config.bin.target explicitly since the cxx module will hint it. We now also have the whole set of target's components: bin.target.{cpu,vendor,system,version,class} --- build2/cxx/module.cxx | 178 +++++++++++++++++++++++++++----------------------- 1 file changed, 98 insertions(+), 80 deletions(-) (limited to 'build2/cxx/module.cxx') diff --git a/build2/cxx/module.cxx b/build2/cxx/module.cxx index 71304c8..aa60be9 100644 --- a/build2/cxx/module.cxx +++ b/build2/cxx/module.cxx @@ -41,22 +41,8 @@ namespace build2 tracer trace ("cxx::init"); l5 ([&]{trace << "for " << b.out_path ();}); - assert (config_hints.empty ()); // We don't known any hints. - - // Initialize the bin module. Only do this if it hasn't already been - // loaded so that we don't overwrite user's bin.* settings. - // - if (!cast_false (b["bin.loaded"])) - load_module ("bin", r, b, loc); - // 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) { auto& v (var_pool); @@ -82,64 +68,11 @@ namespace build2 v.insert ("cxx.std", true); } - // Register target types. - // - { - auto& t (b.target_types); - - t.insert (); - t.insert (); - - t.insert (); - t.insert (); - t.insert (); - t.insert (); - } - - // Register rules. - // - { - using namespace bin; - - auto& r (b.rules); - - r.insert (perform_update_id, "cxx.compile", compile::instance); - - r.insert (perform_update_id, "cxx.compile", compile::instance); - r.insert (perform_clean_id, "cxx.compile", compile::instance); - - r.insert (perform_update_id, "cxx.compile", compile::instance); - r.insert (perform_clean_id, "cxx.compile", compile::instance); - - r.insert (perform_update_id, "cxx.link", link::instance); - r.insert (perform_clean_id, "cxx.link", link::instance); - - r.insert (perform_update_id, "cxx.link", link::instance); - r.insert (perform_clean_id, "cxx.link", link::instance); - - r.insert (perform_update_id, "cxx.link", link::instance); - r.insert (perform_clean_id, "cxx.link", link::instance); - - // Register for configure so that we detect unresolved imports - // during configuration rather that later, e.g., during update. - // - r.insert (configure_update_id, "cxx.compile", compile::instance); - r.insert (configure_update_id, "cxx.compile", compile::instance); - - r.insert (configure_update_id, "cxx.link", link::instance); - r.insert (configure_update_id, "cxx.link", link::instance); - r.insert (configure_update_id, "cxx.link", link::instance); - - //@@ Should we check if install module was loaded (see bin)? - // - r.insert (perform_install_id, "cxx.install", install::instance); - r.insert (perform_install_id, "cxx.install", install::instance); - r.insert (perform_install_id, "cxx.install", install::instance); - } - // Configure. // + assert (config_hints.empty ()); // We don't known any hints. + // config.cxx.{p,c,l}options // config.cxx.libs // @@ -186,15 +119,16 @@ namespace build2 { //@@ Print project out root or name? Don't print if unnamed? - text << cxx << ":\n" - << " id " << ci.id << "\n" - << " version " << ci.version.string << "\n" - << " major " << ci.version.major << "\n" - << " minor " << ci.version.minor << "\n" - << " patch " << ci.version.patch << "\n" - << " build " << ci.version.build << "\n" - << " signature " << ci.signature << "\n" - << " checksum " << ci.checksum << "\n" + text << "cxx\n" + << " exe " << cxx << '\n' + << " id " << ci.id << '\n' + << " version " << ci.version.string << '\n' + << " major " << ci.version.major << '\n' + << " minor " << ci.version.minor << '\n' + << " patch " << ci.version.patch << '\n' + << " build " << ci.version.build << '\n' + << " signature " << ci.signature << '\n' + << " checksum " << ci.checksum << '\n' << " target " << ci.target; } @@ -243,8 +177,8 @@ namespace build2 } catch (const invalid_argument& e) { - // This is where we could suggest that the user specifies - // --config-sub to help us out. + // This is where we suggest that the user specifies --config-sub to + // help us out. // fail << "unable to parse compiler target '" << ci.target << "': " << e.what () << @@ -252,6 +186,90 @@ namespace build2 } } + // Initialize the bin module. Only do this if it hasn't already been + // loaded so that we don't overwrite user's bin.* settings. + // + const string& target (cast (r["cxx.target"])); + + if (!cast_false (b["bin.loaded"])) + { + // Pass the target we extracted from the C++ compiler as a config hint + // to the bin module. + // + variable_map hints; + hints.assign ("config.bin.target") = target; + + load_module ("bin", r, b, loc, false, hints); + } + + // Verify bin's target matches ours. + // + { + const string& bt (cast (r["bin.target"])); + + if (bt != target) + fail (loc) << "bin and cxx module target platform mismatch" << + info << "bin.target is " << bt << + info << "cxx.target is " << target; + } + + // Register target types. + // + { + auto& t (b.target_types); + + t.insert (); + t.insert (); + + t.insert (); + t.insert (); + t.insert (); + t.insert (); + } + + // Register rules. + // + { + using namespace bin; + + auto& r (b.rules); + + r.insert (perform_update_id, "cxx.compile", compile::instance); + + r.insert (perform_update_id, "cxx.compile", compile::instance); + r.insert (perform_clean_id, "cxx.compile", compile::instance); + + r.insert (perform_update_id, "cxx.compile", compile::instance); + r.insert (perform_clean_id, "cxx.compile", compile::instance); + + r.insert (perform_update_id, "cxx.link", link::instance); + r.insert (perform_clean_id, "cxx.link", link::instance); + + r.insert (perform_update_id, "cxx.link", link::instance); + r.insert (perform_clean_id, "cxx.link", link::instance); + + r.insert (perform_update_id, "cxx.link", link::instance); + r.insert (perform_clean_id, "cxx.link", link::instance); + + // Register for configure so that we detect unresolved imports + // during configuration rather that later, e.g., during update. + // + r.insert (configure_update_id, "cxx.compile", compile::instance); + r.insert (configure_update_id, "cxx.compile", compile::instance); + + r.insert (configure_update_id, "cxx.link", link::instance); + r.insert (configure_update_id, "cxx.link", link::instance); + r.insert (configure_update_id, "cxx.link", link::instance); + + //@@ Should we check if install module was loaded (see bin)? + // + r.insert (perform_install_id, "cxx.install", install::instance); + r.insert (perform_install_id, "cxx.install", install::instance); + r.insert (perform_install_id, "cxx.install", install::instance); + } + + + // Configure "installability" of our target types. // using namespace install; -- cgit v1.1