aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-12-04 10:47:16 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-12-04 10:47:16 +0200
commit2ee43600a9090d1eb39a4bfd7fe70c795e16e7e9 (patch)
treef039f77061e7aa17b35d8cb069eafa98cba3c7bc /libbuild2
parentfc84d5b527a17a5360d375ade4cdc17e4f8a6b88 (diff)
Don't match predefs rule for unsupported compiler/version
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/cc/predefs-rule.cxx25
1 files changed, 24 insertions, 1 deletions
diff --git a/libbuild2/cc/predefs-rule.cxx b/libbuild2/cc/predefs-rule.cxx
index c8a8181..e74192d 100644
--- a/libbuild2/cc/predefs-rule.cxx
+++ b/libbuild2/cc/predefs-rule.cxx
@@ -25,10 +25,33 @@ namespace build2
bool predefs_rule::
match (action, target&, const string& hint, match_extra&) const
{
+ tracer trace (x, "predefs_rule::match");
+
// We only match with an explicit hint (failed that, we will turn every
// header into predefs).
//
- return hint == rule_name;
+ if (hint == rule_name)
+ {
+ // Don't match if unsupported compiler. In particular, this allows the
+ // user to provide a fallback rule.
+ //
+ switch (cclass)
+ {
+ case compiler_class::gcc: return true;
+ case compiler_class::msvc:
+ {
+ // Only MSVC 19.20 or later. Not tested with clang-cl.
+ //
+ if (cvariant.empty () && (cmaj > 19 || (cmaj == 19 && cmin >= 20)))
+ return true;
+
+ l4 ([&]{trace << "unsupported compiler/version";});
+ break;
+ }
+ }
+ }
+
+ return false;
}
recipe predefs_rule::