From a89f1e4f4efd291beedea03c65c8185b7d0df20e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 7 Dec 2017 12:06:59 +0200 Subject: Distinguish between "fixed" and "default" target extensions This fixes wrong merging of, say, file{README} and file{README.MySQL} (in libmysqlclient). --- build2/target-type.hxx | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'build2/target-type.hxx') diff --git a/build2/target-type.hxx b/build2/target-type.hxx index 0b8ee54..16513d4 100644 --- a/build2/target-type.hxx +++ b/build2/target-type.hxx @@ -23,13 +23,16 @@ namespace build2 // any target type. As a result, we can use address comparison to determine // if two target types are the same. // - // If the extension derivation function is NULL, then it means this target + // If the extension derivation functions are NULL, then it means this target // type does not use extensions. Note that this is relied upon when deciding // whether to print the extension; if the target does use extensions but the - // defaults could not (and its ok), could not (and its not ok), or should not + // defaults couldn't (and its ok), couldn't (and its not ok), or shouldn't // (logically) be obtained, then use target_extension_{null,fail,assert}(), - // respectively. If the extension function returns NULL, then that means the - // default extension for this target could not be derived. + // respectively. The fixed extension function should return the fixed + // extension (which can point to the key's ext member if the explicit + // extension specificaton is allowed). If the default extension function + // returns NULL, then it means the default extension for this target could + // not be derived. // // The extension is used in two places: search_existing_file() (called for a // prerequisite with the last argument true) and in target::derive_path() @@ -45,17 +48,12 @@ namespace build2 const char* name; const target_type* base; - // Return target and extension. - // - pair> (*factory) (const target_type&, - dir_path, - dir_path, - string, - optional); - - optional (*extension) (const target_key&, - const scope&, - bool search); + target* (*factory) (const target_type&, dir_path, dir_path, string); + + const char* (*fixed_extension) (const target_key&); + optional (*default_extension) (const target_key&, + const scope&, + bool search); bool (*pattern) (const target_type&, const scope&, string&, bool reverse); -- cgit v1.1