From 46148127855b2ddc9c5c58ae286f06c2ddac9fc3 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Thu, 8 Dec 2022 15:57:27 +0100 Subject: [PATCH] add conan.tools.gnu.is_mingw() --- conan/tools/gnu/__init__.py | 1 + conan/tools/gnu/mingw.py | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 conan/tools/gnu/mingw.py diff --git a/conan/tools/gnu/__init__.py b/conan/tools/gnu/__init__.py index a7c75b32404..bd515ad6128 100644 --- a/conan/tools/gnu/__init__.py +++ b/conan/tools/gnu/__init__.py @@ -1,5 +1,6 @@ from conan.tools.gnu.autotools import Autotools from conan.tools.gnu.autotoolstoolchain import AutotoolsToolchain from conan.tools.gnu.autotoolsdeps import AutotoolsDeps +from conan.tools.gnu.mingw import is_mingw from conan.tools.gnu.pkgconfig import PkgConfig from conan.tools.gnu.pkgconfigdeps import PkgConfigDeps diff --git a/conan/tools/gnu/mingw.py b/conan/tools/gnu/mingw.py new file mode 100644 index 00000000000..cab3cc3fe52 --- /dev/null +++ b/conan/tools/gnu/mingw.py @@ -0,0 +1,12 @@ +def is_mingw(conanfile): + """ + Validate if current compiler in host setttings is related to MinGW + + :return: True, if the host compiler is related to MinGW, otherwise False. + """ + host_os = conanfile.settings.get_safe("os") + host_compiler = conanfile.settings.get_safe("compiler") + is_mingw_gcc = host_os == "Windows" and host_compiler == "gcc" + is_mingw_clang = host_os == "Windows" and host_compiler == "clang" and \ + not conanfile.settings.get_safe("compiler.runtime") + return is_mingw_gcc or is_mingw_clang