aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/cmake')
-rw-r--r--mesonbuild/cmake/client.py12
-rw-r--r--mesonbuild/cmake/common.py16
-rw-r--r--mesonbuild/cmake/executor.py8
-rw-r--r--mesonbuild/cmake/fileapi.py2
-rw-r--r--mesonbuild/cmake/interpreter.py66
-rw-r--r--mesonbuild/cmake/toolchain.py2
-rw-r--r--mesonbuild/cmake/traceparser.py22
7 files changed, 64 insertions, 64 deletions
diff --git a/mesonbuild/cmake/client.py b/mesonbuild/cmake/client.py
index eeaab57..bcbb52e 100644
--- a/mesonbuild/cmake/client.py
+++ b/mesonbuild/cmake/client.py
@@ -69,7 +69,7 @@ class RequestBase(MessageBase):
@staticmethod
def gen_cookie() -> str:
RequestBase.cookie_counter += 1
- return 'meson_{}'.format(RequestBase.cookie_counter)
+ return f'meson_{RequestBase.cookie_counter}'
class ReplyBase(MessageBase):
def __init__(self, cookie: str, in_reply_to: str) -> None:
@@ -214,7 +214,7 @@ class ReplyCodeModel(ReplyBase):
def log(self) -> None:
mlog.log('CMake code mode:')
for idx, i in enumerate(self.configs):
- mlog.log('Configuration {}:'.format(idx))
+ mlog.log(f'Configuration {idx}:')
with mlog.nested():
i.log()
@@ -274,10 +274,10 @@ class CMakeClient:
msg_type = raw_data['type']
func = self.type_map.get(msg_type, None)
if not func:
- raise CMakeException('Recieved unknown message type "{}"'.format(msg_type))
+ raise CMakeException(f'Recieved unknown message type "{msg_type}"')
for i in CMAKE_MESSAGE_TYPES[msg_type]:
if i not in raw_data:
- raise CMakeException('Key "{}" is missing from CMake server message type {}'.format(i, msg_type))
+ raise CMakeException(f'Key "{i}" is missing from CMake server message type {msg_type}')
return func(raw_data)
def writeMessage(self, msg: MessageBase) -> None:
@@ -316,10 +316,10 @@ class CMakeClient:
reply_type = data['inReplyTo']
func = self.reply_map.get(reply_type, None)
if not func:
- raise CMakeException('Recieved unknown reply type "{}"'.format(reply_type))
+ raise CMakeException(f'Recieved unknown reply type "{reply_type}"')
for i in ['cookie'] + CMAKE_REPLY_TYPES[reply_type]:
if i not in data:
- raise CMakeException('Key "{}" is missing from CMake server message type {}'.format(i, type))
+ raise CMakeException(f'Key "{i}" is missing from CMake server message type {type}')
return func(data)
def resolve_reply_cmakeInputs(self, data: T.Dict[str, T.Any]) -> ReplyCMakeInputs:
diff --git a/mesonbuild/cmake/common.py b/mesonbuild/cmake/common.py
index 0ec1698..f0a54b5 100644
--- a/mesonbuild/cmake/common.py
+++ b/mesonbuild/cmake/common.py
@@ -56,7 +56,7 @@ class CMakeBuildFile:
self.is_temp = is_temp
def __repr__(self) -> str:
- return '<{}: {}; cmake={}; temp={}>'.format(self.__class__.__name__, self.file, self.is_cmake, self.is_temp)
+ return f'<{self.__class__.__name__}: {self.file}; cmake={self.is_cmake}; temp={self.is_temp}>'
def _flags_to_list(raw: str) -> T.List[str]:
# Convert a raw commandline string into a list of strings
@@ -103,10 +103,10 @@ def cmake_defines_to_args(raw: T.Any, permissive: bool = False) -> T.List[str]:
mlog.warning(' --> Ignoring this option')
continue
if isinstance(val, (str, int, float)):
- res += ['-D{}={}'.format(key, val)]
+ res += [f'-D{key}={val}']
elif isinstance(val, bool):
val_str = 'ON' if val else 'OFF'
- res += ['-D{}={}'.format(key, val_str)]
+ res += [f'-D{key}={val_str}']
else:
raise MesonException('Type "{}" of "{}" is not supported as for a CMake define value'.format(type(val).__name__, key))
@@ -132,7 +132,7 @@ class CMakeInclude:
self.isSystem = isSystem
def __repr__(self) -> str:
- return '<CMakeInclude: {} -- isSystem = {}>'.format(self.path, self.isSystem)
+ return f'<CMakeInclude: {self.path} -- isSystem = {self.isSystem}>'
class CMakeFileGroup:
def __init__(self, data: T.Dict[str, T.Any]) -> None:
@@ -201,7 +201,7 @@ class CMakeTarget:
mlog.log('type =', mlog.bold(self.type))
# mlog.log('is_generator_provided =', mlog.bold('true' if self.is_generator_provided else 'false'))
for idx, i in enumerate(self.files):
- mlog.log('Files {}:'.format(idx))
+ mlog.log(f'Files {idx}:')
with mlog.nested():
i.log()
@@ -220,7 +220,7 @@ class CMakeProject:
mlog.log('build_dir =', mlog.bold(self.build_dir.as_posix()))
mlog.log('name =', mlog.bold(self.name))
for idx, i in enumerate(self.targets):
- mlog.log('Target {}:'.format(idx))
+ mlog.log(f'Target {idx}:')
with mlog.nested():
i.log()
@@ -234,7 +234,7 @@ class CMakeConfiguration:
def log(self) -> None:
mlog.log('name =', mlog.bold(self.name))
for idx, i in enumerate(self.projects):
- mlog.log('Project {}:'.format(idx))
+ mlog.log(f'Project {idx}:')
with mlog.nested():
i.log()
@@ -265,7 +265,7 @@ class SingleTargetOptions:
opt = i[:i.find('=')]
if opt not in self.opts:
res += [i]
- res += ['{}={}'.format(k, v) for k, v in self.opts.items()]
+ res += [f'{k}={v}' for k, v in self.opts.items()]
return res
def get_compile_args(self, lang: str, initial: T.List[str]) -> T.List[str]:
diff --git a/mesonbuild/cmake/executor.py b/mesonbuild/cmake/executor.py
index e4b85de..860d410 100644
--- a/mesonbuild/cmake/executor.py
+++ b/mesonbuild/cmake/executor.py
@@ -87,7 +87,7 @@ class CMakeExecutor:
continue
if not silent:
mlog.log('Found CMake:', mlog.bold(potential_cmakebin.get_path()),
- '({})'.format(version_if_ok))
+ f'({version_if_ok})')
CMakeExecutor.class_cmakebin[self.for_machine] = potential_cmakebin
CMakeExecutor.class_cmakevers[self.for_machine] = version_if_ok
break
@@ -104,7 +104,7 @@ class CMakeExecutor:
def check_cmake(self, cmakebin: 'ExternalProgram') -> T.Optional[str]:
if not cmakebin.found():
- mlog.log('Did not find CMake {!r}'.format(cmakebin.name))
+ mlog.log(f'Did not find CMake {cmakebin.name!r}')
return None
try:
p, out = Popen_safe(cmakebin.get_command() + ['--version'])[0:2]
@@ -202,9 +202,9 @@ class CMakeExecutor:
return rc, out, err
def _call_impl(self, args: T.List[str], build_dir: Path, env: T.Optional[T.Dict[str, str]]) -> TYPE_result:
- mlog.debug('Calling CMake ({}) in {} with:'.format(self.cmakebin.get_command(), build_dir))
+ mlog.debug(f'Calling CMake ({self.cmakebin.get_command()}) in {build_dir} with:')
for i in args:
- mlog.debug(' - "{}"'.format(i))
+ mlog.debug(f' - "{i}"')
if not self.print_cmout:
return self._call_quiet(args, build_dir, env)
else:
diff --git a/mesonbuild/cmake/fileapi.py b/mesonbuild/cmake/fileapi.py
index ce63219..6773e9a 100644
--- a/mesonbuild/cmake/fileapi.py
+++ b/mesonbuild/cmake/fileapi.py
@@ -311,7 +311,7 @@ class CMakeFileAPI:
def _reply_file_content(self, filename: Path) -> T.Dict[str, T.Any]:
real_path = self.reply_dir / filename
if not real_path.exists():
- raise CMakeException('File "{}" does not exist'.format(real_path))
+ raise CMakeException(f'File "{real_path}" does not exist')
data = json.loads(real_path.read_text())
assert isinstance(data, dict)
diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py
index abb4983..cccd358 100644
--- a/mesonbuild/cmake/interpreter.py
+++ b/mesonbuild/cmake/interpreter.py
@@ -175,7 +175,7 @@ class OutputTargetMap:
continue
new_name = name[:-len(i) - 1]
new_name = OutputTargetMap.rm_so_version.sub('', new_name)
- candidates += ['{}.{}'.format(new_name, i)]
+ candidates += [f'{new_name}.{i}']
for i in candidates:
keys += [self._rel_artifact_key(Path(i)), Path(i).name, self._base_artifact_key(Path(i))]
return self._return_first_valid_key(keys)
@@ -194,21 +194,21 @@ class OutputTargetMap:
return None
def _target_key(self, tgt_name: str) -> str:
- return '__tgt_{}__'.format(tgt_name)
+ return f'__tgt_{tgt_name}__'
def _rel_generated_file_key(self, fname: Path) -> T.Optional[str]:
path = self._rel_path(fname)
- return '__relgen_{}__'.format(path.as_posix()) if path else None
+ return f'__relgen_{path.as_posix()}__' if path else None
def _base_generated_file_key(self, fname: Path) -> str:
- return '__gen_{}__'.format(fname.name)
+ return f'__gen_{fname.name}__'
def _rel_artifact_key(self, fname: Path) -> T.Optional[str]:
path = self._rel_path(fname)
- return '__relart_{}__'.format(path.as_posix()) if path else None
+ return f'__relart_{path.as_posix()}__' if path else None
def _base_artifact_key(self, fname: Path) -> str:
- return '__art_{}__'.format(fname.name)
+ return f'__art_{fname.name}__'
class ConverterTarget:
def __init__(self, target: CMakeTarget, env: 'Environment', for_machine: MachineChoice) -> None:
@@ -281,7 +281,7 @@ class ConverterTarget:
# Add arguments, but avoid duplicates
args = i.flags
- args += ['-D{}'.format(x) for x in i.defines]
+ args += [f'-D{x}' for x in i.defines]
for lang in languages:
self.compile_opts[lang] += [x for x in args if x not in self.compile_opts[lang]]
@@ -296,7 +296,7 @@ class ConverterTarget:
self.sources += i.sources
def __repr__(self) -> str:
- return '<{}: {}>'.format(self.__class__.__name__, self.name)
+ return f'<{self.__class__.__name__}: {self.name}>'
std_regex = re.compile(r'([-]{1,2}std=|/std:v?|[-]{1,2}std:)(.*)')
@@ -321,7 +321,7 @@ class ConverterTarget:
once=True
)
continue
- self.override_options += ['{}_std={}'.format(i, std)]
+ self.override_options += [f'{i}_std={std}']
elif j in ['-fPIC', '-fpic', '-fPIE', '-fpie']:
self.pie = True
elif isinstance(ctgt, ConverterCustomTarget):
@@ -393,12 +393,12 @@ class ConverterTarget:
if 'RELEASE' in cfgs:
cfg = 'RELEASE'
- if 'IMPORTED_IMPLIB_{}'.format(cfg) in tgt.properties:
- libraries += [x for x in tgt.properties['IMPORTED_IMPLIB_{}'.format(cfg)] if x]
+ if f'IMPORTED_IMPLIB_{cfg}' in tgt.properties:
+ libraries += [x for x in tgt.properties[f'IMPORTED_IMPLIB_{cfg}'] if x]
elif 'IMPORTED_IMPLIB' in tgt.properties:
libraries += [x for x in tgt.properties['IMPORTED_IMPLIB'] if x]
- elif 'IMPORTED_LOCATION_{}'.format(cfg) in tgt.properties:
- libraries += [x for x in tgt.properties['IMPORTED_LOCATION_{}'.format(cfg)] if x]
+ elif f'IMPORTED_LOCATION_{cfg}' in tgt.properties:
+ libraries += [x for x in tgt.properties[f'IMPORTED_LOCATION_{cfg}'] if x]
elif 'IMPORTED_LOCATION' in tgt.properties:
libraries += [x for x in tgt.properties['IMPORTED_LOCATION'] if x]
@@ -408,8 +408,8 @@ class ConverterTarget:
if 'INTERFACE_LINK_LIBRARIES' in tgt.properties:
otherDeps += [x for x in tgt.properties['INTERFACE_LINK_LIBRARIES'] if x]
- if 'IMPORTED_LINK_DEPENDENT_LIBRARIES_{}'.format(cfg) in tgt.properties:
- otherDeps += [x for x in tgt.properties['IMPORTED_LINK_DEPENDENT_LIBRARIES_{}'.format(cfg)] if x]
+ if f'IMPORTED_LINK_DEPENDENT_LIBRARIES_{cfg}' in tgt.properties:
+ otherDeps += [x for x in tgt.properties[f'IMPORTED_LINK_DEPENDENT_LIBRARIES_{cfg}'] if x]
elif 'IMPORTED_LINK_DEPENDENT_LIBRARIES' in tgt.properties:
otherDeps += [x for x in tgt.properties['IMPORTED_LINK_DEPENDENT_LIBRARIES'] if x]
@@ -445,7 +445,7 @@ class ConverterTarget:
supported = list(header_suffixes) + list(obj_suffixes)
for i in self.languages:
supported += list(lang_suffixes[i])
- supported = ['.{}'.format(x) for x in supported]
+ supported = [f'.{x}' for x in supported]
self.sources = [x for x in self.sources if any([x.name.endswith(y) for y in supported])]
self.generated_raw = [x for x in self.generated_raw if any([x.name.endswith(y) for y in supported])]
@@ -560,7 +560,7 @@ class ConverterTarget:
candidates = [j] # type: T.List[str]
if not any([j.endswith('.' + x) for x in exts]):
mlog.warning('Object files do not contain source file extensions, thus falling back to guessing them.', once=True)
- candidates += ['{}.{}'.format(j, x) for x in exts]
+ candidates += [f'{j}.{x}' for x in exts]
if any([x in source_files for x in candidates]):
if linker_workaround:
self._append_objlib_sources(i)
@@ -632,7 +632,7 @@ class ConverterTarget:
return target_type_map.get(self.type.upper())
def log(self) -> None:
- mlog.log('Target', mlog.bold(self.name), '({})'.format(self.cmake_name))
+ mlog.log('Target', mlog.bold(self.name), f'({self.cmake_name})')
mlog.log(' -- artifacts: ', mlog.bold(str(self.artifacts)))
mlog.log(' -- full_name: ', mlog.bold(self.full_name))
mlog.log(' -- type: ', mlog.bold(self.type))
@@ -664,7 +664,7 @@ class CustomTargetReference:
if self.valid():
return '<{}: {} [{}]>'.format(self.__class__.__name__, self.ctgt.name, self.ctgt.outputs[self.index])
else:
- return '<{}: INVALID REFERENCE>'.format(self.__class__.__name__)
+ return f'<{self.__class__.__name__}: INVALID REFERENCE>'
def valid(self) -> bool:
return self.ctgt is not None and self.index >= 0
@@ -681,7 +681,7 @@ class ConverterCustomTarget:
assert target.current_src_dir is not None
self.name = target.name
if not self.name:
- self.name = 'custom_tgt_{}'.format(ConverterCustomTarget.tgt_counter)
+ self.name = f'custom_tgt_{ConverterCustomTarget.tgt_counter}'
ConverterCustomTarget.tgt_counter += 1
self.cmake_name = str(self.name)
self.original_outputs = list(target.outputs)
@@ -702,7 +702,7 @@ class ConverterCustomTarget:
self.name = _sanitize_cmake_name(self.name)
def __repr__(self) -> str:
- return '<{}: {} {}>'.format(self.__class__.__name__, self.name, self.outputs)
+ return f'<{self.__class__.__name__}: {self.name} {self.outputs}>'
def postprocess(self, output_target_map: OutputTargetMap, root_src_dir: Path, all_outputs: T.List[str], trace: CMakeTraceParser) -> None:
# Default the working directory to ${CMAKE_CURRENT_BINARY_DIR}
@@ -730,7 +730,7 @@ class ConverterCustomTarget:
for i in self.outputs:
if i in all_outputs:
old = str(i)
- i = 'c{}_{}'.format(ConverterCustomTarget.out_counter, i)
+ i = f'c{ConverterCustomTarget.out_counter}_{i}'
ConverterCustomTarget.out_counter += 1
self.conflict_map[old] = i
all_outputs += [i]
@@ -760,7 +760,7 @@ class ConverterCustomTarget:
if trace_tgt.type == 'EXECUTABLE' and 'IMPORTED_LOCATION' in trace_tgt.properties:
cmd += trace_tgt.properties['IMPORTED_LOCATION']
continue
- mlog.debug('CMake: Found invalid CMake target "{}" --> ignoring \n{}'.format(j, trace_tgt))
+ mlog.debug(f'CMake: Found invalid CMake target "{j}" --> ignoring \n{trace_tgt}')
# Fallthrough on error
cmd += [j]
@@ -829,7 +829,7 @@ class ConverterCustomTarget:
return None
def log(self) -> None:
- mlog.log('Custom Target', mlog.bold(self.name), '({})'.format(self.cmake_name))
+ mlog.log('Custom Target', mlog.bold(self.name), f'({self.cmake_name})')
mlog.log(' -- command: ', mlog.bold(str(self.command)))
mlog.log(' -- outputs: ', mlog.bold(str(self.outputs)))
mlog.log(' -- conflict_map: ', mlog.bold(str(self.conflict_map)))
@@ -901,10 +901,10 @@ class CMakeInterpreter:
generator = backend_generator_map[self.backend_name]
cmake_args = []
cmake_args += ['-G', generator]
- cmake_args += ['-DCMAKE_INSTALL_PREFIX={}'.format(self.install_prefix)]
+ cmake_args += [f'-DCMAKE_INSTALL_PREFIX={self.install_prefix}']
cmake_args += extra_cmake_options
trace_args = self.trace.trace_args()
- cmcmp_args = ['-DCMAKE_POLICY_WARNING_{}=OFF'.format(x) for x in disable_policy_warnings]
+ cmcmp_args = [f'-DCMAKE_POLICY_WARNING_{x}=OFF' for x in disable_policy_warnings]
if version_compare(cmake_exe.version(), '>=3.14'):
self.cmake_api = CMakeAPI.FILE
@@ -1217,14 +1217,14 @@ class CMakeInterpreter:
# Determine the meson function to use for the build target
tgt_func = tgt.meson_func()
if not tgt_func:
- raise CMakeException('Unknown target type "{}"'.format(tgt.type))
+ raise CMakeException(f'Unknown target type "{tgt.type}"')
# Determine the variable names
- inc_var = '{}_inc'.format(tgt.name)
- dir_var = '{}_dir'.format(tgt.name)
- sys_var = '{}_sys'.format(tgt.name)
- src_var = '{}_src'.format(tgt.name)
- dep_var = '{}_dep'.format(tgt.name)
+ inc_var = f'{tgt.name}_inc'
+ dir_var = f'{tgt.name}_dir'
+ sys_var = f'{tgt.name}_sys'
+ src_var = f'{tgt.name}_src'
+ dep_var = f'{tgt.name}_dep'
tgt_var = tgt.name
install_tgt = options.get_install(tgt.cmake_name, tgt.install)
@@ -1246,7 +1246,7 @@ class CMakeInterpreter:
# Handle compiler args
for key, val in tgt.compile_opts.items():
- tgt_kwargs['{}_args'.format(key)] = options.get_compile_args(tgt.cmake_name, key, val)
+ tgt_kwargs[f'{key}_args'] = options.get_compile_args(tgt.cmake_name, key, val)
# Handle -fPCI, etc
if tgt_func == 'executable':
diff --git a/mesonbuild/cmake/toolchain.py b/mesonbuild/cmake/toolchain.py
index 1870445..c9f821a 100644
--- a/mesonbuild/cmake/toolchain.py
+++ b/mesonbuild/cmake/toolchain.py
@@ -105,7 +105,7 @@ class CMakeToolchain:
for key, value in self.variables.items():
res += 'set(' + key
for i in value:
- res += ' "{}"'.format(i)
+ res += f' "{i}"'
res += ')\n'
res += '\n'
diff --git a/mesonbuild/cmake/traceparser.py b/mesonbuild/cmake/traceparser.py
index 298c6b8..6294fa1 100644
--- a/mesonbuild/cmake/traceparser.py
+++ b/mesonbuild/cmake/traceparser.py
@@ -134,7 +134,7 @@ class CMakeTraceParser:
base_args = ['--no-warn-unused-cli']
if not self.requires_stderr():
- base_args += ['--trace-redirect={}'.format(self.trace_file)]
+ base_args += [f'--trace-redirect={self.trace_file}']
return arg_map[self.trace_format] + base_args
@@ -157,7 +157,7 @@ class CMakeTraceParser:
elif self.trace_format == 'json-v1':
lexer1 = self._lex_trace_json(trace)
else:
- raise CMakeException('CMake: Internal error: Invalid trace format {}. Expected [human, json-v1]'.format(self.trace_format))
+ raise CMakeException(f'CMake: Internal error: Invalid trace format {self.trace_format}. Expected [human, json-v1]')
# Primary pass -- parse everything
for l in lexer1:
@@ -213,9 +213,9 @@ class CMakeTraceParser:
# Generate an exception if the parser is not in permissive mode
if self.permissive:
- mlog.debug('CMake trace warning: {}() {}\n{}'.format(function, error, tline))
+ mlog.debug(f'CMake trace warning: {function}() {error}\n{tline}')
return None
- raise CMakeException('CMake: {}() {}\n{}'.format(function, error, tline))
+ raise CMakeException(f'CMake: {function}() {error}\n{tline}')
def _cmake_set(self, tline: CMakeTraceLine) -> None:
"""Handler for the CMake set() function in all variaties.
@@ -439,7 +439,7 @@ class CMakeTraceParser:
def do_target(tgt: str) -> None:
if i not in self.targets:
- return self._gen_exception('set_property', 'TARGET {} not found'.format(i), tline)
+ return self._gen_exception('set_property', f'TARGET {i} not found', tline)
if identifier not in self.targets[i].properties:
self.targets[i].properties[identifier] = []
@@ -525,7 +525,7 @@ class CMakeTraceParser:
for name, value in arglist:
for i in targets:
if i not in self.targets:
- return self._gen_exception('set_target_properties', 'TARGET {} not found'.format(i), tline)
+ return self._gen_exception('set_target_properties', f'TARGET {i} not found', tline)
self.targets[i].properties[name] = value
@@ -574,7 +574,7 @@ class CMakeTraceParser:
target = args[0]
if target not in self.targets:
- return self._gen_exception(func, 'TARGET {} not found'.format(target), tline)
+ return self._gen_exception(func, f'TARGET {target} not found', tline)
interface = []
private = []
@@ -706,13 +706,13 @@ class CMakeTraceParser:
path_found = False
elif reg_end.match(i):
# File detected
- curr_str = '{} {}'.format(curr_str, i)
+ curr_str = f'{curr_str} {i}'
fixed_list += [curr_str]
curr_str = None
path_found = False
- elif Path('{} {}'.format(curr_str, i)).exists():
+ elif Path(f'{curr_str} {i}').exists():
# Path detected
- curr_str = '{} {}'.format(curr_str, i)
+ curr_str = f'{curr_str} {i}'
path_found = True
elif path_found:
# Add path to fixed_list after ensuring the whole path is in curr_str
@@ -720,7 +720,7 @@ class CMakeTraceParser:
curr_str = i
path_found = False
else:
- curr_str = '{} {}'.format(curr_str, i)
+ curr_str = f'{curr_str} {i}'
path_found = False
if curr_str: