diff options
| author | Egor Tensin <egor@tensin.name> | 2026-06-23 18:10:36 +0200 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2026-06-23 18:10:36 +0200 |
| commit | db93568d9f8423c4fe6399562f13fa54f7c96494 (patch) | |
| tree | e5543032f89706d0afb3a3c9f777ba1aa14e2620 /project/platform.py | |
| parent | workflows/aur: inherit secrets (diff) | |
| download | cmake-common-db93568d9f8423c4fe6399562f13fa54f7c96494.tar.gz cmake-common-db93568d9f8423c4fe6399562f13fa54f7c96494.zip | |
use default settings for Black
Diffstat (limited to 'project/platform.py')
| -rw-r--r-- | project/platform.py | 52 |
1 files changed, 26 insertions, 26 deletions
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}") |
