aboutsummaryrefslogtreecommitdiff
path: root/build2/target-key.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-12-07 12:06:59 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-12-07 12:06:59 +0200
commita89f1e4f4efd291beedea03c65c8185b7d0df20e (patch)
treed06b2cb81720ae0c6cc877c2c67201838a10b63a /build2/target-key.hxx
parentc2da5df68610a0070575212bfee67c730ab39128 (diff)
Distinguish between "fixed" and "default" target extensions
This fixes wrong merging of, say, file{README} and file{README.MySQL} (in libmysqlclient).
Diffstat (limited to 'build2/target-key.hxx')
-rw-r--r--build2/target-key.hxx26
1 files changed, 19 insertions, 7 deletions
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 <map>
+#include <cstring> // strcmp()
#include <libbutl/utility.mxx> // 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