aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/file.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-11-09 07:42:38 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-11-09 07:42:38 +0200
commit4e547cad02a41d020895eda83088865fecef069a (patch)
treec35d908156d46044e0c46b5ce4dbd6e2aa990cbf /libbuild2/file.cxx
parentca5da0f6dcbd272691f0a5e1c8030f65030cccce (diff)
Make process exit diagnostics in executable metadata extraction consistent
Diffstat (limited to 'libbuild2/file.cxx')
-rw-r--r--libbuild2/file.cxx41
1 files changed, 30 insertions, 11 deletions
diff --git a/libbuild2/file.cxx b/libbuild2/file.cxx
index a3039a2..8666520 100644
--- a/libbuild2/file.cxx
+++ b/libbuild2/file.cxx
@@ -1862,13 +1862,13 @@ namespace build2
try
{
// Note: not using run_*() functions since need to be able to suppress
- // all errors, including inability to exec.
+ // all errors, including abnormal, inability to exec, etc., in case of
+ // optional import. Also, no need to buffer diagnostics since in the
+ // serial load.
//
if (verb >= 3)
print_process (args);
- // @@ DBUF: diag
-
process pr (pp,
args,
-2 /* stdin to /dev/null */,
@@ -1924,10 +1924,19 @@ namespace build2
return r;
if (!opt)
- error (loc) << "invalid metadata signature in " << args[0]
- << " output" <<
+ {
+ diag_record dr;
+ dr << error (loc) << "invalid metadata signature in " << args[0]
+ << " output" <<
info << "expected '" << s << "'";
+ if (verb >= 1 && verb <= 2)
+ {
+ dr << info << "command line: ";
+ print_process (dr, args);
+ }
+ }
+
goto fail;
}
@@ -1943,16 +1952,27 @@ namespace build2
if (pr.wait ())
{
if (!opt)
- error (loc) << "unable to read metadata from " << args[0];
+ error (loc) << "io error reading metadata from " << args[0];
}
else
{
// The child process presumably issued diagnostics but if it didn't,
- // the result will be very confusing. So let's issue something
- // generic for good measure.
+ // the result will be very confusing. So let's issue something generic
+ // for good measure. But also make it consistent with diagnostics
+ // issued by run_finish().
//
if (!opt)
- error (loc) << "unable to extract metadata from " << args[0];
+ {
+ diag_record dr;
+ dr << error (loc) << "unable to extract metadata from " << args[0] <<
+ info << "process " << args[0] << " " << *pr.exit;
+
+ if (verb >= 1 && verb <= 2)
+ {
+ dr << info << "command line: ";
+ print_process (dr, args);
+ }
+ }
}
goto fail;
@@ -1968,8 +1988,7 @@ namespace build2
goto fail;
}
- fail:
-
+ fail:
if (opt)
{
metadata_cache.insert (pp.effect_string (), true);