diff options
Diffstat (limited to 'libbuild2')
-rw-r--r-- | libbuild2/rule.cxx | 8 | ||||
-rw-r--r-- | libbuild2/target.cxx | 29 | ||||
-rw-r--r-- | libbuild2/target.hxx | 17 | ||||
-rw-r--r-- | libbuild2/target.ixx | 2 |
4 files changed, 42 insertions, 14 deletions
diff --git a/libbuild2/rule.cxx b/libbuild2/rule.cxx index 7ccee4e..4b2d69d 100644 --- a/libbuild2/rule.cxx +++ b/libbuild2/rule.cxx @@ -94,13 +94,15 @@ namespace build2 // derivation function to treat this as a prerequisite (just like in // search_existing_file()). // - if (pt->derive_extension (true) == nullptr) + if (const string* e = pt->derive_extension (true)) + { + p = &pt->derive_path_with_extension (*e); + } + else { l4 ([&]{trace << "no default extension for target " << *pt;}); return false; } - - p = &pt->derive_path (); } ts = mtime (*p); diff --git a/libbuild2/target.cxx b/libbuild2/target.cxx index 0b67dc3..34f3f72 100644 --- a/libbuild2/target.cxx +++ b/libbuild2/target.cxx @@ -678,6 +678,15 @@ namespace build2 const path& path_target:: derive_path (const char* de, const char* np, const char* ns, const char* ee) { + return derive_path_with_extension (derive_extension (de), np, ns, ee); + } + + const path& path_target:: + derive_path_with_extension (const string& e, + const char* np, + const char* ns, + const char* ee) + { path_type p (dir); if (np == nullptr || np[0] == '\0') @@ -691,22 +700,22 @@ namespace build2 if (ns != nullptr) p += ns; - return derive_path (move (p), de, ee); + return derive_path_with_extension (move (p), e, ee); } const path& path_target:: derive_path (path_type p, const char* de, const char* ee) { - // Derive and add the extension if any. - // - { - const string& e (derive_extension (de)); + return derive_path_with_extension (move (p), derive_extension (de), ee); + } - if (!e.empty ()) - { - p += '.'; - p += e; - } + const path& path_target:: + derive_path_with_extension (path_type p, const string& e, const char* ee) + { + if (!e.empty ()) + { + p += '.'; + p += e; } if (ee != nullptr) diff --git a/libbuild2/target.hxx b/libbuild2/target.hxx index 091b2d8..6022274 100644 --- a/libbuild2/target.hxx +++ b/libbuild2/target.hxx @@ -1577,6 +1577,15 @@ namespace build2 const char* name_suffix = nullptr, const char* extra_ext = nullptr); + // As above but with the already derived (by calling derive_extension()) + // extension. + // + const path_type& + derive_path_with_extension (const string& ext, + const char* name_prefix = nullptr, + const char* name_suffix = nullptr, + const char* extra_ext = nullptr); + // This version can be used to derive the path from another target's path // by adding another extension. // @@ -1585,6 +1594,14 @@ namespace build2 const char* default_ext = nullptr, const char* extra_ext = nullptr); + // As above but with the already derived (by calling derive_extension()) + // extension. + // + const path_type& + derive_path_with_extension (path_type base, + const string& ext, + const char* extra_ext = nullptr); + // As above but only derives (and returns) the extension (empty means no // extension used). // diff --git a/libbuild2/target.ixx b/libbuild2/target.ixx index 822aff9..3d92c78 100644 --- a/libbuild2/target.ixx +++ b/libbuild2/target.ixx @@ -545,7 +545,7 @@ namespace build2 { // You may be wondering why don't we spin the transition out? The reason // is it shouldn't matter since were we called just a moment earlier, we - // would have seen it. + // wouldn't have seen it. // return path_state_.load (memory_order_acquire) == 2 ? path_ : empty_path; } |