From 2ee43600a9090d1eb39a4bfd7fe70c795e16e7e9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 4 Dec 2023 10:47:16 +0200 Subject: Don't match predefs rule for unsupported compiler/version --- libbuild2/cc/predefs-rule.cxx | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'libbuild2/cc') 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:: -- cgit v1.1