summaryrefslogtreecommitdiffstats
path: root/src/msvc_helper-win32.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/msvc_helper-win32.cc')
-rw-r--r--src/msvc_helper-win32.cc26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/msvc_helper-win32.cc b/src/msvc_helper-win32.cc
index 8e440fe..fd9b671 100644
--- a/src/msvc_helper-win32.cc
+++ b/src/msvc_helper-win32.cc
@@ -14,6 +14,7 @@
#include "msvc_helper.h"
+#include <stdio.h>
#include <string.h>
#include <windows.h>
@@ -28,6 +29,21 @@ bool EndsWith(const string& input, const string& needle) {
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;
+ while ((start_pos = result.find(find, start_pos)) != string::npos) {
+ result.replace(start_pos, find.length(), replace);
+ start_pos += replace.length();
+ }
+ return result;
+}
+
+string EscapeForDepfile(const string& path) {
+ // Depfiles don't escape single \.
+ return Replace(path, " ", "\\ ");
+}
+
} // anonymous namespace
// static
@@ -125,7 +141,7 @@ int CLWrapper::Run(const string& command, string* extra_output) {
if (!include.empty()) {
include = IncludesNormalize::Normalize(include, NULL);
if (!IsSystemInclude(include))
- includes_.push_back(include);
+ includes_.insert(include);
} else if (FilterInputFilename(line)) {
// Drop it.
// TODO: if we support compiling multiple output files in a single
@@ -162,3 +178,11 @@ int CLWrapper::Run(const string& command, string* extra_output) {
return exit_code;
}
+
+vector<string> CLWrapper::GetEscapedResult() {
+ vector<string> result;
+ for (set<string>::iterator i = includes_.begin(); i != includes_.end(); ++i) {
+ result.push_back(EscapeForDepfile(*i));
+ }
+ return result;
+}