diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-04-13 15:50:17 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-04-13 15:50:17 +0200 |
commit | ace1743f7f78bb13f99553d6e97ad1beecf1ba99 (patch) | |
tree | 595bc9dad989e44f4be9a67e351219f3248dc5f0 /build/prerequisite.cxx | |
parent | 534f9d8db025d58c9ce23f3b81a37e8c34386a27 (diff) |
Add separate type to represent directory paths
Diffstat (limited to 'build/prerequisite.cxx')
-rw-r--r-- | build/prerequisite.cxx | 58 |
1 files changed, 22 insertions, 36 deletions
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, |