aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/project/mingw.py
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-03-20 13:16:15 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-03-20 14:34:32 +0300
commite731e6345d7fa1c2326b18c56f5dc361ea3adbfb (patch)
treecc72442867919028eda33b264c02eab47ca3a049 /project/mingw.py
parentworkflows/basic: enable on windows-2016 (diff)
downloadcmake-common-e731e6345d7fa1c2326b18c56f5dc361ea3adbfb.tar.gz
cmake-common-e731e6345d7fa1c2326b18c56f5dc361ea3adbfb.zip
project.platform: add platform 'auto'
There were two problems: * On Windows, VS 2019 defaults to x64 while VS 2017 defaults to x86. * Too much focus on x86(-64) might mean that building stuff on ARM can become difficult. These were all addressed by adding a new platform 'auto'. On Windows, it defaults to picking either x64 or x86 (depending on the host arch) for both Boost and CMake. On Linux, it lets the compiler decide what arch to target.
Diffstat (limited to 'project/mingw.py')
-rw-r--r--project/mingw.py42
1 files changed, 15 insertions, 27 deletions
diff --git a/project/mingw.py b/project/mingw.py
index 731cee9..4ac921f 100644
--- a/project/mingw.py
+++ b/project/mingw.py
@@ -4,36 +4,24 @@
# Distributed under the MIT License.
-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}')
+class MinGW:
+ def __init__(self, platform):
+ self.prefix = platform.mingw_prefix()
+ def _get(self, what):
+ return f'{self.prefix}-w64-mingw32-{what}'
-def _get(platform, what):
- prefix = _get_compiler_prefix(platform)
- path = f'{prefix}-w64-mingw32-{what}'
- return path
+ def gcc(self):
+ return self._get('gcc')
+ def gxx(self):
+ return self._get('g++')
-def get_gcc(platform):
- return _get(platform, 'gcc')
+ def ar(self):
+ return self._get('gcc-ar')
+ def ranlib(self):
+ return self._get('gcc-ranlib')
-def get_gxx(platform):
- return _get(platform, 'g++')
-
-
-def get_ar(platform):
- return _get(platform, 'gcc-ar')
-
-
-def get_ranlib(platform):
- return _get(platform, 'gcc-ranlib')
-
-
-def get_windres(platform):
- return _get(platform, 'windres')
+ def windres(self):
+ return self._get('windres')