Ninja
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
CLParser Struct Reference

Visual Studio's cl.exe requires some massaging to work with Ninja; for example, it emits include information on stderr in a funny format when building with /showIncludes. More...

#include <clparser.h>

Public Member Functions

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). More...
 

Static Public Member Functions

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. More...
 
static string FilterShowIncludes (const string &line, const string &deps_prefix)
 Parse a line of cl.exe output and extract /showIncludes info. More...
 
static bool IsSystemInclude (string path)
 Return true if a mentioned include file is a system path. More...
 

Public Attributes

set< string > includes_
 

Detailed Description

Visual Studio's cl.exe requires some massaging to work with Ninja; for example, it emits include information on stderr in a funny format when building with /showIncludes.

This class parses this output.

Definition at line 26 of file clparser.h.

Member Function Documentation

◆ FilterInputFilename()

bool CLParser::FilterInputFilename ( string  line)
static

Parse a line of cl.exe output and return true if it looks like it's printing an input filename.

This is a heuristic but it appears to be the best we can do. Exposed for testing.

Definition at line 67 of file clparser.cc.

References ToLowerASCII().

Referenced by Parse(), and TEST().

◆ FilterShowIncludes()

string CLParser::FilterShowIncludes ( const string &  line,
const string &  deps_prefix 
)
static

Parse a line of cl.exe output and extract /showIncludes info.

If a dependency is extracted, returns a nonempty string. Exposed for testing.

Definition at line 42 of file clparser.cc.

Referenced by Parse(), and TEST().

◆ IsSystemInclude()

bool CLParser::IsSystemInclude ( string  path)
static

Return true if a mentioned include file is a system path.

Filtering these out reduces dependency information considerably.

Definition at line 59 of file clparser.cc.

References ToLowerASCII().

Referenced by Parse().

◆ Parse()

bool CLParser::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).

Returns true on success, or false with err filled. output must not be the same object as filtered_object.

Definition at line 77 of file clparser.cc.

References CanonicalizePath(), FilterInputFilename(), FilterShowIncludes(), includes_, IsSystemInclude(), METRIC_RECORD, and IncludesNormalize::Normalize().

Referenced by Builder::ExtractDeps(), main(), MSVCHelperMain(), and TEST().

Member Data Documentation

◆ includes_

set<string> CLParser::includes_

Definition at line 49 of file clparser.h.

Referenced by Builder::ExtractDeps(), Parse(), and TEST().


The documentation for this struct was generated from the following files: