From cd75e06a87aa74aa6968113107afa53d401d20bc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 25 Mar 2015 14:48:36 +0200 Subject: Configure/disfigure src_root saving/removing support; fsdir{} injection We can now build out-of-tree. --- build/context.cxx | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'build/context.cxx') diff --git a/build/context.cxx b/build/context.cxx index e9434f7..92f3db9 100644 --- a/build/context.cxx +++ b/build/context.cxx @@ -6,8 +6,10 @@ #include #include +#include #include +#include using namespace std; @@ -19,6 +21,61 @@ namespace build execution_mode current_mode; const target_rule_map* current_rules; + void + reset () + { + targets.clear (); + scopes.clear (); + variable_pool.clear (); + + // Create root scope. For Win32 we use the empty path since there + // is no such "real" root path. On POSIX, however, this is a real + // path. See the comment in for details. + // +#ifdef _WIN32 + root_scope = &scopes[path ()]; +#else + root_scope = &scopes[path ("/")]; +#endif + + root_scope->variables["work"] = work; + root_scope->variables["home"] = home; + } + + mkdir_status + mkdir (const path& d) + { + // We don't want to print the command if the directory already + // exists. This makes the below code a bit ugly. + // + mkdir_status ms; + + try + { + ms = try_mkdir (d); + } + catch (const system_error& e) + { + if (verb >= 1) + text << "mkdir " << d.string (); + else + text << "mkdir " << d; + + fail << "unable to create directory " << d.string () << ": " + << e.what (); + } + + if (ms == mkdir_status::success) + { + if (verb >= 1) + text << "mkdir " << d.string (); + else + text << "mkdir " << d; + } + + return ms; + } + path src_out (const path& out, scope& s) { -- cgit v1.1