diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-12-16 12:00:53 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-12-16 12:00:53 +0200 |
commit | 44e1022f8141bd57756c2be4277c728ca7443eb3 (patch) | |
tree | 4b3d7e4be8c79d00acc52aec7f1cf64d184f9f73 /build2/target.cxx | |
parent | 497353a7eeec26d35741afd45b7cd759105f0246 (diff) |
Redo string/stream representation of dir{} name/target
Now instead of:
dir{foo/bar/}
We get:
foo/dir{bar/}
Which feels more consistent with how we print other names/targets. That is,
"directory bar/ in directory foo/" similar how foo/exe{bar} is "executable
bar in directory foo/".
Diffstat (limited to 'build2/target.cxx')
-rw-r--r-- | build2/target.cxx | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/build2/target.cxx b/build2/target.cxx index aca977e..99c002b 100644 --- a/build2/target.cxx +++ b/build2/target.cxx @@ -418,19 +418,24 @@ namespace build2 ostream& to_stream (ostream& os, const target_key& k, uint16_t ev) { - // If the name is empty, then we want to print the directory - // inside {}, e.g., dir{bar/}, not bar/dir{}. + uint16_t dv (stream_verb (os)); // Directory verbosity. + + // If the name is empty, then we want to print the last component of the + // directory inside {}, e.g., dir{bar/}, not bar/dir{}. // bool n (!k.name->empty ()); - if (n) + // Note: relative() returns empty for './'. + // + const dir_path& rd (dv < 2 ? relative (*k.dir) : *k.dir); // Relative. + const dir_path& pd (n ? rd : rd.directory ()); // Parent. + + if (!pd.empty ()) { - // Avoid printing './' in './{...}' - // - if (stream_verb (os) < 2) - os << diag_relative (*k.dir, false); + if (dv < 2) + os << diag_relative (pd); else - os << *k.dir; + os << pd.representation (); } const target_type& tt (*k.type); @@ -459,7 +464,7 @@ namespace build2 assert (!k.ext); } else - os << *k.dir; + os << (rd.empty () ? dir_path (".") : rd.leaf ()).representation (); os << '}'; @@ -467,7 +472,7 @@ namespace build2 // if (!k.out->empty ()) { - if (stream_verb (os) < 2) + if (dv < 2) { // Don't print '@./'. // |