aboutsummaryrefslogtreecommitdiff
path: root/build2/cxx/compile.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-08-02 13:34:14 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-08-02 13:34:14 +0200
commit1ae0cd48961c6340fe16dc62d888096773d57cc0 (patch)
tree8ce7c8862d448b2cb4853f28f6ce7ccac4f00916 /build2/cxx/compile.cxx
parent9469a7be982f5ab17e201c0b62ee555720ac6303 (diff)
Filter gratuitous VC cl.exe and link.exe messages
Diffstat (limited to 'build2/cxx/compile.cxx')
-rw-r--r--build2/cxx/compile.cxx49
1 files changed, 37 insertions, 12 deletions
diff --git a/build2/cxx/compile.cxx b/build2/cxx/compile.cxx
index c737ce7..5e7a1b2 100644
--- a/build2/cxx/compile.cxx
+++ b/build2/cxx/compile.cxx
@@ -7,6 +7,7 @@
#include <map>
#include <limits> // numeric_limits
#include <cstdlib> // exit()
+#include <iostream> // cerr
#include <butl/path-map>
@@ -1211,7 +1212,7 @@ namespace build2
// we need to copy the diagnostics for the user to see.
//
if (!is.eof () && cid == "msvc" && bad_error)
- *diag_stream << is.rdbuf ();
+ cerr << is.rdbuf ();
is.close ();
@@ -1248,6 +1249,11 @@ namespace build2
}
}
+ // Filter cl.exe noise (msvc.cxx).
+ //
+ void
+ msvc_filter_cl (ifdstream&, const path& src);
+
target_state compile::
perform_update (action a, target& xt)
{
@@ -1406,19 +1412,38 @@ namespace build2
try
{
- // @@ VC prints file name being compiled to stdout as the first
- // line, would be good to weed it out (but check if it is
- // always printed, for example if the file does not exist).
- // Seems always. The same story with link.exe when creating
- // the DLL.
+ // VC cl.exe sends diagnostics to stdout. It also prints the file name
+ // being compiled as the first line. So for cl.exe we redirect stdout
+ // to a pipe, filter that noise out, and send the rest to stderr.
//
-
- // VC++ cl.exe sends diagnostics to stdout. To fix this (and any other
- // insane compilers that may want to do something like this) we are
- // going to always redirect stdout to stderr. For sane compilers this
- // should be harmless.
+ // For other compilers redirect stdout to stderr, in case any of them
+ // tries to pull off something similar. For sane compilers this should
+ // be harmless.
//
- process pr (args.data (), 0, 2);
+ bool filter (cid == "msvc");
+
+ process pr (args.data (), 0, (filter ? -1 : 2));
+
+ if (filter)
+ {
+ try
+ {
+ ifdstream is (pr.in_ofd, fdstream_mode::text, ifdstream::badbit);
+
+ msvc_filter_cl (is, rels);
+
+ // If anything remains in the stream, send it all to stderr. Note
+ // that the eos check is important: if the stream is at eos, this
+ // and all subsequent writes to cerr will fail (and you won't see
+ // a thing).
+ //
+ if (is.peek () != ifdstream::traits_type::eof ())
+ cerr << is.rdbuf ();
+
+ is.close ();
+ }
+ catch (const ifdstream::failure&) {} // Assume exits with error.
+ }
if (!pr.wait ())
throw failed ();