aboutsummaryrefslogtreecommitdiff
path: root/build2/cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-06-27 16:59:09 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-06-27 16:59:09 +0200
commit41cad5bba8a718a0403c0578660c60e81c9f46e4 (patch)
tree7eebba42dac307fdfcf600f5f6527afe0c0f4fea /build2/cxx
parent34cc74df52ed129bffeb7b6fcf11f05c222550ba (diff)
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}
Diffstat (limited to 'build2/cxx')
-rw-r--r--build2/cxx/module.cxx178
1 files changed, 98 insertions, 80 deletions
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<bool> (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<string> ("cxx.std", true);
}
- // Register target types.
- //
- {
- auto& t (b.target_types);
-
- t.insert<h> ();
- t.insert<c> ();
-
- t.insert<cxx> ();
- t.insert<hxx> ();
- t.insert<ixx> ();
- t.insert<txx> ();
- }
-
- // Register rules.
- //
- {
- using namespace bin;
-
- auto& r (b.rules);
-
- r.insert<obja> (perform_update_id, "cxx.compile", compile::instance);
-
- r.insert<obja> (perform_update_id, "cxx.compile", compile::instance);
- r.insert<obja> (perform_clean_id, "cxx.compile", compile::instance);
-
- r.insert<objso> (perform_update_id, "cxx.compile", compile::instance);
- r.insert<objso> (perform_clean_id, "cxx.compile", compile::instance);
-
- r.insert<exe> (perform_update_id, "cxx.link", link::instance);
- r.insert<exe> (perform_clean_id, "cxx.link", link::instance);
-
- r.insert<liba> (perform_update_id, "cxx.link", link::instance);
- r.insert<liba> (perform_clean_id, "cxx.link", link::instance);
-
- r.insert<libso> (perform_update_id, "cxx.link", link::instance);
- r.insert<libso> (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<obja> (configure_update_id, "cxx.compile", compile::instance);
- r.insert<objso> (configure_update_id, "cxx.compile", compile::instance);
-
- r.insert<exe> (configure_update_id, "cxx.link", link::instance);
- r.insert<liba> (configure_update_id, "cxx.link", link::instance);
- r.insert<libso> (configure_update_id, "cxx.link", link::instance);
-
- //@@ Should we check if install module was loaded (see bin)?
- //
- r.insert<exe> (perform_install_id, "cxx.install", install::instance);
- r.insert<liba> (perform_install_id, "cxx.install", install::instance);
- r.insert<libso> (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<string> (r["cxx.target"]));
+
+ if (!cast_false<bool> (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<string> (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<h> ();
+ t.insert<c> ();
+
+ t.insert<cxx> ();
+ t.insert<hxx> ();
+ t.insert<ixx> ();
+ t.insert<txx> ();
+ }
+
+ // Register rules.
+ //
+ {
+ using namespace bin;
+
+ auto& r (b.rules);
+
+ r.insert<obja> (perform_update_id, "cxx.compile", compile::instance);
+
+ r.insert<obja> (perform_update_id, "cxx.compile", compile::instance);
+ r.insert<obja> (perform_clean_id, "cxx.compile", compile::instance);
+
+ r.insert<objso> (perform_update_id, "cxx.compile", compile::instance);
+ r.insert<objso> (perform_clean_id, "cxx.compile", compile::instance);
+
+ r.insert<exe> (perform_update_id, "cxx.link", link::instance);
+ r.insert<exe> (perform_clean_id, "cxx.link", link::instance);
+
+ r.insert<liba> (perform_update_id, "cxx.link", link::instance);
+ r.insert<liba> (perform_clean_id, "cxx.link", link::instance);
+
+ r.insert<libso> (perform_update_id, "cxx.link", link::instance);
+ r.insert<libso> (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<obja> (configure_update_id, "cxx.compile", compile::instance);
+ r.insert<objso> (configure_update_id, "cxx.compile", compile::instance);
+
+ r.insert<exe> (configure_update_id, "cxx.link", link::instance);
+ r.insert<liba> (configure_update_id, "cxx.link", link::instance);
+ r.insert<libso> (configure_update_id, "cxx.link", link::instance);
+
+ //@@ Should we check if install module was loaded (see bin)?
+ //
+ r.insert<exe> (perform_install_id, "cxx.install", install::instance);
+ r.insert<liba> (perform_install_id, "cxx.install", install::instance);
+ r.insert<libso> (perform_install_id, "cxx.install", install::instance);
+ }
+
+
+
// Configure "installability" of our target types.
//
using namespace install;