summaryrefslogtreecommitdiffstats
path: root/src/msvc_helper-win32.cc
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-08-12 22:09:33 (GMT)
committerEvan Martin <martine@danga.com>2012-08-12 22:09:33 (GMT)
commitc963c4834d0ab05ce8ecf341c74db6ded379fa8a (patch)
tree46473deed3a5eb66fca363fcf1f13c54578df144 /src/msvc_helper-win32.cc
parent1843f550d9b8b6d271cefdfb5fffd150bb8ef069 (diff)
downloadNinja-c963c4834d0ab05ce8ecf341c74db6ded379fa8a.zip
Ninja-c963c4834d0ab05ce8ecf341c74db6ded379fa8a.tar.gz
Ninja-c963c4834d0ab05ce8ecf341c74db6ded379fa8a.tar.bz2
msvc helper: attempt to filter out when it prints the input filename
This is a heuristic but it appears to work for the Chrome build.
Diffstat (limited to 'src/msvc_helper-win32.cc')
-rw-r--r--src/msvc_helper-win32.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/msvc_helper-win32.cc b/src/msvc_helper-win32.cc
index ac957e4..f6b2a22 100644
--- a/src/msvc_helper-win32.cc
+++ b/src/msvc_helper-win32.cc
@@ -19,6 +19,16 @@
#include "util.h"
+namespace {
+
+/// Return true if \a input ends with \a needle.
+bool EndsWith(const string& input, const string& needle) {
+ return (input.size() >= needle.size() &&
+ input.substr(input.size() - needle.size()) == needle);
+}
+
+} // anonymous namespace
+
// static
string CLWrapper::FilterShowIncludes(const string& line) {
static const char kMagicPrefix[] = "Note: including file: ";
@@ -35,6 +45,15 @@ string CLWrapper::FilterShowIncludes(const string& line) {
return "";
}
+// static
+bool CLWrapper::FilterInputFilename(const string& line) {
+ // TODO: other extensions, like .asm?
+ return EndsWith(line, ".c") ||
+ EndsWith(line, ".cc") ||
+ EndsWith(line, ".cxx") ||
+ EndsWith(line, ".cpp");
+}
+
int CLWrapper::Run(const string& command, string* extra_output) {
SECURITY_ATTRIBUTES security_attributes = {};
security_attributes.nLength = sizeof(SECURITY_ATTRIBUTES);
@@ -97,6 +116,10 @@ int CLWrapper::Run(const string& command, string* extra_output) {
string include = FilterShowIncludes(line);
if (!include.empty()) {
includes_.push_back(include);
+ } else if (FilterInputFilename(line)) {
+ // Drop it.
+ // TODO: if we support compiling multiple output files in a single
+ // cl.exe invocation, we should stash the filename.
} else {
if (extra_output) {
extra_output->append(line);