From fac576a331d6587e4343d09d6caf959d9a776118 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 11 Jul 2016 05:56:17 +0200 Subject: Add bin.ld sub-module --- build2/bin/module.cxx | 90 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 77 insertions(+), 13 deletions(-) (limited to 'build2/bin/module.cxx') diff --git a/build2/bin/module.cxx b/build2/bin/module.cxx index 9ce069c..f5e44db 100644 --- a/build2/bin/module.cxx +++ b/build2/bin/module.cxx @@ -305,7 +305,7 @@ namespace build2 const path& ar (cast (p.first)); const path& ranlib (v ? cast (v) : path ()); - bin_info bi (guess (ar, ranlib)); + ar_info ai (guess_ar (ar, ranlib)); // If this is a new value (e.g., we are configuring), then print the // report at verbosity level 2 and up (-v). @@ -316,30 +316,30 @@ namespace build2 text << "bin.ar\n" << " exe " << ar << '\n' - << " id " << bi.ar_id << '\n' - << " signature " << bi.ar_signature << '\n' - << " checksum " << bi.ar_checksum; + << " id " << ai.ar_id << '\n' + << " signature " << ai.ar_signature << '\n' + << " checksum " << ai.ar_checksum; if (!ranlib.empty ()) { text << "bin.ranlib\n" << " exe " << ranlib << '\n' - << " id " << bi.ranlib_id << '\n' - << " signature " << bi.ranlib_signature << '\n' - << " checksum " << bi.ranlib_checksum; + << " id " << ai.ranlib_id << '\n' + << " signature " << ai.ranlib_signature << '\n' + << " checksum " << ai.ranlib_checksum; } } - r.assign ("bin.ar.id") = move (bi.ar_id); - r.assign ("bin.ar.signature") = move (bi.ar_signature); - r.assign ("bin.ar.checksum") = move (bi.ar_checksum); + r.assign ("bin.ar.id") = move (ai.ar_id); + r.assign ("bin.ar.signature") = move (ai.ar_signature); + r.assign ("bin.ar.checksum") = move (ai.ar_checksum); if (!ranlib.empty ()) { - r.assign ("bin.ranlib.id") = move (bi.ranlib_id); + r.assign ("bin.ranlib.id") = move (ai.ranlib_id); r.assign ("bin.ranlib.signature") = - move (bi.ranlib_signature); - r.assign ("bin.ranlib.checksum") = move (bi.ranlib_checksum); + move (ai.ranlib_signature); + r.assign ("bin.ranlib.checksum") = move (ai.ranlib_checksum); } } @@ -421,5 +421,69 @@ namespace build2 return true; } + + bool + ld_init (scope& r, + scope& b, + const location& loc, + unique_ptr&, + bool first, + bool, + const variable_map& config_hints) + { + tracer trace ("bin::ld_init"); + l5 ([&]{trace << "for " << b.out_path ();}); + + // Make sure the bin core is loaded. + // + if (!cast_false (b["bin.loaded"])) + load_module ("bin", r, b, loc, false, config_hints); + + // Enter module variables. + // + if (first) + { + auto& v (var_pool); + + v.insert ("config.bin.ld", true); + } + + // Configure. + // + if (first) + { + // config.bin.ld + // + // Use the target to decide on the default ld name. + // + 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)))); + + const path& ld (cast (p.first)); + ld_info li (guess_ld (ld)); + + // If this is a new value (e.g., we are configuring), then print the + // report at verbosity level 2 and up (-v). + // + if (verb >= (p.second ? 2 : 3)) + { + text << "bin.ld\n" + << " exe " << ld << '\n' + << " id " << li.ld_id << '\n' + << " signature " << li.ld_signature << '\n' + << " checksum " << li.ld_checksum; + } + + r.assign ("bin.ld.id") = move (li.ld_id); + r.assign ("bin.ld.signature") = move (li.ld_signature); + r.assign ("bin.ld.checksum") = move (li.ld_checksum); + } + + return true; + } } } -- cgit v1.1