aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-04-02 15:44:49 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-04-02 15:44:49 +0200
commit137df0bea6cebabe5278e67e5dad6f3047c762fb (patch)
tree2ea23a35f99d21a4d9eca89ed71ac9ba2a734f52
parent65dca85d0acc1ae69518e85b52a2877e38dc8c6d (diff)
Handle "nothing to be done" case for disfigure
-rw-r--r--build/algorithm.cxx2
-rw-r--r--build/config/operation.cxx48
-rw-r--r--build/context23
-rw-r--r--build/context.cxx2
-rw-r--r--build/context.txx4
-rw-r--r--build/cxx/module.cxx2
6 files changed, 59 insertions, 22 deletions
diff --git a/build/algorithm.cxx b/build/algorithm.cxx
index d649210..87e2259 100644
--- a/build/algorithm.cxx
+++ b/build/algorithm.cxx
@@ -328,7 +328,7 @@ namespace build
//
file& ft (dynamic_cast<file&> (t));
- bool r (rmfile (ft.path (), ft) == rmfile_status::success);
+ bool r (rmfile (ft.path (), ft));
// Update timestamp in case there are operations after us that
// could use the information.
diff --git a/build/config/operation.cxx b/build/config/operation.cxx
index 3269f9d..6886752 100644
--- a/build/config/operation.cxx
+++ b/build/config/operation.cxx
@@ -112,12 +112,12 @@ namespace build
const list_value& lv (dynamic_cast<const list_value&> (*pval));
ofs << var.name << " = " << lv.data << endl;
- text << var.name << " = " << lv.data;
+ //text << var.name << " = " << lv.data;
}
else
{
ofs << var.name << " =" << endl; // @@ TODO: [undefined]
- text << var.name << " = [undefined]";
+ //text << var.name << " = [undefined]";
}
}
}
@@ -230,6 +230,8 @@ namespace build
const path& out_root (root.path ());
const path& src_root (root.src_path ());
+ bool m (false); // Keep track of whether we actually did anything.
+
// We distinguish between a complete disfigure and operation-
// specific.
//
@@ -237,27 +239,49 @@ namespace build
{
level4 ([&]{trace << "completely disfiguring " << out_root;});
- rmfile (out_root / config_file);
+ m = rmfile (out_root / config_file) || m;
if (out_root != src_root)
{
- rmfile (out_root / src_root_file);
+ m = rmfile (out_root / src_root_file) || m;
// Clean up the directories.
//
- rmdir (out_root / bootstrap_dir);
- rmdir (out_root / build_dir);
-
- if (rmdir (out_root) == rmdir_status::not_empty)
- warn << "directory " << out_root.string () << " is "
- << (out_root == work
- ? "current working directory"
- : "not empty") << ", not removing";
+ m = rmdir (out_root / bootstrap_dir) || m;
+ m = rmdir (out_root / build_dir) || m;
+
+ switch (rmdir (out_root))
+ {
+ case rmdir_status::not_empty:
+ {
+ warn << "directory " << out_root.string () << " is "
+ << (out_root == work
+ ? "current working directory"
+ : "not empty") << ", not removing";
+ break;
+ }
+ case rmdir_status::success:
+ m = true;
+ default:
+ break;
+ }
}
}
else
{
}
+
+ if (!m)
+ {
+ // Create a dir{$out_root/} target to signify the project's
+ // root in diagnostics. Not very clean but seems harmless.
+ //
+ target& t (
+ targets.insert (
+ dir::static_type, out_root, "", nullptr, trace).first);
+
+ info << diag_already_done (a, t);
+ }
}
}
diff --git a/build/context b/build/context
index 723f9f9..8ebce26 100644
--- a/build/context
+++ b/build/context
@@ -32,12 +32,25 @@ namespace build
void
reset ();
+ // The dual interface wrapper for the {mk,rm}{file,dir}() functions
+ // below that allows you to use it as a true/false return or a more
+ // detailed enum from <filesystem>
+ //
+ template <typename T>
+ struct fs_status
+ {
+ T v;
+ fs_status (T v): v (v) {};
+ operator T () const {return v;}
+ explicit operator bool () const {return v == T::success;}
+ };
+
// Create the directory and print the standard diagnostics. Note that
// this implementation is not suitable if it is expected that the
// directory will exist in the majority of case and performance is
// important. See the fsdir{} rule for details.
//
- mkdir_status
+ fs_status<mkdir_status>
mkdir (const path&);
// Remove the file and print the standard diagnostics. The second
@@ -46,19 +59,19 @@ namespace build
// being printed.
//
template <typename T>
- rmfile_status
+ fs_status<rmfile_status>
rmfile (const path&, const T& target);
- inline rmfile_status
+ inline fs_status<rmfile_status>
rmfile (const path& f) {return rmfile (f, f);}
// Similar to rmfile() but for directories.
//
template <typename T>
- rmdir_status
+ fs_status<rmdir_status>
rmdir (const path&, const T& target);
- inline rmdir_status
+ inline fs_status<rmdir_status>
rmdir (const path& d) {return rmdir (d, d);}
// Return the src/out directory corresponding to the given out/src. The
diff --git a/build/context.cxx b/build/context.cxx
index 69b10d7..a0952ec 100644
--- a/build/context.cxx
+++ b/build/context.cxx
@@ -42,7 +42,7 @@ namespace build
global_scope->variables["home"] = home;
}
- mkdir_status
+ fs_status<mkdir_status>
mkdir (const path& d)
{
// We don't want to print the command if the directory already
diff --git a/build/context.txx b/build/context.txx
index cae1ce8..53081b1 100644
--- a/build/context.txx
+++ b/build/context.txx
@@ -9,7 +9,7 @@
namespace build
{
template <typename T>
- rmfile_status
+ fs_status<rmfile_status>
rmfile (const path& f, const T& t)
{
// We don't want to print the command if we couldn't remove the
@@ -45,7 +45,7 @@ namespace build
}
template <typename T>
- rmdir_status
+ fs_status<rmdir_status>
rmdir (const path& d, const T& t)
{
bool w (d == work); // Don't try to remove working directory.
diff --git a/build/cxx/module.cxx b/build/cxx/module.cxx
index 1179ce3..04b1ae5 100644
--- a/build/cxx/module.cxx
+++ b/build/cxx/module.cxx
@@ -92,7 +92,7 @@ namespace build
throw failed ();
}
- text << "toolchain version " << ver;
+ //text << "toolchain version " << ver;
// Set on the project root.
//