aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-10-19 10:44:52 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-10-19 10:44:52 +0200
commit83459829f24624e3cee20a7199af5c69e9678b69 (patch)
tree81774d67dac0829c39a351cfbfe8e7be808bb94d
parent9f9a7c8b7ab245fd20706ff9f6e834899b86b4e6 (diff)
Suggest override variable (config.x) when tool is not found
-rw-r--r--build2/bin/guess.cxx47
-rw-r--r--build2/cc/guess.cxx21
-rw-r--r--build2/cc/guess.hxx1
-rw-r--r--build2/cc/module.cxx1
-rw-r--r--build2/cli/init.cxx6
5 files changed, 63 insertions, 13 deletions
diff --git a/build2/bin/guess.cxx b/build2/bin/guess.cxx
index a142e59..78a1940 100644
--- a/build2/bin/guess.cxx
+++ b/build2/bin/guess.cxx
@@ -42,12 +42,29 @@ namespace build2
{
tracer trace ("bin::guess_ar");
+ process_path arp, rlp;
guess_result arr, rlr;
- process_path arp (run_search (ar, true, fallback));
- process_path rlp (rl != nullptr
- ? run_search (*rl, true, fallback)
- : process_path ());
+ {
+ auto df = make_diag_frame (
+ [](const diag_record& dr)
+ {
+ dr << info << "use config.bin.ar to override";
+ });
+
+ arp = run_search (ar, true, fallback);
+ }
+
+ if (rl != nullptr)
+ {
+ auto df = make_diag_frame (
+ [](const diag_record& dr)
+ {
+ dr << info << "use config.bin.ranlib to override";
+ });
+
+ rlp = run_search (*rl, true, fallback);
+ }
// Binutils, LLVM, and FreeBSD ar/ranlib all recognize the --version
// option. While Microsoft's lib.exe doesn't support --version, it only
@@ -244,7 +261,16 @@ namespace build2
guess_result r;
- process_path pp (run_search (ld, true, fallback));
+ process_path pp;
+ {
+ auto df = make_diag_frame (
+ [](const diag_record& dr)
+ {
+ dr << info << "use config.bin.ld to override";
+ });
+
+ pp = run_search (ld, true, fallback);
+ }
// Binutils ld recognizes the --version option. Microsoft's link.exe
// doesn't support --version (nor any other way to get the version
@@ -363,7 +389,16 @@ namespace build2
guess_result r;
- process_path pp (run_search (rc, true, fallback));
+ process_path pp;
+ {
+ auto df = make_diag_frame (
+ [](const diag_record& dr)
+ {
+ dr << info << "use config.bin.rc to override";
+ });
+
+ pp = run_search (rc, true, fallback);
+ }
// Binutils windres recognizes the --version option.
//
diff --git a/build2/cc/guess.cxx b/build2/cc/guess.cxx
index e9f85e3..e75a6ee 100644
--- a/build2/cc/guess.cxx
+++ b/build2/cc/guess.cxx
@@ -288,13 +288,22 @@ namespace build2
// Allowed to change pre if succeeds.
//
static guess_result
- guess (lang, const path& xc, string& pre)
+ guess (lang, const string& xv, const path& xc, string& pre)
{
tracer trace ("cc::guess");
guess_result r;
- process_path xp (run_search (xc, false /* init */)); // Note: cached.
+ process_path xp;
+ {
+ auto df = make_diag_frame (
+ [&xv](const diag_record& dr)
+ {
+ dr << info << "use " << xv << " to override";
+ });
+
+ xp = run_search (xc, false /* init */); // Note: cached.
+ }
// Start with -v. This will cover gcc and clang.
//
@@ -1450,6 +1459,7 @@ namespace build2
const compiler_info&
guess (lang xl,
+ const string& xv,
const path& xc,
const strings* c_po, const strings* x_po,
const strings* c_co, const strings* x_co,
@@ -1485,16 +1495,17 @@ namespace build2
if (!type.empty ())
{
- gr = guess (xl, xc, type);
+ gr = guess (xl, xv, xc, type);
if (gr.empty ())
- warn << xc << " name looks like " << type << " but it is not";
+ warn << xc << " looks like " << type << " but it is not" <<
+ info << "use " << xv << " to override";
type.clear ();
}
if (gr.empty ())
- gr = guess (xl, xc, type);
+ gr = guess (xl, xv, xc, type);
if (gr.empty ())
fail << "unable to guess " << xl << " compiler type of " << xc;
diff --git a/build2/cc/guess.hxx b/build2/cc/guess.hxx
index 599c56d..6e0281c 100644
--- a/build2/cc/guess.hxx
+++ b/build2/cc/guess.hxx
@@ -215,6 +215,7 @@ namespace build2
//
const compiler_info&
guess (lang,
+ const string& xv, // Override variable (config.x) for diagnostics.
const path& xc,
const strings* c_poptions, const strings* x_poptions,
const strings* c_coptions, const strings* x_coptions,
diff --git a/build2/cc/module.cxx b/build2/cc/module.cxx
index e9d5c09..76935f9 100644
--- a/build2/cc/module.cxx
+++ b/build2/cc/module.cxx
@@ -117,6 +117,7 @@ namespace build2
//
const path& xc (cast<path> (*p.first));
ci_ = &build2::cc::guess (x_lang,
+ config_x.name,
xc,
cast_null<strings> (rs[config_c_poptions]),
cast_null<strings> (rs[config_x_poptions]),
diff --git a/build2/cli/init.cxx b/build2/cli/init.cxx
index 4ad8a1a..bad2533 100644
--- a/build2/cli/init.cxx
+++ b/build2/cli/init.cxx
@@ -150,7 +150,8 @@ namespace build2
else
{
if (!optional)
- fail << cli << " is not command line interface compiler";
+ fail << cli << " is not command line interface compiler" <<
+ info << "use config.cli to override";
v.clear ();
}
@@ -178,7 +179,8 @@ namespace build2
// found). So it would be good to redirect child's STDERR.
//
if (!optional)
- error << "unable to execute " << args[0] << ": " << e;
+ error << "unable to execute " << args[0] << ": " << e <<
+ info << "use config.cli to override";
if (e.child)
exit (1);