From 5f58a7c870f617feba6bf132e5e12e8f1dc24e6a Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Fri, 10 Jan 2025 14:28:35 +0100 Subject: [PATCH] tool: Add `is_like_clang_cl()` getter In `ring` we need to check if the compiler is `clang-cl` to prevent overwriting it with `clang` (see all details in https://github.com/briansmith/ring/issues/2215), but `cc-rs` does not currently expose this despite already tracking it. By adding this getter we can steer that logic to not overwrite the compiler when it is `clang-cl`. Perhaps, since `ToolFamily` is `pub` (but not yet reexported from `lib.rs`), could we have a public `Tool::family()` getter to not have to extend these `is_xxx()` getters whenever a downstream crate wants to know something new? --- src/tool.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tool.rs b/src/tool.rs index ad606060..af43a918 100644 --- a/src/tool.rs +++ b/src/tool.rs @@ -421,6 +421,11 @@ impl Tool { matches!(self.family, ToolFamily::Msvc { .. }) } + /// Whether the tool is `clang-cl`-based MSVC-like. + pub fn is_like_clang_cl(&self) -> bool { + matches!(self.family, ToolFamily::Msvc { clang_cl: true }) + } + /// Supports using `--` delimiter to separate arguments and path to source files. pub(crate) fn supports_path_delimiter(&self) -> bool { matches!(