Skip to content

Commit 3858fd5

Browse files
committed
add conan.tools.gnu.is_mingw()
1 parent d23c1b4 commit 3858fd5

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

conan/tools/gnu/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from conan.tools.gnu.autotools import Autotools
22
from conan.tools.gnu.autotoolstoolchain import AutotoolsToolchain
33
from conan.tools.gnu.autotoolsdeps import AutotoolsDeps
4+
from conan.tools.gnu.mingw import is_mingw
45
from conan.tools.gnu.pkgconfig import PkgConfig
56
from conan.tools.gnu.pkgconfigdeps import PkgConfigDeps

conan/tools/gnu/mingw.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def is_mingw(conanfile):
2+
"""
3+
Validate if current compiler in host setttings is related to MinGW
4+
5+
:return: True, if the host compiler is related to MinGW, otherwise False.
6+
"""
7+
host_os = conanfile.settings.get_safe("os")
8+
host_compiler = conanfile.settings.get_safe("compiler")
9+
mingw_gcc = host_os == "Windows" and host_compiler == "gcc"
10+
mingw_clang = host_os == "Windows" and host_compiler == "clang" and \
11+
not conanfile.settings.get_safe("compiler.runtime")
12+
return mingw_gcc or mingw_clang

0 commit comments

Comments
 (0)