27 : state_(state), file_reader_(file_reader) {
34 *err =
"loading '" + filename +
"': " + read_err;
37 contents.resize(contents.size() + 10);
38 return Parse(filename, contents, err);
69 if (!
ParseLet(&name, &let_value, err))
74 if (name ==
"ninja_required_version")
112 return lexer_.
Error(
"duplicate pool '" + name +
"'", err);
122 if (key ==
"depth") {
124 depth = atol(depth_string.c_str());
128 return lexer_.
Error(
"unexpected variable '" + key +
"'", err);
133 return lexer_.
Error(
"expected 'depth =' line", err);
149 *err =
"duplicate rule '" + name +
"'";
166 return lexer_.
Error(
"unexpected variable '" + key +
"'", err);
170 if (rule->
bindings_[
"rspfile"].empty() !=
171 rule->
bindings_[
"rspfile_content"].empty()) {
172 return lexer_.
Error(
"rspfile and rspfile_content need to be "
173 "both specified", err);
177 return lexer_.
Error(
"expected 'command =' line", err);
211 }
while (!eval.
empty());
220 vector<EvalString> ins, outs;
235 }
while (!out.
empty());
243 return lexer_.
Error(
"expected build command name", err);
247 return lexer_.
Error(
"unknown build rule '" + rule_name +
"'", err);
306 if (!pool_name.empty()) {
313 for (vector<EvalString>::iterator i = ins.begin(); i != ins.end(); ++i) {
314 string path = i->Evaluate(env);
320 for (vector<EvalString>::iterator i = outs.begin(); i != outs.end(); ++i) {
321 string path = i->Evaluate(env);
332 if (!deps_type.empty() && edge->
outputs_.size() > 1) {
333 return lexer_.
Error(
"multiple outputs aren't (yet?) supported by depslog; "
334 "bring this up on the mailing list if it affects you",
351 return lexer_.
Error(
"loading '" + path +
"': " + read_err, err);
360 if (!subparser.
Parse(path, contents, err))
371 if (token != expected) {
void AddIn(Edge *edge, StringPiece path)
static bool IsReservedBinding(const string &var)
virtual bool ReadFile(const string &path, string *content, string *err)=0
bool ParsePool(string *err)
Parse various statement types.
Pool * LookupPool(const string &pool_name)
void UnreadToken()
Rewind to the last read Token.
bool Load(const string &filename, string *err)
Load and parse a file.
static const char * TokenErrorHint(Token expected)
Return a human-readable token hint, used in error messages.
bool PeekToken(Token token)
If the next token is token, read it and return true.
An edge in the dependency graph; links between Nodes using Rules.
bool Error(const string &message, string *err)
Construct an error message with context.
void CheckNinjaVersion(const string &version)
Check whether version is compatible with the current Ninja version, aborting if not.
bool CanonicalizePath(string *path, string *err)
Canonicalize a path like "foo/../bar.h" into just "bar.h".
Token ReadToken()
Read a Token from the Token enum.
bool ReadPath(EvalString *path, string *err)
Read a path (complete with $escapes).
Edge * AddEdge(const Rule *rule)
An Env which contains a mapping of variables to values as well as a pointer to a parent scope...
void AddOut(Edge *edge, StringPiece path)
bool ParseEdge(string *err)
void AddRule(const Rule *rule)
An invokable build command and associated metadata (description, etc.).
string DescribeLastError()
If the last token read was an ERROR token, provide more info or the empty string. ...
A pool for delayed edges.
bool ParseLet(string *key, EvalString *val, string *err)
#define METRIC_RECORD(name)
The primary interface to metrics.
bool ReadIdent(string *out)
Read a simple identifier (a rule or variable name).
void AddBinding(const string &key, const EvalString &val)
bool ExpectToken(Lexer::Token expected, string *err)
If the next token is not expected, produce an error string saying "expectd foo, got bar"...
bool ReadVarValue(EvalString *value, string *err)
Read the value side of a var = value line (complete with $escapes).
bool AddDefault(StringPiece path, string *error)
string GetBinding(const string &key)
bool ParseRule(string *err)
void AddBinding(const string &key, const string &val)
static const char * TokenName(Token t)
Return a human-readable form of a token, used in error messages.
Global state (file status, loaded rules) for a single run.
map< string, EvalString > bindings_
FileReader * file_reader_
string Evaluate(Env *env) const
bool ParseFileInclude(bool new_scope, string *err)
Parse either a 'subninja' or 'include' line.
A tokenized string that contains variable references.
bool Parse(const string &filename, const string &input, string *err)
Parse a file, given its contents as a string.
bool ParseDefault(string *err)
const Rule * LookupRule(const string &rule_name)
void Start(StringPiece filename, StringPiece input)
Start parsing some input.
ManifestParser(State *state, FileReader *file_reader)
vector< Node * > outputs_