aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/project/boost
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/boost
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/boost')
-rw-r--r--project/boost/build.py15
-rw-r--r--project/boost/toolchain.py41
2 files changed, 25 insertions, 31 deletions
diff --git a/project/boost/build.py b/project/boost/build.py
index b262e47..7cf1364 100644
--- a/project/boost/build.py
+++ b/project/boost/build.py
@@ -40,7 +40,7 @@ from project.os import on_linux_like
from project.utils import normalize_path, setup_logging
-DEFAULT_PLATFORMS = (Platform.native(),)
+DEFAULT_PLATFORMS = (Platform.AUTO,)
DEFAULT_CONFIGURATIONS = (Configuration.DEBUG, Configuration.RELEASE,)
# For my development, I link everything statically (to be able to pull the
# binaries from a CI, etc. and run them everywhere):
@@ -71,7 +71,6 @@ class BuildParameters:
self.boost_dir = boost_dir
self.build_dir = build_dir
- self.stage_dir = 'stage'
self.platforms = platforms
self.configurations = configurations
self.link = link
@@ -126,12 +125,11 @@ class BuildParameters:
def _build_params(self, build_dir, toolchain, configuration, link, runtime_link):
params = []
params.append(self._build_dir(build_dir))
- params.append(self._stagedir(toolchain, configuration))
- params.append('--layout=system')
- params += toolchain.get_b2_args()
- params.append(self._variant(configuration))
params.append(self._link(link))
params.append(self._runtime_link(runtime_link))
+ params.append('--layout=system')
+ params += toolchain.b2_args(configuration)
+ params += configuration.b2_args()
params += self.b2_args
return params
@@ -139,11 +137,6 @@ class BuildParameters:
def _build_dir(build_dir):
return f'--build-dir={build_dir}'
- def _stagedir(self, toolchain, configuration):
- platform = str(toolchain.platform)
- configuration = str(configuration)
- return f'--stagedir={os.path.join(self.stage_dir, platform, configuration)}'
-
@staticmethod
def _link(link):
return f'link={link}'
diff --git a/project/boost/toolchain.py b/project/boost/toolchain.py
index 08bc49c..5422a62 100644
--- a/project/boost/toolchain.py
+++ b/project/boost/toolchain.py
@@ -104,11 +104,8 @@ class Toolchain(abc.ABC):
def __init__(self, platform):
self.platform = platform
- def get_b2_args(self):
- return [
- # Always pass the address-model explicitly.
- f'address-model={self.platform.get_address_model()}'
- ]
+ def b2_args(self, configuration):
+ return self.platform.b2_args(configuration)
@staticmethod
@contextmanager
@@ -139,8 +136,8 @@ class Auto(Toolchain):
class MSVC(Auto):
- def get_b2_args(self):
- return super().get_b2_args() + [
+ def b2_args(self, configuration):
+ return super().b2_args(configuration) + [
'toolset=msvc',
]
@@ -187,14 +184,16 @@ class BoostBuildToolset:
self.options = options
@property
- def toolset_id(self):
+ def toolset(self):
if self.version:
return f'{self.compiler}-{self.version}'
return self.compiler
- @property
- def b2_arg(self):
- return f'toolset={self.toolset_id}'
+ def b2_toolset(self):
+ return f'toolset={self.toolset}'
+
+ def b2_args(self):
+ return [self.b2_toolset()]
def _format_using_options(self):
return ''.join(f'\n <{name}>{val}' for name, val in self.options)
@@ -232,13 +231,14 @@ class ConfigFile(Toolchain):
with tmp as path:
yield cls(platform, path, toolset)
- def get_b2_args(self):
+ def b2_args(self, configuration):
# All the required options and the toolset definition should be in the
# user configuration file.
- return super().get_b2_args() + [
- f'--user-config={self.config_path}',
- self.toolset.b2_arg,
- ]
+ args = []
+ args += super().b2_args(configuration)
+ args.append(f'--user-config={self.config_path}')
+ args += self.toolset.b2_args()
+ return args
class GCC(ConfigFile):
@@ -273,8 +273,9 @@ class MinGW(GCC):
@staticmethod
def get_toolset(platform):
- path = project.mingw.get_gxx(platform)
- return BoostBuildToolset(MinGW.COMPILER, path, MinGW.get_options())
+ paths = project.mingw.MinGW(platform)
+ compiler = paths.gxx()
+ return BoostBuildToolset(MinGW.COMPILER, compiler, MinGW.get_options())
class Clang(ConfigFile):
@@ -320,8 +321,8 @@ class Clang(ConfigFile):
class ClangCL(Toolchain):
- def get_b2_args(self):
- return super().get_b2_args() + [
+ def b2_args(self, configuration):
+ return super().b2_args(configuration) + [
'toolset=clang-win',
'define=BOOST_USE_WINDOWS_H',
]