34 bool EndsWith(
const string& input,
const string& needle) {
35 return (input.size() >= needle.size() &&
36 input.substr(input.size() - needle.size()) == needle);
43 const string& deps_prefix) {
44 const string kDepsPrefixEnglish =
"Note: including file: ";
45 const char* in = line.c_str();
46 const char* end = in + line.size();
47 const string& prefix = deps_prefix.empty() ? kDepsPrefixEnglish : deps_prefix;
48 if (end - in > (
int)prefix.size() &&
49 memcmp(in, prefix.c_str(), (int)prefix.size()) == 0) {
53 return line.substr(in - line.c_str());
60 transform(path.begin(), path.end(), path.begin(),
ToLowerASCII);
62 return (path.find(
"program files") != string::npos ||
63 path.find(
"microsoft visual studio") != string::npos);
68 transform(line.begin(), line.end(), line.begin(),
ToLowerASCII);
70 return EndsWith(line,
".c") ||
71 EndsWith(line,
".cc") ||
72 EndsWith(line,
".cxx") ||
73 EndsWith(line,
".cpp");
78 string* filtered_output,
string* err) {
82 assert(&output != filtered_output);
88 while (start < output.size()) {
89 size_t end = output.find_first_of(
"\r\n", start);
90 if (end == string::npos)
92 string line = output.substr(start, end - start);
95 if (!include.empty()) {
98 if (!normalizer.
Normalize(include, &normalized, err))
102 normalized = include;
114 filtered_output->append(line);
115 filtered_output->append(
"\n");
118 if (end < output.size() && output[end] ==
'\r')
120 if (end < output.size() && output[end] ==
'\n')
static bool FilterInputFilename(string line)
Parse a line of cl.exe output and return true if it looks like it's printing an input filename...
static bool IsSystemInclude(string path)
Return true if a mentioned include file is a system path.
bool CanonicalizePath(string *path, uint64_t *slash_bits, string *err)
Canonicalize a path like "foo/../bar.h" into just "bar.h".
static string FilterShowIncludes(const string &line, const string &deps_prefix)
Parse a line of cl.exe output and extract /showIncludes info.
bool Normalize(const string &input, string *result, string *err) const
Normalize by fixing slashes style, fixing redundant .
#define METRIC_RECORD(name)
The primary interface to metrics.
Utility functions for normalizing include paths on Windows.
char ToLowerASCII(char c)
unsigned long long uint64_t
bool Parse(const string &output, const string &deps_prefix, string *filtered_output, string *err)
Parse the full output of cl, filling filtered_output with the text that should be printed (if any)...