From 7de6f6f275d840e8d9523c72d8f4309c51b4dcd3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 7 Mar 2015 14:36:51 +0200 Subject: Add support for buildspec --- build/spec.cxx | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 build/spec.cxx (limited to 'build/spec.cxx') 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 + +#include + +#include + +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; + } +} -- cgit v1.1