aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/project/mingw.py
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-03-30 02:34:03 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-03-30 02:53:51 +0300
commit39902041e7671a94abcf691fa4a769b5cb4fc4fb (patch)
tree9ea5e61c6f49913aa81c7ba0bddb85127c8fc0dd /project/mingw.py
parentproject.cmake.build: refactoring (diff)
downloadcmake-common-39902041e7671a94abcf691fa4a769b5cb4fc4fb.tar.gz
cmake-common-39902041e7671a94abcf691fa4a769b5cb4fc4fb.zip
project.cmake: make it --platform aware
Diffstat (limited to '')
-rw-r--r--project/mingw.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/project/mingw.py b/project/mingw.py
new file mode 100644
index 0000000..1e136cd
--- /dev/null
+++ b/project/mingw.py
@@ -0,0 +1,37 @@
+# Copyright (c) 2020 Egor Tensin <Egor.Tensin@gmail.com>
+# This file is part of the "cmake-common" project.
+# For details, see https://github.com/egor-tensin/cmake-common.
+# Distributed under the MIT License.
+
+from project.os import on_windows_like
+
+
+def _get_compiler_prefix(platform):
+ target_arch = platform.get_address_model()
+ if target_arch == 32:
+ return 'i686'
+ if target_arch == 64:
+ return 'x86_64'
+ raise RuntimeError(f'unexpected address model: {target_arch}')
+
+
+def _get(platform, what):
+ prefix = _get_compiler_prefix(platform)
+ ext = ''
+ if on_windows_like():
+ # Boost.Build wants the .exe extension at the end on Cygwin.
+ ext = '.exe'
+ path = f'{prefix}-w64-mingw32-{what}{ext}'
+ return path
+
+
+def get_gcc(platform):
+ return _get(platform, 'gcc')
+
+
+def get_gxx(platform):
+ return _get(platform, 'g++')
+
+
+def get_windres(platform):
+ return _get(platform, 'windres')