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 std::string &output, const std::string &deps_prefix, std::string *filtered_output, std::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 (std::string line)
 Parse a line of cl.exe output and return true if it looks like it's printing an input filename. More...
 
static std::string FilterShowIncludes (const std::string &line, const std::string &deps_prefix)
 Parse a line of cl.exe output and extract /showIncludes info. More...
 
static bool IsSystemInclude (std::string path)
 Return true if a mentioned include file is a system path. More...
 

Public Attributes

std::set< std::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 25 of file clparser.h.

Member Function Documentation

◆ FilterInputFilename()

bool CLParser::FilterInputFilename ( std::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 69 of file clparser.cc.

References ToLowerASCII().

Referenced by TEST().

◆ FilterShowIncludes()

string CLParser::FilterShowIncludes ( const std::string &  line,
const std::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 44 of file clparser.cc.

Referenced by TEST().

◆ IsSystemInclude()

bool CLParser::IsSystemInclude ( std::string  path)
static

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

Filtering these out reduces dependency information considerably.

Definition at line 61 of file clparser.cc.

References ToLowerASCII().

◆ Parse()

bool CLParser::Parse ( const std::string &  output,
const std::string &  deps_prefix,
std::string *  filtered_output,
std::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 80 of file clparser.cc.

References CanonicalizePath(), METRIC_RECORD, and IncludesNormalize::Normalize().

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

Member Data Documentation

◆ includes_

std::set<std::string> CLParser::includes_

Definition at line 48 of file clparser.h.

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


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