From ace1743f7f78bb13f99553d6e97ad1beecf1ba99 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 13 Apr 2015 15:50:17 +0200 Subject: Add separate type to represent directory paths --- build/prerequisite.cxx | 58 +++++++++++++++++++------------------------------- 1 file changed, 22 insertions(+), 36 deletions(-) (limited to 'build/prerequisite.cxx') diff --git a/build/prerequisite.cxx b/build/prerequisite.cxx index aa6c53c..5d3235c 100644 --- a/build/prerequisite.cxx +++ b/build/prerequisite.cxx @@ -18,52 +18,38 @@ namespace build ostream& operator<< (ostream& os, const prerequisite& p) { - if (p.target != nullptr) - os << *p.target; - else + // Print scope unless the prerequisite's directory is absolute. + // + if (!p.dir.absolute ()) { - os << p.type.name << '{'; - - // Print scope unless the directory is absolute. - // - if (!p.dir.absolute ()) - { - string s (diag_relative (p.scope.path ())); + string s (diag_relative (p.scope.path (), false)); - if (s != ".") - { - os << s; - - if (s.back () != path::traits::directory_separator) - os << path::traits::directory_separator; - - os << ": "; - } - } + if (!s.empty ()) + os << s << ':'; + } - // Print directory. - // - if (!p.dir.empty ()) - { - string s (diag_relative (p.dir)); + // If the name is empty, then we want to print the directory + // inside {}, e.g., dir{bar/}, not bar/dir{}. + // + bool n (!p.name.empty ()); + string d (diag_relative (p.dir, false)); - if (s != ".") - { - os << s; + if (n) + os << d; - if (!p.name.empty () && - s.back () != path::traits::directory_separator) - os << path::traits::directory_separator; - } - } + os << p.type.name << '{'; + if (n) + { os << p.name; if (p.ext != nullptr && !p.ext->empty ()) os << '.' << *p.ext; - - os << '}'; } + else + os << d; + + os << '}'; return os; } @@ -89,7 +75,7 @@ namespace build // auto prerequisite_set:: insert (const target_type& tt, - path dir, + dir_path dir, std::string name, const std::string* ext, scope& s, -- cgit v1.1