aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/spec.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-06-24 12:01:19 +0200
committerKaren Arutyunov <karen@codesynthesis.com>2019-07-01 18:13:55 +0300
commit977d07a3ae47ef204665d1eda2d642e5064724f3 (patch)
tree525a3d6421f61ce789b690191d3c30fc09be3517 /libbuild2/spec.cxx
parent7161b24963dd9da4d218f92c736b77c35c328a2d (diff)
Split build system into library and driver
Diffstat (limited to 'libbuild2/spec.cxx')
-rw-r--r--libbuild2/spec.cxx111
1 files changed, 111 insertions, 0 deletions
diff --git a/libbuild2/spec.cxx b/libbuild2/spec.cxx
new file mode 100644
index 0000000..3ad6b7d
--- /dev/null
+++ b/libbuild2/spec.cxx
@@ -0,0 +1,111 @@
+// file : libbuild2/spec.cxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+#include <libbuild2/spec.hxx>
+
+#include <libbuild2/context.hxx>
+#include <libbuild2/diagnostics.hxx>
+
+using namespace std;
+
+namespace build2
+{
+ ostream&
+ operator<< (ostream& os, const targetspec& s)
+ {
+ if (!s.src_base.empty ())
+ {
+ // Avoid printing './' in './@...', similar to what we do for the
+ // {target,prerequisite}_key.
+ //
+ if (stream_verb (os).path < 1)
+ {
+ const string& r (diag_relative (s.src_base, false));
+
+ if (!r.empty ())
+ os << r << '@';
+ }
+ else
+ os << s.src_base << '@';
+ }
+
+ os << s.name;
+ return os;
+ }
+
+ ostream&
+ operator<< (ostream& os, const opspec& s)
+ {
+ bool hn (!s.name.empty ());
+ bool ht (!s.empty ());
+
+ os << (hn ? "\"" : "") << s.name << (hn ? "\"" : "");
+
+ if (hn && ht)
+ os << '(';
+
+ for (auto b (s.begin ()), i (b); i != s.end (); ++i)
+ os << (i != b ? " " : "") << *i;
+
+ for (const value& v: s.params)
+ {
+ os << ", ";
+
+ if (v)
+ {
+ names storage;
+ os << reverse (v, storage);
+ }
+ else
+ os << "[null]";
+ }
+
+ if (hn && ht)
+ os << ')';
+
+ return os;
+ }
+
+ ostream&
+ operator<< (ostream& os, const metaopspec& s)
+ {
+ bool hn (!s.name.empty ());
+ bool ho (!s.empty ());
+
+ os << (hn ? "\'" : "") << s.name << (hn ? "\'" : "");
+
+ if (hn && ho)
+ os << '(';
+
+ for (auto b (s.begin ()), i (b); i != s.end (); ++i)
+ os << (i != b ? " " : "") << *i;
+
+ for (const value& v: s.params)
+ {
+ os << ", ";
+
+ if (v)
+ {
+ names storage;
+ os << reverse (v, storage);
+ }
+ else
+ os << "[null]";
+ }
+
+ if (hn && ho)
+ os << ')';
+
+ return os;
+ }
+
+ ostream&
+ operator<< (ostream& os, const buildspec& s)
+ {
+ for (auto b (s.begin ()), i (b); i != s.end (); ++i)
+ os << (i != b ? " " : "") << *i;
+
+ return os;
+ }
+}