aboutsummaryrefslogtreecommitdiff
path: root/build/context.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-08-27 15:11:40 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-08-27 15:11:40 +0200
commitfd689eb883655dcb29e505b041cd02fac01f0bac (patch)
tree0d85ec32d95a1c96eaa7eff28734b900c44dd3ca /build/context.cxx
parent7f2d06258d57e39940e8fa959336da0ea66fe37f (diff)
Dist module/meta-operation initial implementation
Diffstat (limited to 'build/context.cxx')
-rw-r--r--build/context.cxx40
1 files changed, 31 insertions, 9 deletions
diff --git a/build/context.cxx b/build/context.cxx
index 3e3d0c3..aaeb426 100644
--- a/build/context.cxx
+++ b/build/context.cxx
@@ -47,6 +47,7 @@ namespace build
meta_operation_table.insert ("perform");
meta_operation_table.insert ("configure");
meta_operation_table.insert ("disfigure");
+ meta_operation_table.insert ("dist");
operation_table.clear ();
operation_table.insert ("default");
@@ -100,17 +101,13 @@ namespace build
{
rule_map& rs (global_scope->rules);
- rs.insert<alias> (default_id, "alias", alias_rule::instance);
- rs.insert<alias> (update_id, "alias", alias_rule::instance);
- rs.insert<alias> (clean_id, "alias", alias_rule::instance);
+ rs.insert<alias> (perform_id, 0, "alias", alias_rule::instance);
- rs.insert<fsdir> (default_id, "fsdir", fsdir_rule::instance);
- rs.insert<fsdir> (update_id, "fsdir", fsdir_rule::instance);
- rs.insert<fsdir> (clean_id, "fsdir", fsdir_rule::instance);
+ rs.insert<fsdir> (perform_id, update_id, "fsdir", fsdir_rule::instance);
+ rs.insert<fsdir> (perform_id, clean_id, "fsdir", fsdir_rule::instance);
- rs.insert<file> (default_id, "file", file_rule::instance);
- rs.insert<file> (update_id, "file", file_rule::instance);
- rs.insert<file> (clean_id, "file", file_rule::instance);
+ rs.insert<file> (perform_id, update_id, "file", file_rule::instance);
+ rs.insert<file> (perform_id, clean_id, "file", file_rule::instance);
}
}
@@ -162,6 +159,31 @@ namespace build
return ms;
}
+ fs_status<butl::rmdir_status>
+ rmdir_r (const dir_path& d)
+ {
+ using namespace butl;
+
+ if (work.sub (d)) // Don't try to remove working directory.
+ return rmdir_status::not_empty;
+
+ if (!dir_exists (d))
+ return rmdir_status::not_exist;
+
+ text << "rmdir -r " << d;
+
+ try
+ {
+ butl::rmdir_r (d);
+ }
+ catch (const std::system_error& e)
+ {
+ fail << "unable to remove directory " << d << ": " << e.what ();
+ }
+
+ return rmdir_status::success;
+ }
+
dir_path
src_out (const dir_path& out, scope& s)
{