aboutsummaryrefslogtreecommitdiff
path: root/build/context.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-03-25 14:48:36 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-03-25 14:48:36 +0200
commitcd75e06a87aa74aa6968113107afa53d401d20bc (patch)
tree1e104829d10f375a783d6efbbf7eef3e2c6d2ef5 /build/context.cxx
parenta94dcda7f00b10cb22b5f2138b1c29bcfbe7de37 (diff)
Configure/disfigure src_root saving/removing support; fsdir{} injection
We can now build out-of-tree.
Diffstat (limited to 'build/context.cxx')
-rw-r--r--build/context.cxx57
1 files changed, 57 insertions, 0 deletions
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 <ostream>
#include <cassert>
+#include <system_error>
#include <build/scope>
+#include <build/diagnostics>
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 <build/path-map> 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)
{