From 3239bc2435ddcd9dae0a177360a3644d85008c42 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 20 Jul 2016 10:32:29 +0200 Subject: Print project name and out_root in config reports --- build2/bin/module.cxx | 32 +++++++-------- build2/cli/module.cxx | 109 +++++++++++++++++++++++++++++--------------------- build2/context | 11 ++++- build2/cxx/module.cxx | 6 +-- 4 files changed, 91 insertions(+), 67 deletions(-) (limited to 'build2') diff --git a/build2/bin/module.cxx b/build2/bin/module.cxx index c796c84..6f9a938 100644 --- a/build2/bin/module.cxx +++ b/build2/bin/module.cxx @@ -267,7 +267,7 @@ namespace build2 { diag_record dr (text); - dr << "bin\n" + dr << "bin " << project (r) << '@' << r.out_path () << '\n' << " target " << cast (r["bin.target"]); if (auto l = r["bin.pattern"]) @@ -430,21 +430,21 @@ namespace build2 // if (verb >= (p.second ? 2 : 3)) { - //@@ Print project out root or name? See cxx. + diag_record dr (text); - text << "bin.ar\n" - << " exe " << ar << '\n' - << " id " << ari.ar_id << '\n' - << " signature " << ari.ar_signature << '\n' - << " checksum " << ari.ar_checksum; + dr << "bin.ar " << project (r) << '@' << r.out_path () << '\n' + << " ar " << ar << '\n' + << " id " << ari.ar_id << '\n' + << " signature " << ari.ar_signature << '\n' + << " checksum " << ari.ar_checksum; if (!ranlib.empty ()) { - text << "bin.ranlib\n" - << " exe " << ranlib << '\n' - << " id " << ari.ranlib_id << '\n' - << " signature " << ari.ranlib_signature << '\n' - << " checksum " << ari.ranlib_checksum; + dr << '\n' + << " ranlib " << ranlib << '\n' + << " id " << ari.ranlib_id << '\n' + << " signature " << ari.ranlib_signature << '\n' + << " checksum " << ari.ranlib_checksum; } } @@ -514,8 +514,8 @@ namespace build2 // if (verb >= (p.second ? 2 : 3)) { - text << "bin.ld\n" - << " exe " << ld << '\n' + text << "bin.ld " << project (r) << '@' << r.out_path () << '\n' + << " ld " << ld << '\n' << " id " << ldi.id << '\n' << " signature " << ldi.signature << '\n' << " checksum " << ldi.checksum; @@ -591,8 +591,8 @@ namespace build2 // if (verb >= (p.second ? 2 : 3)) { - text << "bin.rc\n" - << " exe " << rc << '\n' + text << "bin.rc " << project (r) << '@' << r.out_path () << '\n' + << " rc " << rc << '\n' << " id " << rci.id << '\n' << " signature " << rci.signature << '\n' << " checksum " << rci.checksum; diff --git a/build2/cli/module.cxx b/build2/cli/module.cxx index 6a6ab38..d6f99ba 100644 --- a/build2/cli/module.cxx +++ b/build2/cli/module.cxx @@ -26,8 +26,8 @@ namespace build2 static compile compile_; bool - init (scope& root, - scope& base, + init (scope& rs, + scope& bs, const location& loc, unique_ptr&, bool first, @@ -35,7 +35,7 @@ namespace build2 const variable_map& config_hints) { tracer trace ("cli::init"); - l5 ([&]{trace << "for " << base.out_path ();}); + l5 ([&]{trace << "for " << bs.out_path ();}); assert (config_hints.empty ()); // We don't known any hints. @@ -44,7 +44,7 @@ namespace build2 // the non-trivial variable merging semantics. So it is better to let // the user load cxx explicitly. // - if (!cast_false (base["cxx.loaded"])) + if (!cast_false (bs["cxx.loaded"])) fail (loc) << "cxx module must be loaded before cli"; // Enter module variables. @@ -64,7 +64,7 @@ namespace build2 // Register target types. // { - auto& t (base.target_types); + auto& t (bs.target_types); t.insert (); t.insert (); @@ -80,19 +80,20 @@ namespace build2 // We will only honor optional if the user didn't specify any cli // configuration explicitly. // - optional = optional && !config::specified (root, "config.cli"); + optional = optional && !config::specified (rs, "config.cli"); - // Don't re-run tests if the configuration says we are unconfigured. + // If the configuration says we are unconfigured, then we don't need to + // re-run tests, etc. But we may still need to print the config report. // - if (optional && config::unconfigured (root, "config.cli")) - return false; + bool unconf (optional && config::unconfigured (rs, "config.cli")); - // config.cli - // if (first) { - // Return version or empty string if unable to execute (e.g., - // the cli executable is not found). + // config.cli + // + + // Return version or empty string if unable to execute (e.g., the cli + // executable is not found). // auto test = [optional] (const path& cli) -> string { @@ -124,7 +125,7 @@ namespace build2 is.close (); // Don't block the other end. - if (!pr.wait ()) + if (!pr.wait ()) // Presumably issued diagnostics. return string (); // Not found. if (ver.empty ()) @@ -148,8 +149,9 @@ namespace build2 } }; - string ver; + string ver; // Empty means unconfigured. path cli ("cli"); // Default. + bool nv (false); // New value. if (optional) { @@ -157,59 +159,74 @@ namespace build2 // so that if we fail to configure, nothing will be written to // config.build. // - ver = test (cli); - - if (ver.empty ()) + if (!unconf) { - // Note that we are unconfigured so that we don't keep re-testing - // this on each run. - // - config::unconfigured (root, "config.cli", true); - - if (verb >= 2) - text << cli << " not found, leaving cli module unconfigured"; + ver = test (cli); - return false; - } - else - { - auto p (config::required (root, "config.cli", cli)); - assert (p.second && cast (p.first) == cli); + if (ver.empty ()) + { + // Note that we are unconfigured so that we don't keep + // re-testing this on each run. + // + config::unconfigured (rs, "config.cli", true); + unconf = true; + } + else + { + auto p (config::required (rs, "config.cli", cli)); + assert (p.second && cast (p.first) == cli); + } + + nv = true; } } else { - auto p (config::required (root, "config.cli", cli)); + auto p (config::required (rs, "config.cli", cli)); - // If we actually set a new value, test it by trying to execute. - // - if (p.second) - { - cli = cast (p.first); - ver = test (cli); + cli = cast (p.first); + ver = test (cli); - if (ver.empty ()) - throw failed (); - } + if (ver.empty ()) + throw failed (); // Diagnostics already issued. + + nv = p.second; } - if (!ver.empty () && verb >= 2) - text << cli << " " << ver; + // If this is a new value (e.g., we are configuring), then print the + // report at verbosity level 2 and up (-v). + // + if (verb >= (nv ? 2 : 3)) + { + diag_record dr (text); + dr << "cli " << project (rs) << '@' << rs.out_path () << '\n'; + + if (unconf) + dr << " cli " << "not found, leaving unconfigured"; + else + dr << " cli " << cli << '\n' + << " version " << ver; + } } + // Nothing else to do if we are unconfigured. + // + if (unconf) + return false; + // config.cli.options // // This one is optional. We also merge it into the corresponding // cli.* variables. See the cxx module for more information on // this merging semantics and some of its tricky aspects. // - base.assign ("cli.options") += cast_null ( - config::optional (root, "config.cli.options")); + bs.assign ("cli.options") += cast_null ( + config::optional (rs, "config.cli.options")); // Register our rules. // { - auto& r (base.rules); + auto& r (bs.rules); r.insert (perform_update_id, "cli.compile", compile_); r.insert (perform_clean_id, "cli.compile", compile_); diff --git a/build2/context b/build2/context index dc7d0c0..93cf5ad 100644 --- a/build2/context +++ b/build2/context @@ -8,13 +8,13 @@ #include #include +#include #include #include #include namespace build2 { - class scope; class file; extern dir_path work; @@ -58,6 +58,15 @@ namespace build2 variable_overrides reset (const strings& cmd_vars); + // Return the project name or empty string if unnamed. + // + inline const string& + project (scope& root) + { + auto l (root["project"]); + return l ? cast (l) : empty_string; + } + // Return the src/out directory corresponding to the given out/src. The // passed directory should be a sub-directory of out/src_root. // diff --git a/build2/cxx/module.cxx b/build2/cxx/module.cxx index 6ae7882..f66ef53 100644 --- a/build2/cxx/module.cxx +++ b/build2/cxx/module.cxx @@ -123,10 +123,8 @@ namespace build2 // if (verb >= (p.second ? 2 : 3)) { - //@@ Print project out root or name? Don't print if unnamed? - - text << "cxx\n" - << " exe " << cxx << '\n' + text << "cxx " << project (r) << '@' << r.out_path () << '\n' + << " cxx " << cxx << '\n' << " id " << ci.id << '\n' << " version " << ci.version.string << '\n' << " major " << ci.version.major << '\n' -- cgit v1.1