From 6b30cf83699e3c492dcc0b7058eefc836f08dc78 Mon Sep 17 00:00:00 2001 From: HYUEHFJKhfjklkej <50876734+HYUEHFJKhfjklkej@users.noreply.github.com> Date: Sun, 10 May 2026 15:22:19 +0300 Subject: [PATCH] Document `conan.tools.gnu.is_mingw` helper Adds a reference page for `is_mingw()` mirroring the structure of `is_msvc` (`reference/tools/microsoft/helpers.rst`) and registers it in the `gnu` toctree. Companion to conan-io/conan PR #19963. --- reference/tools/gnu.rst | 1 + reference/tools/gnu/mingw.rst | 39 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 reference/tools/gnu/mingw.rst diff --git a/reference/tools/gnu.rst b/reference/tools/gnu.rst index 48e2e93734bc..b3f915772ff1 100644 --- a/reference/tools/gnu.rst +++ b/reference/tools/gnu.rst @@ -12,3 +12,4 @@ conan.tools.gnu gnu/makedeps gnu/pkgconfigdeps gnu/pkgconfig + gnu/mingw diff --git a/reference/tools/gnu/mingw.rst b/reference/tools/gnu/mingw.rst new file mode 100644 index 000000000000..2caca1f5fc40 --- /dev/null +++ b/reference/tools/gnu/mingw.rst @@ -0,0 +1,39 @@ +.. _conan_tools_gnu_mingw: + +is_mingw +======== + +.. currentmodule:: conan.tools.gnu + +.. autofunction:: is_mingw + +The helper detects a MinGW toolchain from the recipe settings: + +* ``os`` is ``"Windows"``; +* ``os.subsystem`` is **not** ``"cygwin"`` (Cygwin uses a POSIX layer + rather than a MinGW runtime); +* ``compiler`` is ``"gcc"``, **or** it is ``"clang"`` with no + ``compiler.runtime`` set. ``clang-cl`` declares ``compiler.runtime`` + and is therefore not classified as MinGW; see the + `Different flavors of Clang on Windows + `_ + blog post for the rationale. + +Pass ``build_context=True`` to inspect ``settings_build`` instead of the +host settings (mirrors :ref:`is_msvc `). + +Example: + +.. code-block:: python + + from conan import ConanFile + from conan.tools.gnu import is_mingw + + class Pkg(ConanFile): + settings = "os", "arch", "compiler", "build_type" + + def generate(self): + if is_mingw(self): + # MinGW-specific branch: Autotools-style build, MinGW + # import-library naming, etc. + ...