aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/project
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-06-23 18:10:36 +0200
committerEgor Tensin <egor@tensin.name>2026-06-23 18:10:36 +0200
commitdb93568d9f8423c4fe6399562f13fa54f7c96494 (patch)
treee5543032f89706d0afb3a3c9f777ba1aa14e2620 /project
parentworkflows/aur: inherit secrets (diff)
downloadcmake-common-db93568d9f8423c4fe6399562f13fa54f7c96494.tar.gz
cmake-common-db93568d9f8423c4fe6399562f13fa54f7c96494.zip
use default settings for Black
Diffstat (limited to 'project')
-rw-r--r--project/boost/archive.py14
-rw-r--r--project/boost/build.py124
-rw-r--r--project/boost/directory.py18
-rw-r--r--project/boost/download.py44
-rw-r--r--project/boost/version.py16
-rw-r--r--project/build.py118
-rw-r--r--project/configuration.py20
-rw-r--r--project/linkage.py16
-rw-r--r--project/mingw.py12
-rw-r--r--project/os.py14
-rw-r--r--project/platform.py52
-rw-r--r--project/toolset.py226
-rw-r--r--project/utils.py28
-rw-r--r--project/version.py6
14 files changed, 354 insertions, 354 deletions
diff --git a/project/boost/archive.py b/project/boost/archive.py
index 921e04f..526257c 100644
--- a/project/boost/archive.py
+++ b/project/boost/archive.py
@@ -25,8 +25,8 @@ class Archive:
def unpack(self, dest_dir):
path = os.path.join(dest_dir, self.dir_name)
if os.path.exists(path):
- raise RuntimeError(f'Boost directory already exists: {path}')
- logging.info('Unpacking Boost to: %s', path)
+ raise RuntimeError(f"Boost directory already exists: {path}")
+ logging.info("Unpacking Boost to: %s", path)
shutil.unpack_archive(self.path, dest_dir)
return BoostDir(path)
@@ -58,10 +58,10 @@ class PermanentStorage(ArchiveStorage):
@contextmanager
def write_archive(self, version, contents):
path = self._archive_path(version)
- logging.info('Writing Boost archive: %s', path)
+ logging.info("Writing Boost archive: %s", path)
if os.path.exists(path):
- raise RuntimeError(f'cannot download Boost, file already exists: {path}')
- with open(path, mode='w+b') as dest:
+ raise RuntimeError(f"cannot download Boost, file already exists: {path}")
+ with open(path, mode="w+b") as dest:
dest.write(contents)
yield path
@@ -76,9 +76,9 @@ class TemporaryStorage(ArchiveStorage):
@contextmanager
def write_archive(self, version, contents):
tmp = temp_file(
- prefix=f'boost_{version}_', suffix=version.archive_ext, dir=self._dir
+ prefix=f"boost_{version}_", suffix=version.archive_ext, dir=self._dir
)
with tmp as archive_path:
- with open(archive_path, mode='wb') as fd:
+ with open(archive_path, mode="wb") as fd:
fd.write(contents)
yield archive_path
diff --git a/project/boost/build.py b/project/boost/build.py
index 6f0726c..a501c11 100644
--- a/project/boost/build.py
+++ b/project/boost/build.py
@@ -3,7 +3,7 @@
# For details, see https://github.com/egor-tensin/cmake-common.
# Distributed under the MIT License.
-R'''Build Boost.
+R"""Build Boost.
The main utility of this script is setting the correct --prefix parameter value
to avoid name clashes.
@@ -24,7 +24,7 @@ By default, only builds:
* Debug & Release configurations,
* static libraries,
* statically linked to the runtime.
-'''
+"""
import argparse
from contextlib import contextmanager
@@ -47,8 +47,8 @@ DEFAULT_CONFIGURATIONS = (
Configuration.RELEASE,
)
DEFAULT_TOOLSET_VERSION = ToolsetVersion.default()
-B2_QUIET = ['warnings=off', '-d0']
-B2_VERBOSE = ['warnings=all', '-d2', '--debug-configuration']
+B2_QUIET = ["warnings=off", "-d0"]
+B2_VERBOSE = ["warnings=all", "-d2", "--debug-configuration"]
class BuildParameters:
@@ -94,7 +94,7 @@ class BuildParameters:
@staticmethod
def from_cmd_args(args):
args = vars(args)
- args.pop('help_toolsets', None)
+ args.pop("help_toolsets", None)
return BuildParameters(**args)
def enum_b2_args(self):
@@ -107,18 +107,18 @@ class BuildParameters:
@contextmanager
def _create_build_dir(self):
if self.build_dir is not None:
- logging.info('Build directory: %s', self.build_dir)
+ logging.info("Build directory: %s", self.build_dir)
yield self.build_dir
return
with tempfile.TemporaryDirectory(
dir=os.path.dirname(self.boost_dir)
) as build_dir:
- logging.info('Build directory: %s', build_dir)
+ logging.info("Build directory: %s", build_dir)
try:
yield build_dir
finally:
- logging.info('Removing build directory: %s', build_dir)
+ logging.info("Removing build directory: %s", build_dir)
return
@contextmanager
@@ -126,16 +126,16 @@ class BuildParameters:
toolset = Toolset.make(self.toolset_version, platform)
link, runtime_link = Linkage.validate_linkage(self.link, self.runtime_link)
with toolset.b2_args() as result:
- result.append(f'--build-dir={build_dir}')
- result.append('--layout=system')
+ result.append(f"--build-dir={build_dir}")
+ result.append("--layout=system")
result += platform.b2_args(configuration)
result += configuration.b2_args()
result += link.b2_args_link()
result += runtime_link.b2_args_runtime_link()
result += self.b2_args
if self.libraries:
- result += [f'--with-{lib}' for lib in self.libraries]
- result += ['install']
+ result += [f"--with-{lib}" for lib in self.libraries]
+ result += ["install"]
yield result
@@ -148,7 +148,7 @@ def _parse_args(argv=None):
if argv is None:
argv = sys.argv[1:]
- if '--help-toolsets' in argv:
+ if "--help-toolsets" in argv:
sys.stdout.write(ToolsetVersion.help_toolsets())
sys.exit(0)
@@ -157,102 +157,102 @@ def _parse_args(argv=None):
)
parser.add_argument(
- '--help-toolsets',
- action='store_true',
- help='show detailed info about supported toolsets',
+ "--help-toolsets",
+ action="store_true",
+ help="show detailed info about supported toolsets",
)
project.version.add_to_arg_parser(parser)
parser.add_argument(
- '-v',
- '--verbose',
- action='store_true',
- help='verbose b2 invocation (quiet by default)',
+ "-v",
+ "--verbose",
+ action="store_true",
+ help="verbose b2 invocation (quiet by default)",
)
parser.add_argument(
- '--toolset',
- metavar='TOOLSET',
- dest='toolset_version',
+ "--toolset",
+ metavar="TOOLSET",
+ dest="toolset_version",
type=ToolsetVersion.parse,
default=DEFAULT_TOOLSET_VERSION,
- help=f'toolset to use ({ToolsetVersion.usage()})',
+ help=f"toolset to use ({ToolsetVersion.usage()})",
)
- platform_options = '/'.join(map(str, Platform.all()))
- configuration_options = '/'.join(map(str, Configuration.all()))
+ platform_options = "/".join(map(str, Platform.all()))
+ configuration_options = "/".join(map(str, Configuration.all()))
# These are used to put the built libraries into proper installation
# directory subdirectories (to avoid name clashes).
parser.add_argument(
- '--platform',
- metavar='PLATFORM',
- dest='platforms',
- nargs='*',
+ "--platform",
+ metavar="PLATFORM",
+ dest="platforms",
+ nargs="*",
type=Platform.parse,
default=[],
- help=f'target platform ({platform_options})',
+ help=f"target platform ({platform_options})",
)
parser.add_argument(
- '--configuration',
- metavar='CONFIGURATION',
- dest='configurations',
- nargs='*',
+ "--configuration",
+ metavar="CONFIGURATION",
+ dest="configurations",
+ nargs="*",
type=Configuration.parse,
default=[],
- help=f'target configuration ({configuration_options})',
+ help=f"target configuration ({configuration_options})",
)
- linkage_options = '/'.join(map(str, Linkage.all()))
+ linkage_options = "/".join(map(str, Linkage.all()))
# This is needed because the default behaviour on Linux and Windows is
# different: static & dynamic libs are built on Linux, but only static libs
# are built on Windows by default.
parser.add_argument(
- '--link',
- metavar='LINKAGE',
+ "--link",
+ metavar="LINKAGE",
type=Linkage.parse,
default=Linkage.default_link(),
- help=f'how the libraries are linked ({linkage_options})',
+ help=f"how the libraries are linked ({linkage_options})",
)
# This is used to omit runtime-link=static I'd have to otherwise use a lot,
# plus the script validates the link= and runtime-link= combinations.
parser.add_argument(
- '--runtime-link',
- metavar='LINKAGE',
+ "--runtime-link",
+ metavar="LINKAGE",
type=Linkage.parse,
default=Linkage.default_runtime_link(),
- help=f'how the libraries link to the runtime ({linkage_options})',
+ help=f"how the libraries link to the runtime ({linkage_options})",
)
parser.add_argument(
- '--build',
- metavar='DIR',
- dest='build_dir',
+ "--build",
+ metavar="DIR",
+ dest="build_dir",
type=normalize_path,
- help='Boost build directory (temporary directory unless specified)',
+ help="Boost build directory (temporary directory unless specified)",
)
parser.add_argument(
- '--b2-arg',
- metavar='ARG',
- dest='b2_args',
- action='extend',
- nargs='*',
- help='additional b2 arguments, to be passed verbatim',
+ "--b2-arg",
+ metavar="ARG",
+ dest="b2_args",
+ action="extend",
+ nargs="*",
+ help="additional b2 arguments, to be passed verbatim",
)
parser.add_argument(
- 'boost_dir',
- metavar='BOOST_DIR',
+ "boost_dir",
+ metavar="BOOST_DIR",
type=normalize_path,
- help='root Boost directory',
+ help="root Boost directory",
)
parser.add_argument(
- 'libraries',
- metavar='LIBRARIES',
- action='extend',
- nargs='*',
- help='libraries to build (all libraries by default)',
+ "libraries",
+ metavar="LIBRARIES",
+ action="extend",
+ nargs="*",
+ help="libraries to build (all libraries by default)",
)
return parser.parse_args(argv)
@@ -264,5 +264,5 @@ def _main(argv=None):
build(BuildParameters.from_cmd_args(args))
-if __name__ == '__main__':
+if __name__ == "__main__":
_main()
diff --git a/project/boost/directory.py b/project/boost/directory.py
index 62090dc..fc05f68 100644
--- a/project/boost/directory.py
+++ b/project/boost/directory.py
@@ -27,7 +27,7 @@ class BoostDir:
def _bootstrap_if_required(self, params):
if os.path.isfile(self._b2_path()):
- logging.info('Not going to bootstrap, b2 is already there')
+ logging.info("Not going to bootstrap, b2 is already there")
return
self.bootstrap(params)
@@ -41,14 +41,14 @@ class BoostDir:
@staticmethod
def _bootstrap_path():
- return os.path.join('.', BoostDir._bootstrap_name())
+ return os.path.join(".", BoostDir._bootstrap_name())
@staticmethod
def _bootstrap_name():
- ext = '.sh'
+ ext = ".sh"
if on_windows():
- ext = '.bat'
- return f'bootstrap{ext}'
+ ext = ".bat"
+ return f"bootstrap{ext}"
@staticmethod
def _bootstrap_args(toolset_version):
@@ -59,11 +59,11 @@ class BoostDir:
@staticmethod
def _b2_path():
- return os.path.join('.', BoostDir._b2_name())
+ return os.path.join(".", BoostDir._b2_name())
@staticmethod
def _b2_name():
- ext = ''
+ ext = ""
if on_windows():
- ext = '.exe'
- return f'b2{ext}'
+ ext = ".exe"
+ return f"b2{ext}"
diff --git a/project/boost/download.py b/project/boost/download.py
index a10e9e6..52710af 100644
--- a/project/boost/download.py
+++ b/project/boost/download.py
@@ -3,7 +3,7 @@
# For details, see https://github.com/egor-tensin/cmake-common.
# Distributed under the MIT License.
-R'''Download & bootstrap Boost.
+R"""Download & bootstrap Boost.
This script downloads and unpacks a Boost distribution archive. Its main
utility is that it's cross-platform & supports different Boost versions out of
@@ -16,7 +16,7 @@ Usage examples:
$ boost-download --unpack ~/workspace/third-party/ 1.65.0
...
-'''
+"""
import argparse
from contextlib import contextmanager
@@ -37,7 +37,7 @@ class Download:
):
if unpack_dir is None:
if cache_dir is None:
- unpack_dir = '.'
+ unpack_dir = "."
else:
unpack_dir = cache_dir
@@ -75,7 +75,7 @@ class Download:
return Download._download_url(url)
def _try_url(self, url):
- logging.info('Trying URL: %s', url)
+ logging.info("Trying URL: %s", url)
try:
if self.no_retry:
return self._download_url(url)
@@ -107,7 +107,7 @@ class Download:
def download_if_necessary(self):
path = self.storage.get_archive(self.version)
if path is not None:
- logging.info('Using existing Boost archive: %s', path)
+ logging.info("Using existing Boost archive: %s", path)
yield path
return
with self._download_from_cdn() as path:
@@ -132,32 +132,32 @@ def _parse_args(argv=None):
project.version.add_to_arg_parser(parser)
parser.add_argument(
- '--unpack',
- metavar='DIR',
- dest='unpack_dir',
+ "--unpack",
+ metavar="DIR",
+ dest="unpack_dir",
type=normalize_path,
- help='directory to unpack the archive to',
+ help="directory to unpack the archive to",
)
parser.add_argument(
- '--cache',
- metavar='DIR',
- dest='cache_dir',
+ "--cache",
+ metavar="DIR",
+ dest="cache_dir",
type=normalize_path,
- help='download directory (temporary file unless specified)',
+ help="download directory (temporary file unless specified)",
)
- parser.add_argument('--no-retry', action='store_true', help=argparse.SUPPRESS)
+ parser.add_argument("--no-retry", action="store_true", help=argparse.SUPPRESS)
parser.add_argument(
- 'version',
- metavar='VERSION',
+ "version",
+ metavar="VERSION",
type=Version.from_string,
- help='Boost version (in the MAJOR.MINOR.PATCH format)',
+ help="Boost version (in the MAJOR.MINOR.PATCH format)",
)
parser.add_argument(
- 'dest_path',
- metavar='DIR',
- nargs='?',
+ "dest_path",
+ metavar="DIR",
+ nargs="?",
type=normalize_path,
- help='rename the boost directory to DIR',
+ help="rename the boost directory to DIR",
)
return parser.parse_args(argv)
@@ -169,5 +169,5 @@ def _main(argv=None):
download(Download.from_args(args))
-if __name__ == '__main__':
+if __name__ == "__main__":
_main()
diff --git a/project/boost/version.py b/project/boost/version.py
index d58f462..58bfb56 100644
--- a/project/boost/version.py
+++ b/project/boost/version.py
@@ -8,7 +8,7 @@ from functools import total_ordering
import os.path
import re
-_Version = namedtuple('_Version', ['major', 'minor', 'patch'])
+_Version = namedtuple("_Version", ["major", "minor", "patch"])
@total_ordering
@@ -36,31 +36,31 @@ class Version:
@staticmethod
def from_string(s):
- result = re.match(r'^(\d+)\.(\d+)\.(\d+)$', s)
+ result = re.match(r"^(\d+)\.(\d+)\.(\d+)$", s)
if result is None:
- raise ValueError(f'invalid Boost version: {s}')
+ raise ValueError(f"invalid Boost version: {s}")
major = int(result.group(1))
minor = int(result.group(2))
patch = int(result.group(3))
return Version(major, minor, patch)
def __str__(self):
- return f'{self.major}.{self.minor}.{self.patch}'
+ return f"{self.major}.{self.minor}.{self.patch}"
@property
def archive_ext(self):
- return '.tar.gz'
+ return ".tar.gz"
def dir_path(self, parent_dir):
return os.path.join(parent_dir, self.dir_name)
@property
def dir_name(self):
- return f'boost_{self.major}_{self.minor}_{self.patch}'
+ return f"boost_{self.major}_{self.minor}_{self.patch}"
@property
def archive_name(self):
- return f'{self.dir_name}{self.archive_ext}'
+ return f"{self.dir_name}{self.archive_ext}"
def get_download_url(self):
- return f'https://archives.boost.io/release/{self}/source/{self.archive_name}'
+ return f"https://archives.boost.io/release/{self}/source/{self.archive_name}"
diff --git a/project/build.py b/project/build.py
index 1c3cdb7..3a3a0a4 100644
--- a/project/build.py
+++ b/project/build.py
@@ -3,7 +3,7 @@
# For details, see https://github.com/egor-tensin/cmake-common.
# Distributed under the MIT License.
-R'''Build a CMake project.
+R"""Build a CMake project.
This script works nicely with boost-build from this package - it will set the
correct BOOST_ROOT value automatically.
@@ -18,7 +18,7 @@ Usage example:
$ ./path/to/somewhere/bin/foo
foo
-'''
+"""
import argparse
from contextlib import contextmanager
@@ -43,11 +43,11 @@ DEFAULT_TOOLSET_VERSION = ToolsetVersion.default()
# _guessing_ that the build system is make and passing -j explicitly. Plus it
# works with older CMake versions, which don't support the --parallel flag.
cmake_env = os.environ.copy()
-cmake_env['CMAKE_BUILD_PARALLEL_LEVEL'] = str(os.cpu_count())
+cmake_env["CMAKE_BUILD_PARALLEL_LEVEL"] = str(os.cpu_count())
def run_cmake(cmake_args):
- return run(['cmake'] + cmake_args, env=cmake_env)
+ return run(["cmake"] + cmake_args, env=cmake_env)
class GenerationPhase:
@@ -92,23 +92,23 @@ class GenerationPhase:
root = self.boost_dir
root = os.path.join(root, self.platform.boost_installdir(self.configuration))
args = [
- f'-DBoost_ROOT={root}',
- f'-DBOOST_ROOT={root}',
+ f"-DBoost_ROOT={root}",
+ f"-DBOOST_ROOT={root}",
]
args += self.link.cmake_args_link()
return args
@staticmethod
def _cmake_extra_args():
- return ['-DCMAKE_EXPORT_COMPILE_COMMANDS=ON']
+ return ["-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"]
def _cmake_dir_args(self):
args = []
if self.install_dir is not None:
- args += [f'-DCMAKE_INSTALL_PREFIX={self.install_dir}']
+ args += [f"-DCMAKE_INSTALL_PREFIX={self.install_dir}"]
# Important! -H must come as the last parameter, older CMake versions
# don't like it when it's not.
- args += [f'-B{self.build_dir}', f'-H{self.src_dir}']
+ args += [f"-B{self.build_dir}", f"-H{self.src_dir}"]
return args
def run(self, toolset):
@@ -122,11 +122,11 @@ class BuildPhase:
self.configuration = configuration or DEFAULT_CONFIGURATION
def _cmake_args(self, toolset):
- result = ['--build', self.build_dir]
- result += ['--config', str(self.configuration)]
+ result = ["--build", self.build_dir]
+ result += ["--config", str(self.configuration)]
if self.install_dir is not None:
- result += ['--target', 'install']
- result += ['--'] + toolset.build_system_args()
+ result += ["--target", "install"]
+ result += ["--"] + toolset.build_system_args()
return result
def run(self, toolset):
@@ -162,13 +162,13 @@ class BuildParameters:
@staticmethod
def from_args(args):
args = vars(args)
- args.pop('help_toolsets', None)
+ args.pop("help_toolsets", None)
return BuildParameters(**args)
@contextmanager
def create_build_dir(self):
if self.build_dir is not None:
- logging.info('Build directory: %s', self.build_dir)
+ logging.info("Build directory: %s", self.build_dir)
mkdir_parent(self.build_dir)
yield self.build_dir
return
@@ -176,11 +176,11 @@ class BuildParameters:
with tempfile.TemporaryDirectory(
dir=os.path.dirname(self.src_dir)
) as build_dir:
- logging.info('Build directory: %s', build_dir)
+ logging.info("Build directory: %s", build_dir)
try:
yield build_dir
finally:
- logging.info('Removing build directory: %s', build_dir)
+ logging.info("Removing build directory: %s", build_dir)
def build(params):
@@ -211,7 +211,7 @@ def _parse_args(argv=None):
if argv is None:
argv = sys.argv[1:]
- if '--help-toolsets' in argv:
+ if "--help-toolsets" in argv:
sys.stdout.write(ToolsetVersion.help_toolsets())
sys.exit(0)
@@ -220,86 +220,86 @@ def _parse_args(argv=None):
)
parser.add_argument(
- '--help-toolsets',
- action='store_true',
- help='show detailed info about supported toolsets',
+ "--help-toolsets",
+ action="store_true",
+ help="show detailed info about supported toolsets",
)
project.version.add_to_arg_parser(parser)
parser.add_argument(
- '--toolset',
- metavar='TOOLSET',
- dest='toolset_version',
+ "--toolset",
+ metavar="TOOLSET",
+ dest="toolset_version",
type=ToolsetVersion.parse,
default=DEFAULT_TOOLSET_VERSION,
- help=f'toolset to use ({ToolsetVersion.usage()})',
+ help=f"toolset to use ({ToolsetVersion.usage()})",
)
- platform_options = '/'.join(map(str, Platform.all()))
- configuration_options = '/'.join(map(str, Configuration.all()))
+ platform_options = "/".join(map(str, Platform.all()))
+ configuration_options = "/".join(map(str, Configuration.all()))
parser.add_argument(
- '--platform',
- metavar='PLATFORM',
+ "--platform",
+ metavar="PLATFORM",
type=Platform.parse,
- help=f'target platform ({platform_options})',
+ help=f"target platform ({platform_options})",
)
parser.add_argument(
- '--configuration',
- metavar='CONFIG',
+ "--configuration",
+ metavar="CONFIG",
type=Configuration.parse,
default=DEFAULT_CONFIGURATION,
- help=f'build configuration ({configuration_options})',
+ help=f"build configuration ({configuration_options})",
)
parser.add_argument(
- '--boost',
- metavar='DIR',
- dest='boost_dir',
+ "--boost",
+ metavar="DIR",
+ dest="boost_dir",
type=normalize_path,
- help='set Boost directory path',
+ help="set Boost directory path",
)
- linkage_options = '/'.join(map(str, Linkage.all()))
+ linkage_options = "/".join(map(str, Linkage.all()))
parser.add_argument(
- '--link',
- metavar='LINKAGE',
+ "--link",
+ metavar="LINKAGE",
type=Linkage.parse,
default=Linkage.default_link(),
- help=f'how Boost libraries are linked ({linkage_options})',
+ help=f"how Boost libraries are linked ({linkage_options})",
)
parser.add_argument(
- '--runtime-link',
- metavar='LINKAGE',
+ "--runtime-link",
+ metavar="LINKAGE",
type=Linkage.parse,
default=Linkage.default_runtime_link(),
- help=f'which runtime to link to ({linkage_options})',
+ help=f"which runtime to link to ({linkage_options})",
)
parser.add_argument(
- '--install',
- metavar='DIR',
- dest='install_dir',
+ "--install",
+ metavar="DIR",
+ dest="install_dir",
type=normalize_path,
- help='install directory',
+ help="install directory",
)
parser.add_argument(
- '--cmake-arg',
- metavar='ARG',
- dest='cmake_args',
- action='extend',
- nargs='*',
- help='additional CMake arguments, to be passed verbatim',
+ "--cmake-arg",
+ metavar="ARG",
+ dest="cmake_args",
+ action="extend",
+ nargs="*",
+ help="additional CMake arguments, to be passed verbatim",
)
- parser.add_argument('src_dir', type=normalize_path, help='source directory')
+ parser.add_argument("src_dir", type=normalize_path, help="source directory")
parser.add_argument(
- 'build_dir',
+ "build_dir",
type=normalize_path,
- nargs='?',
- help='build directory (a temporary directory if omitted)',
+ nargs="?",
+ help="build directory (a temporary directory if omitted)",
)
return parser.parse_args(argv)
@@ -311,5 +311,5 @@ def main(argv=None):
build(BuildParameters.from_args(args))
-if __name__ == '__main__':
+if __name__ == "__main__":
main()
diff --git a/project/configuration.py b/project/configuration.py
index ce839a8..78e6eb9 100644
--- a/project/configuration.py
+++ b/project/configuration.py
@@ -8,12 +8,12 @@ from enum import Enum
class Configuration(Enum):
- '''Correspond to CMake's default CMAKE_BUILD_TYPE values.'''
+ """Correspond to CMake's default CMAKE_BUILD_TYPE values."""
- DEBUG = 'Debug'
- MINSIZEREL = 'MinSizeRel'
- RELWITHDEBINFO = 'RelWithDebInfo'
- RELEASE = 'Release'
+ DEBUG = "Debug"
+ MINSIZEREL = "MinSizeRel"
+ RELWITHDEBINFO = "RelWithDebInfo"
+ RELEASE = "Release"
def __str__(self):
return str(self.value)
@@ -27,22 +27,22 @@ class Configuration(Enum):
try:
return Configuration(s)
except ValueError as e:
- raise argparse.ArgumentTypeError(f'invalid configuration: {s}') from e
+ raise argparse.ArgumentTypeError(f"invalid configuration: {s}") from e
def b2_variant(self):
- '''Roughly maps CMake's CMAKE_BUILD_TYPE to Boost's variant.
+ """Roughly maps CMake's CMAKE_BUILD_TYPE to Boost's variant.
AFAIK, Boost only supports debug/release, MinSizeRel and RelWithDebInfo
are hence mapped to "release". The libraries will still reside in
install_dir/PLATFORM/CONFIGURATION/lib, if CONFIGURATION is
MinSizeRel/RelWithDebInfo.
- '''
+ """
if self in (Configuration.MINSIZEREL, Configuration.RELWITHDEBINFO):
return Configuration.RELEASE.b2_variant()
return str(self).lower()
def b2_args(self):
- return [f'variant={self.b2_variant()}']
+ return [f"variant={self.b2_variant()}"]
def cmake_args(self):
- return [f'-DCMAKE_BUILD_TYPE={self}']
+ return [f"-DCMAKE_BUILD_TYPE={self}"]
diff --git a/project/linkage.py b/project/linkage.py
index 8b2949b..6d2cd11 100644
--- a/project/linkage.py
+++ b/project/linkage.py
@@ -11,8 +11,8 @@ from project.os import on_linux_like
class Linkage(Enum):
- STATIC = 'static'
- SHARED = 'shared'
+ STATIC = "static"
+ SHARED = "shared"
def __str__(self):
return str(self.value)
@@ -26,7 +26,7 @@ class Linkage(Enum):
try:
return Linkage(s)
except ValueError as e:
- raise argparse.ArgumentTypeError(f'invalid linkage: {s}') from e
+ raise argparse.ArgumentTypeError(f"invalid linkage: {s}") from e
# For my development, I link everything statically (to be able to pull the
# binaries from a CI, etc. and run them everywhere):
@@ -54,20 +54,20 @@ class Linkage(Enum):
return link, runtime_link
def b2_args_link(self):
- return [f'link={self}']
+ return [f"link={self}"]
def b2_args_runtime_link(self):
- return [f'runtime-link={self}']
+ return [f"runtime-link={self}"]
def cmake_args_link(self):
if self is Linkage.STATIC:
- return ['-DBoost_USE_STATIC_LIBS=ON']
+ return ["-DBoost_USE_STATIC_LIBS=ON"]
return []
def cmake_args_runtime_link(self):
if self is Linkage.STATIC:
return [
- '-DBoost_USE_STATIC_RUNTIME=ON',
- '-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>',
+ "-DBoost_USE_STATIC_RUNTIME=ON",
+ "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>",
]
return []
diff --git a/project/mingw.py b/project/mingw.py
index e3a14ef..fb44e23 100644
--- a/project/mingw.py
+++ b/project/mingw.py
@@ -9,19 +9,19 @@ class MinGW:
self.prefix = platform.mingw_prefix()
def _get(self, what):
- return f'{self.prefix}-w64-mingw32-{what}'
+ return f"{self.prefix}-w64-mingw32-{what}"
def gcc(self):
- return self._get('gcc')
+ return self._get("gcc")
def gxx(self):
- return self._get('g++')
+ return self._get("g++")
def ar(self):
- return self._get('gcc-ar')
+ return self._get("gcc-ar")
def ranlib(self):
- return self._get('gcc-ranlib')
+ return self._get("gcc-ranlib")
def windres(self):
- return self._get('windres')
+ return self._get("windres")
diff --git a/project/os.py b/project/os.py
index 1d35fb9..398f4b2 100644
--- a/project/os.py
+++ b/project/os.py
@@ -8,9 +8,9 @@ import platform
class OS(Enum):
- WINDOWS = 'Windows'
- LINUX = 'Linux'
- MACOS = 'macOS'
+ WINDOWS = "Windows"
+ LINUX = "Linux"
+ MACOS = "macOS"
def __str__(self):
return str(self.value)
@@ -19,12 +19,12 @@ class OS(Enum):
def current():
system = platform.system()
mapping = {
- 'Windows': OS.WINDOWS,
- 'Linux': OS.LINUX,
- 'Darwin': OS.MACOS,
+ "Windows": OS.WINDOWS,
+ "Linux": OS.LINUX,
+ "Darwin": OS.MACOS,
}
if system not in mapping:
- raise NotImplementedError(f'unsupported OS: {system}')
+ raise NotImplementedError(f"unsupported OS: {system}")
return mapping[system]
diff --git a/project/platform.py b/project/platform.py
index 582470c..70f4788 100644
--- a/project/platform.py
+++ b/project/platform.py
@@ -13,11 +13,11 @@ from project.os import on_windows
class Platform(Enum):
# I only build for x86(-64), so here it goes.
- X86 = 'x86'
- X64 = 'x64'
+ X86 = "x86"
+ X64 = "x64"
# 'auto' means that no additional arguments will be passed to either
# Boost's b2 nor CMake (except on Windows, see below).
- AUTO = 'auto'
+ AUTO = "auto"
def __str__(self):
return str(self.value)
@@ -30,7 +30,7 @@ class Platform(Enum):
# is true?), and we default to x64 most of the time.
#
# Source: https://stackoverflow.com/a/12578715/514684
- if platform.machine().endswith('64'):
+ if platform.machine().endswith("64"):
return Platform.X64
return Platform.X86
@@ -41,12 +41,12 @@ class Platform(Enum):
@staticmethod
def parse(s):
try:
- if s == 'Win32':
+ if s == "Win32":
# Visual Studio/AppVeyor convention:
return Platform.X86
return Platform(s)
except ValueError as e:
- raise argparse.ArgumentTypeError(f'invalid platform: {s}') from e
+ raise argparse.ArgumentTypeError(f"invalid platform: {s}") from e
def mingw_prefix(self):
if self is Platform.AUTO:
@@ -56,38 +56,38 @@ class Platform(Enum):
# On Linux, assume that the target is x64.
return Platform.X64.mingw_prefix()
if self is Platform.X86:
- return 'i686'
+ return "i686"
if self is Platform.X64:
- return 'x86_64'
- raise NotImplementedError(f'unsupported platform: {self}')
+ return "x86_64"
+ raise NotImplementedError(f"unsupported platform: {self}")
def address_model(self):
- '''Maps to Boost's address-model.'''
+ """Maps to Boost's address-model."""
if self is Platform.AUTO:
if on_windows():
# On Windows, use the host architecture.
return Platform.windows_native().address_model()
# On Linux, assume that the target is x64.
raise RuntimeError(
- 'cannot determine address model unless the target platform is specified explicitly'
+ "cannot determine address model unless the target platform is specified explicitly"
)
if self is Platform.X86:
return 32
if self is Platform.X64:
return 64
- raise NotImplementedError(f'unsupported platform: {self}')
+ raise NotImplementedError(f"unsupported platform: {self}")
def installdir(self, configuration):
- '''Path to the installation directory inside the Boost build directory.'''
+ """Path to the installation directory inside the Boost build directory."""
if self is Platform.AUTO:
if on_windows():
# On Windows, use the host architecture.
return Platform.windows_native().installdir(configuration)
# On Linux, the libraries are stored in install_dir/auto/CONFIGURATION/lib.
- return os.path.join('install_dir', str(self), str(configuration))
+ return os.path.join("install_dir", str(self), str(configuration))
def boost_installdir(self, configuration):
- '''Same as above, but for CMake.'''
+ """Same as above, but for CMake."""
return self.installdir(configuration)
def b2_address_model(self):
@@ -95,10 +95,10 @@ class Platform(Enum):
# On Linux, don't specify the architecture explicitly (it is
# assumed that the host architecture will be targeted).
return []
- return [f'address-model={self.address_model()}']
+ return [f"address-model={self.address_model()}"]
def b2_installdir(self, configuration):
- return [f'--prefix={self.installdir(configuration)}']
+ return [f"--prefix={self.installdir(configuration)}"]
def b2_args(self, configuration):
args = []
@@ -111,20 +111,20 @@ class Platform(Enum):
# specifies the -m32/-m64 flags, etc.
if self is Platform.AUTO:
# Let the compiler decide.
- return ''
+ return ""
if self is Platform.X86:
address_model = 32
elif self is Platform.X64:
address_model = 64
else:
- raise NotImplementedError(f'unsupported platform: {self}')
- return f'''
+ raise NotImplementedError(f"unsupported platform: {self}")
+ return f"""
set(CMAKE_C_FLAGS -m{address_model})
set(CMAKE_CXX_FLAGS -m{address_model})
-'''
+"""
def msvc_arch(self):
- '''Maps to CMake's -A argument for MSVC.'''
+ """Maps to CMake's -A argument for MSVC."""
if self is Platform.AUTO:
if on_windows():
# On Windows, use the host architecture.
@@ -132,10 +132,10 @@ set(CMAKE_CXX_FLAGS -m{address_model})
# I don't think the -A argument is supported on any generators
# except the Visual Studio ones.
raise RuntimeError(
- '-A parameter is only supported for Visual Studio generators'
+ "-A parameter is only supported for Visual Studio generators"
)
if self is Platform.X86:
- return 'Win32'
+ return "Win32"
if self is Platform.X64:
- return 'x64'
- raise NotImplementedError(f'unsupported platform: {self}')
+ return "x64"
+ raise NotImplementedError(f"unsupported platform: {self}")
diff --git a/project/toolset.py b/project/toolset.py
index c685a16..bc75149 100644
--- a/project/toolset.py
+++ b/project/toolset.py
@@ -3,7 +3,7 @@
# For details, see https://github.com/egor-tensin/cmake-common.
# Distributed under the MIT License.
-'''Supported platform/build system/compiler combinations include, but are not
+"""Supported platform/build system/compiler combinations include, but are not
limited to:
| Platform | Build system | Compiler |
@@ -17,7 +17,7 @@ limited to:
1. Both GNU make and MinGW mingw32-make.
2. clang-cl is supported by Boost 1.69.0 or higher only.
-'''
+"""
# See docs/{boost,cmake}.md for a more thorough description of my pain.
@@ -39,14 +39,14 @@ from project.utils import full_exe_name, temp_file
class MSVCVersion(Enum):
# It's the MSVC "toolset" version, or whatever.
# Source: https://cmake.org/cmake/help/latest/variable/MSVC_TOOLSET_VERSION.html
- VS2010 = '100'
- VS2012 = '110'
- VS2013 = '120'
- VS2015 = '140'
- VS2017 = '141'
- VS2019 = '142'
- VS2022 = '143'
- VS2026 = '145'
+ VS2010 = "100"
+ VS2012 = "110"
+ VS2013 = "120"
+ VS2015 = "140"
+ VS2017 = "141"
+ VS2019 = "142"
+ VS2022 = "143"
+ VS2026 = "145"
# ^^^ Update the mappings below.
def __str__(self):
@@ -54,15 +54,15 @@ class MSVCVersion(Enum):
def help(self):
if self in _msvc_to_vs_version:
- return f'Visual Studio {_msvc_to_vs_version[self]}'
- raise NotImplementedError(f'unsupported MSVC version: {self}')
+ return f"Visual Studio {_msvc_to_vs_version[self]}"
+ raise NotImplementedError(f"unsupported MSVC version: {self}")
@staticmethod
def parse(s):
try:
return MSVCVersion(s)
except ValueError as e:
- raise argparse.ArgumentTypeError(f'invalid MSVC version: {s}') from e
+ raise argparse.ArgumentTypeError(f"invalid MSVC version: {s}") from e
@staticmethod
def all():
@@ -74,32 +74,32 @@ class MSVCVersion(Enum):
def to_visual_studio_version(self):
if self in _msvc_to_vs_version:
return _msvc_to_vs_version[self]
- raise NotImplementedError(f'unsupported MSVC version: {self}')
+ raise NotImplementedError(f"unsupported MSVC version: {self}")
def to_boost_msvc_version(self):
try:
numeric = int(self.value)
except ValueError as e:
raise RuntimeError(
- f'what? MSVC versions are supposed to be integers: {self.value}'
+ f"what? MSVC versions are supposed to be integers: {self.value}"
) from e
numeric = Decimal(numeric) / 10
- numeric = numeric.quantize(Decimal('1.0'))
+ numeric = numeric.quantize(Decimal("1.0"))
return str(numeric)
def to_cmake_toolset(self):
- return f'v{self}'
+ return f"v{self}"
class VisualStudioVersion(Enum):
- VS2010 = '2010'
- VS2012 = '2012'
- VS2013 = '2013'
- VS2015 = '2015'
- VS2017 = '2017'
- VS2019 = '2019'
- VS2022 = '2022'
- VS2026 = '2026'
+ VS2010 = "2010"
+ VS2012 = "2012"
+ VS2013 = "2013"
+ VS2015 = "2015"
+ VS2017 = "2017"
+ VS2019 = "2019"
+ VS2022 = "2022"
+ VS2026 = "2026"
# ^^^ Update the mappings below.
def __str__(self):
@@ -108,7 +108,7 @@ class VisualStudioVersion(Enum):
def help(self):
if self in _vs_to_msvc_version:
return f"Same as '{ToolsetType.MSVC}{_vs_to_msvc_version[self]}'"
- raise NotImplementedError(f'unsupported Visual Studio version: {self}')
+ raise NotImplementedError(f"unsupported Visual Studio version: {self}")
@staticmethod
def parse(s):
@@ -116,7 +116,7 @@ class VisualStudioVersion(Enum):
return VisualStudioVersion(s)
except ValueError as e:
raise argparse.ArgumentTypeError(
- f'invalid Visual Studio version: {s}'
+ f"invalid Visual Studio version: {s}"
) from e
@staticmethod
@@ -126,7 +126,7 @@ class VisualStudioVersion(Enum):
def to_msvc_version(self):
if self in _vs_to_msvc_version:
return _vs_to_msvc_version[self]
- raise NotImplementedError(f'unsupported Visual Studio version: {self}')
+ raise NotImplementedError(f"unsupported Visual Studio version: {self}")
def to_visual_studio_version(self):
return self
@@ -146,13 +146,13 @@ _vs_to_msvc_version = {v: k for k, v in _msvc_to_vs_version.items()}
class ToolsetType(Enum):
- AUTO = 'auto'
- MSVC = 'msvc'
- VISUAL_STUDIO = 'vs'
- GCC = 'gcc'
- MINGW = 'mingw'
- CLANG = 'clang'
- CLANG_CL = 'clang-cl'
+ AUTO = "auto"
+ MSVC = "msvc"
+ VISUAL_STUDIO = "vs"
+ GCC = "gcc"
+ MINGW = "mingw"
+ CLANG = "clang"
+ CLANG_CL = "clang-cl"
def __str__(self):
return str(self.value)
@@ -161,25 +161,25 @@ class ToolsetType(Enum):
if self is ToolsetType.AUTO:
return "Means 'gcc' on Linux and 'msvc' on Windows"
if self is ToolsetType.MSVC:
- return 'Use cl.exe'
+ return "Use cl.exe"
if self is ToolsetType.VISUAL_STUDIO:
return "Visual Studio; same as 'msvc'"
if self is ToolsetType.GCC:
- return 'Use gcc/g++'
+ return "Use gcc/g++"
if self is ToolsetType.MINGW:
- return 'Use gcc/g++ with the PLATFORM-w64-mingw32 prefix'
+ return "Use gcc/g++ with the PLATFORM-w64-mingw32 prefix"
if self is ToolsetType.CLANG:
- return 'Use clang/clang++'
+ return "Use clang/clang++"
if self is ToolsetType.CLANG_CL:
- return 'Use clang-cl.exe'
- raise NotImplementedError(f'unsupported toolset: {self}')
+ return "Use clang-cl.exe"
+ raise NotImplementedError(f"unsupported toolset: {self}")
@staticmethod
def parse(s):
try:
return ToolsetType(s)
except ValueError as e:
- raise argparse.ArgumentTypeError(f'invalid toolset: {s}') from e
+ raise argparse.ArgumentTypeError(f"invalid toolset: {s}") from e
@property
def is_versioned(self):
@@ -222,7 +222,7 @@ class ToolsetVersion:
def __str__(self):
if self.version is None:
return str(self.hint)
- return f'{self.hint}{self.version}'
+ return f"{self.hint}{self.version}"
@staticmethod
def default():
@@ -230,31 +230,31 @@ class ToolsetVersion:
@staticmethod
def usage():
- return '/'.join(map(str, ToolsetType.all()))
+ return "/".join(map(str, ToolsetType.all()))
@staticmethod
def help_toolsets():
- return f'''{__doc__}
+ return f"""{__doc__}
{ToolsetVersion.help_all_toolsets()}
-{ToolsetVersion.help_versioned_toolsets()}'''
+{ToolsetVersion.help_versioned_toolsets()}"""
@staticmethod
def help_all_toolsets():
- s = '''All supported toolsets are listed below.
+ s = """All supported toolsets are listed below.
-'''
+"""
max_name = max((len(str(hint)) for hint in ToolsetType.all()))
for hint in ToolsetType.all():
- name_padding = ' ' * (max_name - len(str(hint)))
- s += f' * {hint}{name_padding} \t{hint.help()}\n'
+ name_padding = " " * (max_name - len(str(hint)))
+ s += f" * {hint}{name_padding} \t{hint.help()}\n"
return s
@staticmethod
def help_versioned_toolsets():
- s = '''Some toolsets support specifying a version using the VERSION suffix. This is
+ s = """Some toolsets support specifying a version using the VERSION suffix. This is
a list of all supported toolset versions:
-'''
+"""
max_name = max(
(
len(str(hint) + str(version))
@@ -264,9 +264,9 @@ a list of all supported toolset versions:
)
for hint in ToolsetType.all_versioned():
for version in hint.all_versions():
- name = f'{hint}{version}'
- name_padding = ' ' * (max_name - len(name))
- s += f' * {name}{name_padding} \t{version.help()}\n'
+ name = f"{hint}{version}"
+ name_padding = " " * (max_name - len(name))
+ s += f" * {name}{name_padding} \t{version.help()}\n"
return s
@staticmethod
@@ -276,10 +276,10 @@ a list of all supported toolset versions:
except ValueError:
pass
for hint in sorted(ToolsetType.all_versioned(), key=str, reverse=True):
- prefix = f'{hint}'
+ prefix = f"{hint}"
if s.startswith(prefix):
return ToolsetVersion(hint, hint.parse_version(s[len(prefix) :]))
- raise argparse.ArgumentTypeError(f'invalid toolset: {s}')
+ raise argparse.ArgumentTypeError(f"invalid toolset: {s}")
class Toolset(abc.ABC):
@@ -304,7 +304,7 @@ class Toolset(abc.ABC):
args = []
generator = self.cmake_generator()
if generator is not None:
- args += ['-G', generator]
+ args += ["-G", generator]
return args
@staticmethod
@@ -328,7 +328,7 @@ class Toolset(abc.ABC):
return Clang
if version.hint is ToolsetType.CLANG_CL:
return ClangCL
- raise NotImplementedError(f'unrecognized toolset: {version}')
+ raise NotImplementedError(f"unrecognized toolset: {version}")
@staticmethod
def make(version, platform):
@@ -368,12 +368,12 @@ class MSVC(Toolset):
def b2_toolset(self):
if self.version is not None:
- return f'msvc-{self.version.to_msvc_version().to_boost_msvc_version()}'
- return 'msvc'
+ return f"msvc-{self.version.to_msvc_version().to_boost_msvc_version()}"
+ return "msvc"
@contextmanager
def b2_args(self):
- yield [f'toolset={self.b2_toolset()}']
+ yield [f"toolset={self.b2_toolset()}"]
# Note: bootstrap.bat picks up MSVC by default.
@@ -381,22 +381,22 @@ class MSVC(Toolset):
# This doesn't actually specify the generator of course, but I don't
# want to implement VS detection logic.
args = super().cmake_args(build_dir, platform)
- args += ['-A', platform.msvc_arch()]
+ args += ["-A", platform.msvc_arch()]
if self.version is not None:
- args += ['-T', self.version.to_msvc_version().to_cmake_toolset()]
+ args += ["-T", self.version.to_msvc_version().to_cmake_toolset()]
return args
class BoostCustom(Toolset):
- COMPILER_VERSION = 'custom'
+ COMPILER_VERSION = "custom"
def __init__(self, compiler, path=None, build_options=None):
if not compiler:
- raise RuntimeError('compiler type is required (like gcc, clang, etc.)')
+ raise RuntimeError("compiler type is required (like gcc, clang, etc.)")
self.compiler = compiler
version = BoostCustom.COMPILER_VERSION
self.version = version
- path = path or ''
+ path = path or ""
path = path and full_exe_name(path)
self.path = path
build_options = build_options or []
@@ -404,37 +404,37 @@ class BoostCustom(Toolset):
def b2_toolset(self):
if self.version:
- return f'{self.compiler}-{self.version}'
+ return f"{self.compiler}-{self.version}"
return self.compiler
def b2_toolset_arg(self):
- return f'toolset={self.b2_toolset()}'
+ return f"toolset={self.b2_toolset()}"
@contextmanager
def _b2_write_config(self):
- config_file = temp_file(prefix='user_config_', suffix='.jam')
+ config_file = temp_file(prefix="user_config_", suffix=".jam")
with config_file as config_path:
config = self.b2_format_config()
- logging.info('Using user config:\n%s', config)
- with open(config_path, mode='w') as fd:
+ logging.info("Using user config:\n%s", config)
+ with open(config_path, mode="w") as fd:
fd.write(config)
yield config_path
def _b2_format_build_options(self):
- return ''.join(f'\n <{name}>{val}' for name, val in self.build_options)
+ return "".join(f"\n <{name}>{val}" for name, val in self.build_options)
def b2_format_config(self):
- version = self.version and f'{self.version} '
- path = self.path and f'{self.path} '
- return f'''using {self.compiler} : {version}: {path}:{self._b2_format_build_options()}
-;'''
+ version = self.version and f"{self.version} "
+ path = self.path and f"{self.path} "
+ return f"""using {self.compiler} : {version}: {path}:{self._b2_format_build_options()}
+;"""
@contextmanager
def b2_args(self):
with self._b2_write_config() as config_path:
args = []
args.append(self.b2_toolset_arg())
- args.append(f'--user-config={config_path}')
+ args.append(f"--user-config={config_path}")
yield args
@@ -447,25 +447,25 @@ class CMakeCustom(Toolset):
@staticmethod
def makefiles():
if on_windows():
- if shutil.which('mingw32-make'):
- return 'MinGW Makefiles'
- return 'Unix Makefiles'
+ if shutil.which("mingw32-make"):
+ return "MinGW Makefiles"
+ return "Unix Makefiles"
# On Linux, make all the way:
- return 'Unix Makefiles'
+ return "Unix Makefiles"
@staticmethod
def nmake_or_makefiles():
if on_windows():
# MinGW utilities like make might be unavailable, but NMake can
# very much be there.
- if shutil.which('nmake'):
- return 'NMake Makefiles'
+ if shutil.which("nmake"):
+ return "NMake Makefiles"
return CMakeCustom.cmake_generator()
@staticmethod
def _cmake_write_config(build_dir, contents):
- path = os.path.join(build_dir, 'custom_toolchain.cmake')
- with open(path, mode='w') as file:
+ path = os.path.join(build_dir, "custom_toolchain.cmake")
+ with open(path, mode="w") as file:
file.write(contents)
return path
@@ -478,7 +478,7 @@ class CMakeCustom(Toolset):
config_path = self._cmake_write_config(build_dir, contents)
return super().cmake_args(build_dir, platform) + [
- f'-DCMAKE_TOOLCHAIN_FILE={config_path}',
+ f"-DCMAKE_TOOLCHAIN_FILE={config_path}",
]
@@ -487,31 +487,31 @@ class GCC(BoostCustom, CMakeCustom):
# MinGW-flavoured GCC on Windows.
def __init__(self):
- BoostCustom.__init__(self, 'gcc', 'g++', self.b2_build_options())
+ BoostCustom.__init__(self, "gcc", "g++", self.b2_build_options())
CMakeCustom.__init__(self)
@staticmethod
def bootstrap_bat_args():
- return ['gcc']
+ return ["gcc"]
@staticmethod
def bootstrap_sh_args():
- return ['--with-toolset=gcc']
+ return ["--with-toolset=gcc"]
@staticmethod
def b2_build_options():
return []
def cmake_format_config(self, platform):
- return f'''
+ return f"""
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_COMPILER g++)
-{platform.cmake_toolset_file()}'''
+{platform.cmake_toolset_file()}"""
def _gcc_or_auto():
- if shutil.which('gcc') is not None:
- return ['gcc']
+ if shutil.which("gcc") is not None:
+ return ["gcc"]
return []
@@ -522,7 +522,7 @@ class MinGW(BoostCustom, CMakeCustom):
def __init__(self, platform):
self.paths = project.mingw.MinGW(platform)
- BoostCustom.__init__(self, 'gcc', self.paths.gxx(), self.b2_build_options())
+ BoostCustom.__init__(self, "gcc", self.paths.gxx(), self.b2_build_options())
CMakeCustom.__init__(self)
@staticmethod
@@ -539,19 +539,19 @@ class MinGW(BoostCustom, CMakeCustom):
return GCC.b2_build_options()
def cmake_format_config(self, platform):
- return f'''
+ return f"""
set(CMAKE_C_COMPILER {self.paths.gcc()})
set(CMAKE_CXX_COMPILER {self.paths.gxx()})
set(CMAKE_AR {self.paths.ar()})
set(CMAKE_RANLIB {self.paths.ranlib()})
set(CMAKE_RC_COMPILER {self.paths.windres()})
set(CMAKE_SYSTEM_NAME Windows)
-'''
+"""
class Clang(BoostCustom, CMakeCustom):
def __init__(self):
- BoostCustom.__init__(self, 'clang', 'clang++', self.b2_build_options())
+ BoostCustom.__init__(self, "clang", "clang++", self.b2_build_options())
CMakeCustom.__init__(self)
@staticmethod
@@ -564,25 +564,25 @@ class Clang(BoostCustom, CMakeCustom):
def bootstrap_sh_args():
# bootstrap.sh, on the other hand, is very much aware of Clang, and
# it can build b2 using this compiler.
- return ['--with-toolset=clang']
+ return ["--with-toolset=clang"]
@staticmethod
def b2_build_options():
options = GCC.b2_build_options()
options += [
- ('cxxflags', '-DBOOST_USE_WINDOWS_H'),
+ ("cxxflags", "-DBOOST_USE_WINDOWS_H"),
# Even with <warnings>off, the build might sometimes fail with the
# following error:
#
# error: constant expression evaluates to -105 which cannot be narrowed to type 'boost::re_detail::cpp_regex_traits_implementation<char>::char_class_type' (aka 'unsigned int')
- ('cxxflags', '-Wno-c++11-narrowing'),
+ ("cxxflags", "-Wno-c++11-narrowing"),
]
if on_windows():
# Prefer LLVM binutils:
- if shutil.which('llvm-ar') is not None:
- options.append(('archiver', 'llvm-ar'))
- if shutil.which('llvm-ranlib') is not None:
- options.append(('ranlib', 'llvm-ranlib'))
+ if shutil.which("llvm-ar") is not None:
+ options.append(("archiver", "llvm-ar"))
+ if shutil.which("llvm-ranlib") is not None:
+ options.append(("ranlib", "llvm-ranlib"))
return options
def b2_format_config(self):
@@ -592,7 +592,7 @@ class Clang(BoostCustom, CMakeCustom):
#
# [1]: https://github.com/Kitware/CMake/blob/v3.18.4/Modules/Platform/Windows-Clang.cmake
# [2]: https://stackoverflow.com/questions/2715106/how-to-create-a-new-variant-in-bjam
- return f'''project : requirements
+ return f"""project : requirements
<target-os>windows:<define>_MT
<target-os>windows,<variant>debug:<define>_DEBUG
<target-os>windows,<runtime-link>static,<variant>debug:<cxxflags>"-Xclang -flto-visibility-public-std -Xclang --dependent-lib=libcmtd"
@@ -601,10 +601,10 @@ class Clang(BoostCustom, CMakeCustom):
<target-os>windows,<runtime-link>shared,<variant>release:<cxxflags>"-D_DLL -Xclang --dependent-lib=msvcrt"
;
{BoostCustom.b2_format_config(self)}
-'''
+"""
def cmake_format_config(self, platform):
- return f'''
+ return f"""
if(CMAKE_VERSION VERSION_LESS "3.15" AND WIN32)
set(CMAKE_C_COMPILER clang-cl)
set(CMAKE_CXX_COMPILER clang-cl)
@@ -612,7 +612,7 @@ else()
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
endif()
-{platform.cmake_toolset_file()}'''
+{platform.cmake_toolset_file()}"""
@staticmethod
def cmake_generator():
@@ -623,8 +623,8 @@ class ClangCL(CMakeCustom):
@contextmanager
def b2_args(self):
yield [
- 'toolset=clang-win',
- 'define=BOOST_USE_WINDOWS_H',
+ "toolset=clang-win",
+ "define=BOOST_USE_WINDOWS_H",
]
# There's no point in building b2 using clang-cl; clang though, presumably
@@ -639,11 +639,11 @@ class ClangCL(CMakeCustom):
return Clang.bootstrap_sh_args()
def cmake_format_config(self, platform):
- return f'''
+ return f"""
set(CMAKE_C_COMPILER clang-cl)
set(CMAKE_CXX_COMPILER clang-cl)
set(CMAKE_SYSTEM_NAME Windows)
-{platform.cmake_toolset_file()}'''
+{platform.cmake_toolset_file()}"""
@staticmethod
def cmake_generator():
diff --git a/project/utils.py b/project/utils.py
index d20f4c1..f09905e 100644
--- a/project/utils.py
+++ b/project/utils.py
@@ -47,19 +47,19 @@ def full_exe_name(exe):
@contextmanager
def setup_logging():
level_names = {
- logging.DEBUG: 'DBG',
- logging.INFO: 'INFO',
- logging.WARNING: 'WARN',
- logging.ERROR: 'ERR',
- logging.CRITICAL: 'CRIT',
+ logging.DEBUG: "DBG",
+ logging.INFO: "INFO",
+ logging.WARNING: "WARN",
+ logging.ERROR: "ERR",
+ logging.CRITICAL: "CRIT",
}
for lvl, name in level_names.items():
logging.addLevelName(lvl, name)
logging.basicConfig(
level=logging.INFO,
- datefmt='%Y-%m-%d %H:%M:%S%z',
- format='%(asctime)s | %(levelname)4s | %(message)s',
+ datefmt="%Y-%m-%d %H:%M:%S%z",
+ format="%(asctime)s | %(levelname)4s | %(message)s",
# Log to stdout, because that's where subprocess's output goes (so that
# they don't get interleaved).
stream=sys.stdout,
@@ -82,7 +82,7 @@ def cd(path):
def run(cmd_line, **kwargs):
- logging.info('Running executable: %s', cmd_line)
+ logging.info("Running executable: %s", cmd_line)
return subprocess.run(cmd_line, check=True, **kwargs)
@@ -91,7 +91,7 @@ def delete_on_error(path):
try:
yield
except:
- logging.info('Removing temporary file: %s', path)
+ logging.info("Removing temporary file: %s", path)
os.remove(path)
raise
@@ -101,20 +101,20 @@ def delete(path):
try:
yield
finally:
- logging.info('Removing temporary file: %s', path)
+ logging.info("Removing temporary file: %s", path)
os.remove(path)
@contextmanager
def temp_file(**kwargs):
- '''Make NamedTemporaryFile usable on Windows.
+ """Make NamedTemporaryFile usable on Windows.
It can't be opened a second time on Windows, hence this silliness.
- '''
+ """
tmp = tempfile.NamedTemporaryFile(delete=False, **kwargs)
with tmp as file, delete_on_error(file.name):
path = file.name
- logging.info('Created temporary file: %s', path)
+ logging.info("Created temporary file: %s", path)
with delete(path):
yield path
@@ -132,7 +132,7 @@ def retry(exc_type, timeout=5, tries=3, backoff=2):
logging.exception(e)
current_try += 1
if current_try < tries:
- logging.error('Retrying after %d seconds', current_timeout)
+ logging.error("Retrying after %d seconds", current_timeout)
time.sleep(current_timeout)
current_timeout *= backoff
continue
diff --git a/project/version.py b/project/version.py
index 3aa3c44..f39049f 100644
--- a/project/version.py
+++ b/project/version.py
@@ -1,12 +1,12 @@
from importlib import metadata
try:
- __version__ = metadata.version('cmake_common')
+ __version__ = metadata.version("cmake_common")
except:
- __version__ = 'unknown'
+ __version__ = "unknown"
def add_to_arg_parser(parser):
parser.add_argument(
- '--version', '-V', action='version', version=f'%(prog)s {__version__}'
+ "--version", "-V", action="version", version=f"%(prog)s {__version__}"
)