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-key.hxx | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'build2/target-key.hxx') diff --git a/build2/target-key.hxx b/build2/target-key.hxx index b7335eb..f37713e 100644 --- a/build2/target-key.hxx +++ b/build2/target-key.hxx @@ -6,6 +6,7 @@ #define BUILD2_TARGET_KEY_HXX #include +#include // strcmp() #include // compare_c_string @@ -46,14 +47,25 @@ namespace build2 inline bool operator== (const target_key& x, const target_key& y) { - // Unspecified and specified extension are assumed equal. + if (x.type != y.type || + *x.dir != *y.dir || + *x.out != *y.out || + *x.name != *y.name) + return false; + + // Unless fixed, unspecified and specified extensions are assumed equal. // - return - x.type == y.type && - *x.dir == *y.dir && - *x.out == *y.out && - *x.name == *y.name && - (!x.ext || !y.ext || *x.ext == *y.ext); + const target_type& tt (*x.type); + + if (tt.fixed_extension == nullptr) + return !x.ext || !y.ext || *x.ext == *y.ext; + else + { + const char* xe (x.ext ? x.ext->c_str () : tt.fixed_extension (x)); + const char* ye (y.ext ? y.ext->c_str () : tt.fixed_extension (y)); + + return strcmp (xe, ye) == 0; + } } inline bool -- cgit v1.1