diff options
author | Nico Weber <nicolasweber@gmx.de> | 2015-06-12 06:53:32 (GMT) |
---|---|---|
committer | Nico Weber <thakis@chromium.org> | 2016-04-06 01:08:32 (GMT) |
commit | 3a889126247d31d637c7470554be12f7c1df2ffa (patch) | |
tree | 9b66b601fc2b0296f3d1ac95aee6a20c176c0568 /src/msvc_helper-win32.cc | |
parent | aea5a4d41ff626f46a06a245f54f1175712470f8 (diff) | |
download | Ninja-3a889126247d31d637c7470554be12f7c1df2ffa.zip Ninja-3a889126247d31d637c7470554be12f7c1df2ffa.tar.gz Ninja-3a889126247d31d637c7470554be12f7c1df2ffa.tar.bz2 |
Make deps=msvc experimentally available on non-Windows.
This makes it possible to run most of the clparser tests on non-Windows,
and is potentially useful for cross-compiling on non-Windows hosts.
Also, the manual didn't document this as Windows-only previously.
If you use this on non-Windows, please let me know, else I might undo
this change again in the future.
Diffstat (limited to 'src/msvc_helper-win32.cc')
-rw-r--r-- | src/msvc_helper-win32.cc | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/src/msvc_helper-win32.cc b/src/msvc_helper-win32.cc index d516240..e37a26e 100644 --- a/src/msvc_helper-win32.cc +++ b/src/msvc_helper-win32.cc @@ -14,23 +14,12 @@ #include "msvc_helper.h" -#include <algorithm> -#include <assert.h> -#include <stdio.h> -#include <string.h> #include <windows.h> -#include "includes_normalize.h" #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); -} - string Replace(const string& input, const string& find, const string& replace) { string result = input; size_t start_pos = 0; @@ -48,78 +37,6 @@ string EscapeForDepfile(const string& path) { return Replace(path, " ", "\\ "); } -// static -string CLParser::FilterShowIncludes(const string& line, - const string& deps_prefix) { - const string kDepsPrefixEnglish = "Note: including file: "; - const char* in = line.c_str(); - const char* end = in + line.size(); - const string& prefix = deps_prefix.empty() ? kDepsPrefixEnglish : deps_prefix; - if (end - in > (int)prefix.size() && - memcmp(in, prefix.c_str(), (int)prefix.size()) == 0) { - in += prefix.size(); - while (*in == ' ') - ++in; - return line.substr(in - line.c_str()); - } - return ""; -} - -// static -bool CLParser::IsSystemInclude(string path) { - transform(path.begin(), path.end(), path.begin(), ::tolower); - // TODO: this is a heuristic, perhaps there's a better way? - return (path.find("program files") != string::npos || - path.find("microsoft visual studio") != string::npos); -} - -// static -bool CLParser::FilterInputFilename(string line) { - transform(line.begin(), line.end(), line.begin(), ::tolower); - // TODO: other extensions, like .asm? - return EndsWith(line, ".c") || - EndsWith(line, ".cc") || - EndsWith(line, ".cxx") || - EndsWith(line, ".cpp"); -} - -bool CLParser::Parse(const string& output, const string& deps_prefix, - string* filtered_output, string* err) { - // Loop over all lines in the output to process them. - assert(&output != filtered_output); - size_t start = 0; - while (start < output.size()) { - size_t end = output.find_first_of("\r\n", start); - if (end == string::npos) - end = output.size(); - string line = output.substr(start, end - start); - - string include = FilterShowIncludes(line, deps_prefix); - if (!include.empty()) { - string normalized; - if (!IncludesNormalize::Normalize(include, NULL, &normalized, err)) - return false; - if (!IsSystemInclude(normalized)) - includes_.insert(normalized); - } 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 { - filtered_output->append(line); - filtered_output->append("\n"); - } - - if (end < output.size() && output[end] == '\r') - ++end; - if (end < output.size() && output[end] == '\n') - ++end; - start = end; - } - - return true; -} - int CLWrapper::Run(const string& command, string* output) { SECURITY_ATTRIBUTES security_attributes = {}; security_attributes.nLength = sizeof(SECURITY_ATTRIBUTES); |