From 0fd7815cbc6557811df4f1b6ffb40461474b8534 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 12 Aug 2016 12:46:21 +0200 Subject: Implement c/cxx toolchain cross-hinting --- build2/bin/module.cxx | 71 +++++++++++++++++++++------------------------------ 1 file changed, 29 insertions(+), 42 deletions(-) (limited to 'build2/bin') diff --git a/build2/bin/module.cxx b/build2/bin/module.cxx index 6d9cda7..3a3f612 100644 --- a/build2/bin/module.cxx +++ b/build2/bin/module.cxx @@ -370,26 +370,6 @@ namespace build2 return true; } - // Apply the specified stem to the config.bin.pattern. If there is no - // pattern, then return the stem itself. Assume the pattern is valid, - // i.e., contains single '*'. - // - static string - apply (const lookup& pattern, const char* stem) - { - if (!pattern) - return stem; - - const string& p (cast (pattern)); - size_t i (p.find ('*')); - assert (i != string::npos); - - string r (p, 0, i++); - r.append (stem); - r.append (p, i, p.size () - i); - return r; - } - bool ar_config_init (scope& r, scope& b, @@ -435,7 +415,6 @@ namespace build2 // toolchain can be target-unprefixed. Also, without canonicalization, // comparing targets will be unreliable. // - auto pattern (r["bin.pattern"]); // Use the target to decide on the default binutils program names. // @@ -446,17 +425,21 @@ namespace build2 // changes, say, the C++ compiler (which hinted the pattern), then // ar will automatically change as well. // - auto ap (config::required (r, - "config.bin.ar", - path (apply (pattern, ar_d)), - false, - config::save_commented)); - - auto rp (config::required (r, - "config.bin.ranlib", - nullptr, - false, - config::save_commented)); + auto ap ( + config::required ( + r, + "config.bin.ar", + path (apply_pattern (ar_d, cast_null (r["bin.pattern"]))), + false, + config::save_commented)); + + auto rp ( + config::required ( + r, + "config.bin.ranlib", + nullptr, + false, + config::save_commented)); const path& ar (cast (ap.first)); const path* ranlib (cast_null (rp.first)); @@ -566,11 +549,13 @@ namespace build2 const string& tsys (cast (r["bin.target.system"])); const char* ld_d (tsys == "win32-msvc" ? "link" : "ld"); - auto p (config::required (r, - "config.bin.ld", - path (apply (r["bin.pattern"], ld_d)), - false, - config::save_commented)); + auto p ( + config::required ( + r, + "config.bin.ld", + path (apply_pattern (ld_d, cast_null (r["bin.pattern"]))), + false, + config::save_commented)); const path& ld (cast (p.first)); ld_info ldi (guess_ld (ld)); @@ -668,11 +653,13 @@ namespace build2 const string& tsys (cast (r["bin.target.system"])); const char* rc_d (tsys == "win32-msvc" ? "rc" : "windres"); - auto p (config::required (r, - "config.bin.rc", - path (apply (r["bin.pattern"], rc_d)), - false, - config::save_commented)); + auto p ( + config::required ( + r, + "config.bin.rc", + path (apply_pattern (rc_d, cast_null (r["bin.pattern"]))), + false, + config::save_commented)); const path& rc (cast (p.first)); rc_info rci (guess_rc (rc)); -- cgit v1.1