Support all kinds of command line variables
This fixes #51. TODO: add tests for command line variables
diff --git a/eval.cc b/eval.cc
index db1b539..5c9055c 100644
--- a/eval.cc
+++ b/eval.cc
@@ -50,6 +50,7 @@
AssignOp op, bool is_override) {
VarOrigin origin = (
(is_bootstrap_ ? VarOrigin::DEFAULT :
+ is_commandline_ ? VarOrigin::COMMAND_LINE :
is_override ? VarOrigin::OVERRIDE : VarOrigin::FILE));
Var* rhs = NULL;
diff --git a/eval.h b/eval.h
index 3f32d5c..bf8c98a 100644
--- a/eval.h
+++ b/eval.h
@@ -61,6 +61,7 @@
void Error(const string& msg);
void set_is_bootstrap(bool b) { is_bootstrap_ = b; }
+ void set_is_commandline(bool c) { is_commandline_ = c; }
void set_current_scope(Vars* v) { current_scope_ = v; }
@@ -109,6 +110,7 @@
Loc loc_;
bool is_bootstrap_;
+ bool is_commandline_;
bool avoid_io_;
// This value tracks the nest level of make expressions. For
diff --git a/main.cc b/main.cc
index 2627bfd..5afe2b1 100644
--- a/main.cc
+++ b/main.cc
@@ -154,9 +154,14 @@
}
ev->set_is_bootstrap(false);
+ ev->set_is_commandline(true);
for (StringPiece l : cl_vars) {
- SetVar(l, VarOrigin::COMMAND_LINE);
+ vector<Stmt*> asts;
+ Parse(Intern(l).str(), Loc("*bootstrap*", 0), &asts);
+ CHECK(asts.size() == 1);
+ asts[0]->Eval(ev);
}
+ ev->set_is_commandline(false);
{
ScopedTimeReporter tr("eval time");