summaryrefslogtreecommitdiffstats
path: root/src/graph.h
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-10-27 20:09:40 (GMT)
committerEvan Martin <martine@danga.com>2012-12-29 20:34:25 (GMT)
commit13dd08c1a03e5a8f4299816fbd3af1b6cb6d9642 (patch)
tree9564593d47936d2e47d88e344c2f6915ba8753a3 /src/graph.h
parent3249938cdf574058a066436aea06b0541ded6958 (diff)
downloadNinja-13dd08c1a03e5a8f4299816fbd3af1b6cb6d9642.zip
Ninja-13dd08c1a03e5a8f4299816fbd3af1b6cb6d9642.tar.gz
Ninja-13dd08c1a03e5a8f4299816fbd3af1b6cb6d9642.tar.bz2
rearrange handling of builtin bindings to make rules simpler
Now, a 'build' block can override any special binding like 'command' or 'description' if it needs to.
Diffstat (limited to 'src/graph.h')
-rw-r--r--src/graph.h43
1 files changed, 10 insertions, 33 deletions
diff --git a/src/graph.h b/src/graph.h
index 3c31e19..8b93e29 100644
--- a/src/graph.h
+++ b/src/graph.h
@@ -102,38 +102,23 @@ private:
/// An invokable build command and associated metadata (description, etc.).
struct Rule {
- explicit Rule(const string& name)
- : name_(name), generator_(false), restat_(false) {}
+ explicit Rule(const string& name) : name_(name) {}
const string& name() const { return name_; }
- bool generator() const { return generator_; }
- bool restat() const { return restat_; }
+ typedef map<string, EvalString> Bindings;
+ void AddBinding(const string& key, const EvalString& val);
- const EvalString& command() const { return command_; }
- const EvalString& description() const { return description_; }
- const EvalString& depfile() const { return depfile_; }
- const EvalString& rspfile() const { return rspfile_; }
- const EvalString& rspfile_content() const { return rspfile_content_; }
+ static bool IsReservedBinding(const string& var);
- /// Used by a test.
- void set_command(const EvalString& command) { command_ = command; }
+ const EvalString* GetBinding(const string& key) const;
private:
// Allow the parsers to reach into this object and fill out its fields.
friend struct ManifestParser;
string name_;
-
- bool generator_;
- bool restat_;
-
- EvalString command_;
- EvalString description_;
- EvalString depfile_;
- EvalString pool_;
- EvalString rspfile_;
- EvalString rspfile_content_;
+ map<string, EvalString> bindings_;
};
struct BuildLog;
@@ -153,17 +138,9 @@ struct Edge {
/// If incl_rsp_file is enabled, the string will also contain the
/// full contents of a response file (if applicable)
string EvaluateCommand(bool incl_rsp_file = false);
- string EvaluateDepFile();
- string GetDescription();
-
- /// Does the edge use a response file?
- bool HasRspFile();
-
- /// Get the path to the response file
- string GetRspFile();
- /// Get the contents of the response file
- string GetRspFileContent();
+ string GetBinding(const string& key);
+ bool GetBindingBool(const string& key);
void Dump(const char* prefix="") const;
@@ -171,7 +148,7 @@ struct Edge {
Pool* pool_;
vector<Node*> inputs_;
vector<Node*> outputs_;
- Env* env_;
+ BindingEnv* env_;
bool outputs_ready_;
const Rule& rule() const { return *rule_; }
@@ -220,7 +197,7 @@ struct DependencyScan {
bool RecomputeOutputDirty(Edge* edge, Node* most_recent_input,
const string& command, Node* output);
- bool LoadDepFile(Edge* edge, string* err);
+ bool LoadDepFile(Edge* edge, const string& path, string* err);
BuildLog* build_log() const {
return build_log_;