aboutsummaryrefslogtreecommitdiff
path: root/build/diagnostics.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-04-02 15:06:55 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-04-02 15:06:55 +0200
commit65dca85d0acc1ae69518e85b52a2877e38dc8c6d (patch)
tree7e2f1c227d5114d30b8c84e2d9f6af826a36066a /build/diagnostics.cxx
parent48f8883de7b8fa348423b3baf262de08c98eba18 (diff)
Implement translation of meta/operations to natural language
Diffstat (limited to 'build/diagnostics.cxx')
-rw-r--r--build/diagnostics.cxx99
1 files changed, 99 insertions, 0 deletions
diff --git a/build/diagnostics.cxx b/build/diagnostics.cxx
index 43ee0e5..aab7675 100644
--- a/build/diagnostics.cxx
+++ b/build/diagnostics.cxx
@@ -4,8 +4,12 @@
#include <build/diagnostics>
+#include <sstream>
#include <iostream>
+#include <build/scope>
+#include <build/target>
+#include <build/operation>
#include <build/context>
#include <build/utility>
@@ -53,6 +57,101 @@ namespace build
return p.string ();
}
+ // diag_do(), etc.
+ //
+ string
+ diag_do (const action& a, const target& t)
+ {
+ // @@ root scope
+ //
+ scope& root (
+ scopes.find (
+ scopes.find (t.dir)["out_root"].as<const path&> ()));
+
+ const meta_operation_info& mi (root.meta_operations[a.meta_operation ()]);
+ const operation_info& oi (root.operations[a.operation ()]);
+
+ ostringstream os;
+
+ // perform(update(x)) -> "update x"
+ // configure(update(x)) -> "configure updating x"
+ //
+ if (mi.name_do.empty ())
+ os << oi.name_do << ' ';
+ else
+ {
+ os << mi.name_do << ' ';
+
+ if (!oi.name_doing.empty ())
+ os << oi.name_doing << ' ';
+ }
+
+ os << t;
+ return os.str ();
+ }
+
+ string
+ diag_doing (const action& a, const target& t)
+ {
+ // @@ root scope
+ //
+ scope& root (
+ scopes.find (
+ scopes.find (t.dir)["out_root"].as<const path&> ()));
+
+ const meta_operation_info& mi (root.meta_operations[a.meta_operation ()]);
+ const operation_info& oi (root.operations[a.operation ()]);
+
+ ostringstream os;
+
+ // perform(update(x)) -> "updating x"
+ // configure(update(x)) -> "configuring updating x"
+ //
+ if (!mi.name_doing.empty ())
+ os << mi.name_doing << ' ';
+
+ if (!oi.name_doing.empty ())
+ os << oi.name_doing << ' ';
+
+ os << t;
+ return os.str ();
+ }
+
+ string
+ diag_already_done (const action& a, const target& t)
+ {
+ // @@ root scope
+ //
+ scope& root (
+ scopes.find (
+ scopes.find (t.dir)["out_root"].as<const path&> ()));
+
+ const meta_operation_info& mi (root.meta_operations[a.meta_operation ()]);
+ const operation_info& oi (root.operations[a.operation ()]);
+
+ ostringstream os;
+
+ // perform(update(x)) -> "x is already up to date"
+ // configure(update(x)) -> "updating x is already configured"
+ //
+ if (mi.name_already_done.empty ())
+ {
+ os << t;
+
+ if (!oi.name_already_done.empty ())
+ os << " is already " << oi.name_already_done;
+ }
+ else
+ {
+ if (!oi.name_doing.empty ())
+ os << oi.name_doing << ' ';
+
+ os << t << " is already " << mi.name_already_done;
+ }
+
+ return os.str ();
+ }
+
void
print_process (const char* const* args)
{