diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-03-07 14:36:51 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-03-07 14:36:51 +0200 |
commit | 7de6f6f275d840e8d9523c72d8f4309c51b4dcd3 (patch) | |
tree | 4b0387fe8f80db3ea6214aea330c03f3d1145c08 /build/spec.cxx | |
parent | 897a0e4fdf9ca90ee8d236a38e138a8ae6bc3627 (diff) |
Add support for buildspec
Diffstat (limited to 'build/spec.cxx')
-rw-r--r-- | build/spec.cxx | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/build/spec.cxx b/build/spec.cxx new file mode 100644 index 0000000..fb83b31 --- /dev/null +++ b/build/spec.cxx @@ -0,0 +1,89 @@ +// file : build/spec.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +#include <build/spec> + +#include <ostream> + +#include <build/diagnostics> + +using namespace std; + +namespace build +{ + ostream& + operator<< (ostream& os, const targetspec& s) + { + if (!s.src_root.empty ()) + { + string d (diag_relative_work (s.src_root)); + + if (d != ".") + { + os << d; + + // Add the directory separator unless it is already there. + // + if (d.back () != path::traits::directory_separator) + os << path::traits::directory_separator; + + os << '='; + } + } + + os << s.target; + return os; + } + + ostream& + operator<< (ostream& os, const opspec& s) + { + bool ho (!s.operation.empty ()); + bool ht (!s.empty ()); + + //os << s.operation; + os << (ho ? "\"" : "") << s.operation << (ho ? "\"" : ""); + + if (ho && ht) + os << '('; + + for (auto b (s.begin ()), i (b); i != s.end (); ++i) + os << (i != b ? " " : "") << *i; + + if (ho && ht) + os << ')'; + + return os; + } + + ostream& + operator<< (ostream& os, const metaopspec& s) + { + bool hm (!s.meta_operation.empty ()); + bool ho (!s.empty ()); + + //os << s.meta_operation; + os << (hm ? "\'" : "") << s.meta_operation << (hm ? "\'" : ""); + + if (hm && ho) + os << '('; + + for (auto b (s.begin ()), i (b); i != s.end (); ++i) + os << (i != b ? " " : "") << *i; + + if (hm && 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; + } +} |