1 // Copyright 2015 Google Inc. All Rights Reserved.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 #ifndef NINJA_CLPARSER_H_
16 #define NINJA_CLPARSER_H_
22 /// Visual Studio's cl.exe requires some massaging to work with Ninja;
23 /// for example, it emits include information on stderr in a funny
24 /// format when building with /showIncludes. This class parses this
27 /// Parse a line of cl.exe output and extract /showIncludes info.
28 /// If a dependency is extracted, returns a nonempty string.
29 /// Exposed for testing.
30 static string FilterShowIncludes(const string& line,
31 const string& deps_prefix);
33 /// Return true if a mentioned include file is a system path.
34 /// Filtering these out reduces dependency information considerably.
35 static bool IsSystemInclude(string path);
37 /// Parse a line of cl.exe output and return true if it looks like
38 /// it's printing an input filename. This is a heuristic but it appears
39 /// to be the best we can do.
40 /// Exposed for testing.
41 static bool FilterInputFilename(string line);
43 /// Parse the full output of cl, filling filtered_output with the text that
44 /// should be printed (if any). Returns true on success, or false with err
45 /// filled. output must not be the same object as filtered_object.
46 bool Parse(const string& output, const string& deps_prefix,
47 string* filtered_output, string* err);
49 set<string> includes_;
52 #endif // NINJA_CLPARSER_H_