aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/backend
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/backend')
-rw-r--r--mesonbuild/backend/backends.py26
-rw-r--r--mesonbuild/backend/ninjabackend.py76
-rw-r--r--mesonbuild/backend/vs2010backend.py8
-rw-r--r--mesonbuild/backend/xcodebackend.py68
4 files changed, 89 insertions, 89 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index 2e1f081..96d2f46 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -65,7 +65,7 @@ class TestProtocol(enum.Enum):
return cls.GTEST
elif string == 'rust':
return cls.RUST
- raise MesonException('unknown test format {}'.format(string))
+ raise MesonException(f'unknown test format {string}')
def __str__(self) -> str:
cls = type(self)
@@ -282,14 +282,14 @@ class Backend:
return os.path.join(self.get_target_dir(target), target.get_filename())
elif isinstance(target, (build.CustomTarget, build.CustomTargetIndex)):
if not target.is_linkable_target():
- raise MesonException('Tried to link against custom target "{}", which is not linkable.'.format(target.name))
+ raise MesonException(f'Tried to link against custom target "{target.name}", which is not linkable.')
return os.path.join(self.get_target_dir(target), target.get_filename())
elif isinstance(target, build.Executable):
if target.import_filename:
return os.path.join(self.get_target_dir(target), target.get_import_filename())
else:
return None
- raise AssertionError('BUG: Tried to link to {!r} which is not linkable'.format(target))
+ raise AssertionError(f'BUG: Tried to link to {target!r} which is not linkable')
@lru_cache(maxsize=None)
def get_target_dir(self, target):
@@ -335,7 +335,7 @@ class Backend:
def get_unity_source_file(self, target, suffix, number):
# There is a potential conflict here, but it is unlikely that
# anyone both enables unity builds and has a file called foo-unity.cpp.
- osrc = '{}-unity{}.{}'.format(target.name, number, suffix)
+ osrc = f'{target.name}-unity{number}.{suffix}'
return mesonlib.File.from_built_file(self.get_target_private_dir(target), osrc)
def generate_unity_files(self, target, unity_src):
@@ -368,7 +368,7 @@ class Backend:
ofile = init_language_file(comp.get_default_suffix(), unity_file_number)
unity_file_number += 1
files_in_current = 0
- ofile.write('#include<{}>\n'.format(src))
+ ofile.write(f'#include<{src}>\n')
files_in_current += 1
if ofile:
ofile.close()
@@ -505,7 +505,7 @@ class Backend:
data = bytes(str(es.env) + str(es.cmd_args) + str(es.workdir) + str(capture),
encoding='utf-8')
digest = hashlib.sha1(data).hexdigest()
- scratch_file = 'meson_exe_{}_{}.dat'.format(basename, digest)
+ scratch_file = f'meson_exe_{basename}_{digest}.dat'
exe_data = os.path.join(self.environment.get_scratch_dir(), scratch_file)
with open(exe_data, 'wb') as f:
pickle.dump(es, f)
@@ -575,7 +575,7 @@ class Backend:
for dir in symbols_match.group(1).split(':'):
# Prevent usage of --just-symbols to specify rpath
if Path(dir).is_dir():
- raise MesonException('Invalid arg for --just-symbols, {} is a directory.'.format(dir))
+ raise MesonException(f'Invalid arg for --just-symbols, {dir} is a directory.')
return dirs
def rpaths_for_bundled_shared_libraries(self, target, exclude_system=True):
@@ -601,7 +601,7 @@ class Backend:
continue
if libdir.startswith(self.environment.get_source_dir()):
rel_to_src = libdir[len(self.environment.get_source_dir()) + 1:]
- assert not os.path.isabs(rel_to_src), 'rel_to_src: {} is absolute'.format(rel_to_src)
+ assert not os.path.isabs(rel_to_src), f'rel_to_src: {rel_to_src} is absolute'
paths.append(os.path.join(self.build_to_src, rel_to_src))
else:
paths.append(libdir)
@@ -717,7 +717,7 @@ class Backend:
def create_msvc_pch_implementation(self, target, lang, pch_header):
# We have to include the language in the file name, otherwise
# pch.c and pch.cpp will both end up as pch.obj in VS backends.
- impl_name = 'meson_pch-{}.{}'.format(lang, lang)
+ impl_name = f'meson_pch-{lang}.{lang}'
pch_rel_to_build = os.path.join(self.get_target_private_dir(target), impl_name)
# Make sure to prepend the build dir, since the working directory is
# not defined. Otherwise, we might create the file in the wrong path.
@@ -833,7 +833,7 @@ class Backend:
args = []
for d in deps:
if not (d.is_linkable_target()):
- raise RuntimeError('Tried to link with a non-library target "{}".'.format(d.get_basename()))
+ raise RuntimeError(f'Tried to link with a non-library target "{d.get_basename()}".')
arg = self.get_target_filename_for_linking(d)
if not arg:
continue
@@ -1011,7 +1011,7 @@ class Backend:
# to the future by a minuscule amount, less than
# 0.001 seconds. I don't know why.
if delta > 0.001:
- raise MesonException('Clock skew detected. File {} has a time stamp {:.4f}s in the future.'.format(absf, delta))
+ raise MesonException(f'Clock skew detected. File {absf} has a time stamp {delta:.4f}s in the future.')
def build_target_to_cmd_array(self, bt):
if isinstance(bt, build.BuildTarget):
@@ -1036,7 +1036,7 @@ class Backend:
m = regex.search(arg)
while m is not None:
index = int(m.group(1))
- src = '@OUTPUT{}@'.format(index)
+ src = f'@OUTPUT{index}@'
arg = arg.replace(src, os.path.join(private_dir, output_list[index]))
m = regex.search(arg)
newargs.append(arg)
@@ -1239,7 +1239,7 @@ class Backend:
for s in self.build.postconf_scripts:
name = ' '.join(s.cmd_args)
- mlog.log('Running postconf script {!r}'.format(name))
+ mlog.log(f'Running postconf script {name!r}')
run_exe(s, env)
def create_install_data(self) -> InstallData:
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 240cc0a..819d478 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -64,7 +64,7 @@ def cmd_quote(s):
# any terminal backslashes likewise need doubling
s = re.sub(r'(\\*)$', lambda m: '\\' * (len(m.group(1)) * 2), s)
# and double quote
- s = '"{}"'.format(s)
+ s = f'"{s}"'
return s
@@ -238,7 +238,7 @@ class NinjaRule:
yield '_RSP'
for rsp in rule_iter():
- outfile.write('rule {}{}\n'.format(self.name, rsp))
+ outfile.write(f'rule {self.name}{rsp}\n')
if rsp == '_RSP':
outfile.write(' command = {} @$out.rsp\n'.format(' '.join([self._quoter(x) for x in self.command])))
outfile.write(' rspfile = $out.rsp\n')
@@ -246,10 +246,10 @@ class NinjaRule:
else:
outfile.write(' command = {}\n'.format(' '.join([self._quoter(x) for x in (self.command + self.args)])))
if self.deps:
- outfile.write(' deps = {}\n'.format(self.deps))
+ outfile.write(f' deps = {self.deps}\n')
if self.depfile:
- outfile.write(' depfile = {}\n'.format(self.depfile))
- outfile.write(' description = {}\n'.format(self.description))
+ outfile.write(f' depfile = {self.depfile}\n')
+ outfile.write(f' description = {self.description}\n')
if self.extra:
for l in self.extra.split('\n'):
outfile.write(' ')
@@ -364,7 +364,7 @@ class NinjaBuildElement:
mlog.debug("Command line for building %s is long, using a response file" % self.outfilenames)
else:
rulename = self.rulename
- line = 'build {}{}: {} {}'.format(outs, implicit_outs, rulename, ins)
+ line = f'build {outs}{implicit_outs}: {rulename} {ins}'
if len(self.deps) > 0:
line += ' | ' + ' '.join([ninja_quote(x, True) for x in sorted(self.deps)])
if len(self.orderdeps) > 0:
@@ -396,7 +396,7 @@ class NinjaBuildElement:
for e in self.elems:
(name, elems) = e
should_quote = name not in raw_names
- line = ' {} = '.format(name)
+ line = f' {name} = '
newelems = []
for i in elems:
if not should_quote or i == '&&': # Hackety hack hack
@@ -411,7 +411,7 @@ class NinjaBuildElement:
def check_outputs(self):
for n in self.outfilenames:
if n in self.all_outputs:
- raise MesonException('Multiple producers for Ninja target "{}". Please rename your targets.'.format(n))
+ raise MesonException(f'Multiple producers for Ninja target "{n}". Please rename your targets.')
self.all_outputs[n] = True
class NinjaBackend(backends.Backend):
@@ -511,7 +511,7 @@ int dummy;
outfilename = os.path.join(self.environment.get_build_dir(), self.ninja_filename)
tempfilename = outfilename + '~'
with open(tempfilename, 'w', encoding='utf-8') as outfile:
- outfile.write('# This is the build file for project "{}"\n'.format(self.build.get_project()))
+ outfile.write(f'# This is the build file for project "{self.build.get_project()}"\n')
outfile.write('# It is autogenerated by the Meson build system.\n')
outfile.write('# Do not edit by hand.\n\n')
outfile.write('ninja_required_version = 1.8.2\n\n')
@@ -563,9 +563,9 @@ int dummy;
# rule store as being wanted in compdb
for for_machine in MachineChoice:
for lang in self.environment.coredata.compilers[for_machine]:
- rules += ["%s%s" % (rule, ext) for rule in [self.get_compiler_rule_name(lang, for_machine)]
+ rules += [f"{rule}{ext}" for rule in [self.get_compiler_rule_name(lang, for_machine)]
for ext in ['', '_RSP']]
- rules += ["%s%s" % (rule, ext) for rule in [self.get_pch_rule_name(lang, for_machine)]
+ rules += [f"{rule}{ext}" for rule in [self.get_pch_rule_name(lang, for_machine)]
for ext in ['', '_RSP']]
compdb_options = ['-x'] if mesonlib.version_compare(self.ninja_version, '>=1.9') else []
ninja_compdb = self.ninja_command + ['-t', 'compdb'] + compdb_options + rules
@@ -620,7 +620,7 @@ int dummy;
# either in the source root, or generated with configure_file and
# in the build root
if not isinstance(s, File):
- raise InvalidArguments('All sources in target {!r} must be of type mesonlib.File'.format(s))
+ raise InvalidArguments(f'All sources in target {s!r} must be of type mesonlib.File')
f = s.rel_to_builddir(self.build_to_src)
srcs[f] = s
return srcs
@@ -962,7 +962,7 @@ int dummy;
capture=ofilenames[0] if target.capture else None,
env=target.env)
if reason:
- cmd_type = ' (wrapped by meson {})'.format(reason)
+ cmd_type = f' (wrapped by meson {reason})'
else:
cmd_type = ''
if target.depfile is not None:
@@ -980,10 +980,10 @@ int dummy;
def build_run_target_name(self, target):
if target.subproject != '':
- subproject_prefix = '{}@@'.format(target.subproject)
+ subproject_prefix = f'{target.subproject}@@'
else:
subproject_prefix = ''
- return '{}{}'.format(subproject_prefix, target.name)
+ return f'{subproject_prefix}{target.name}'
def generate_run_target(self, target):
target_name = self.build_run_target_name(target)
@@ -998,8 +998,8 @@ int dummy;
meson_exe_cmd, reason = self.as_meson_exe_cmdline(target_name, target.command[0], cmd[1:],
force_serialize=True, env=target_env,
verbose=True)
- cmd_type = ' (wrapped by meson {})'.format(reason)
- internal_target_name = 'meson-{}'.format(target_name)
+ cmd_type = f' (wrapped by meson {reason})'
+ internal_target_name = f'meson-{target_name}'
elem = NinjaBuildElement(self.all_outputs, internal_target_name, 'CUSTOM_COMMAND', [])
elem.add_item('COMMAND', meson_exe_cmd)
elem.add_item('description', desc.format(target.name, cmd_type))
@@ -1141,7 +1141,7 @@ int dummy;
def add_rule(self, rule):
if rule.name in self.ruledict:
- raise MesonException('Tried to add rule {} twice.'.format(rule.name))
+ raise MesonException(f'Tried to add rule {rule.name} twice.')
self.rules.append(rule)
self.ruledict[rule.name] = rule
@@ -1153,7 +1153,7 @@ int dummy;
if build.rulename in self.ruledict:
build.rule = self.ruledict[build.rulename]
else:
- mlog.warning("build statement for {} references non-existent rule {}".format(build.outfilenames, build.rulename))
+ mlog.warning(f"build statement for {build.outfilenames} references non-existent rule {build.rulename}")
def write_rules(self, outfile):
for b in self.build_elements:
@@ -1238,12 +1238,12 @@ int dummy;
ofilename = os.path.join(self.get_target_private_dir(target), ofilebase)
elem = NinjaBuildElement(self.all_outputs, ofilename, "CUSTOM_COMMAND", rel_sourcefile)
elem.add_item('COMMAND', ['resgen', rel_sourcefile, ofilename])
- elem.add_item('DESC', 'Compiling resource {}'.format(rel_sourcefile))
+ elem.add_item('DESC', f'Compiling resource {rel_sourcefile}')
self.add_build(elem)
deps.append(ofilename)
a = '-resource:' + ofilename
else:
- raise InvalidArguments('Unknown resource file {}.'.format(r))
+ raise InvalidArguments(f'Unknown resource file {r}.')
args.append(a)
return args, deps
@@ -1546,13 +1546,13 @@ int dummy;
main_rust_file = None
for i in target.get_sources():
if not rustc.can_compile(i):
- raise InvalidArguments('Rust target {} contains a non-rust source file.'.format(target.get_basename()))
+ raise InvalidArguments(f'Rust target {target.get_basename()} contains a non-rust source file.')
if main_rust_file is None:
main_rust_file = i.rel_to_builddir(self.build_to_src)
for g in target.get_generated_sources():
for i in g.get_outputs():
if not rustc.can_compile(i):
- raise InvalidArguments('Rust target {} contains a non-rust source file.'.format(target.get_basename()))
+ raise InvalidArguments(f'Rust target {target.get_basename()} contains a non-rust source file.')
if isinstance(g, GeneratedList):
fname = os.path.join(self.get_target_private_dir(target), i)
else:
@@ -1581,7 +1581,7 @@ int dummy;
# to be -C link-arg=foo
if cratetype in {'bin', 'dylib'}:
for a in rustc.linker.get_always_args():
- args += ['-C', 'link-arg={}'.format(a)]
+ args += ['-C', f'link-arg={a}']
opt_proxy = self.get_compiler_options_for_target(target)
@@ -1593,7 +1593,7 @@ int dummy;
args += self.build.get_global_args(rustc, target.for_machine)
args += self.build.get_project_args(rustc, target.subproject, target.for_machine)
depfile = os.path.join(target.subdir, target.name + '.d')
- args += ['--emit', 'dep-info={}'.format(depfile), '--emit', 'link']
+ args += ['--emit', f'dep-info={depfile}', '--emit', 'link']
args += target.get_extra_args('rust')
args += rustc.get_output_args(os.path.join(target.subdir, target.get_filename()))
args += self.environment.coredata.get_external_args(target.for_machine, rustc.language)
@@ -1754,7 +1754,7 @@ int dummy;
abs_headers.append(absh)
header_imports += swiftc.get_header_import_args(absh)
else:
- raise InvalidArguments('Swift target {} contains a non-swift source file.'.format(target.get_basename()))
+ raise InvalidArguments(f'Swift target {target.get_basename()} contains a non-swift source file.')
os.makedirs(self.get_target_private_dir_abs(target), exist_ok=True)
compile_args = swiftc.get_compile_only_args()
compile_args += swiftc.get_optimization_args(self.get_option_for_target(OptionKey('optimization'), target))
@@ -1954,7 +1954,7 @@ int dummy;
def generate_fortran_dep_hack(self, crstr: str) -> None:
if self.use_dyndeps_for_fortran():
return
- rule = 'FORTRAN_DEP_HACK{}'.format(crstr)
+ rule = f'FORTRAN_DEP_HACK{crstr}'
if mesonlib.is_windows():
cmd = ['cmd', '/C']
else:
@@ -2001,7 +2001,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
depargs = NinjaCommandArg.list(compiler.get_dependency_gen_args('$out', '$DEPFILE'), Quoting.none)
command = compiler.get_exelist()
args = ['$ARGS'] + depargs + NinjaCommandArg.list(compiler.get_output_args('$out'), Quoting.none) + compiler.get_compile_only_args() + ['$in']
- description = 'Compiling {} object $out'.format(compiler.get_display_language())
+ description = f'Compiling {compiler.get_display_language()} object $out'
if isinstance(compiler, VisualStudioLikeCompiler):
deps = 'msvc'
depfile = None
@@ -2094,7 +2094,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
if len(generator.outputs) == 1:
sole_output = os.path.join(self.get_target_private_dir(target), outfilelist[i])
else:
- sole_output = '{}'.format(curfile)
+ sole_output = f'{curfile}'
infilename = curfile.rel_to_builddir(self.build_to_src)
base_args = generator.get_arglist(infilename)
outfiles = genlist.get_outputs_for(curfile)
@@ -2129,13 +2129,13 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
elem.add_dep(extra_dependencies)
if len(generator.outputs) == 1:
- what = '{!r}'.format(sole_output)
+ what = f'{sole_output!r}'
else:
# since there are multiple outputs, we log the source that caused the rebuild
- what = 'from {!r}.'.format(sole_output)
+ what = f'from {sole_output!r}.'
if reason:
- reason = ' (wrapped by meson {})'.format(reason)
- elem.add_item('DESC', 'Generating {}{}.'.format(what, reason))
+ reason = f' (wrapped by meson {reason})'
+ elem.add_item('DESC', f'Generating {what}{reason}.')
if isinstance(exe, build.BuildTarget):
elem.add_dep(self.get_target_filename(exe))
@@ -2305,7 +2305,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
elif isinstance(src, File):
rel_src = src.rel_to_builddir(self.build_to_src)
else:
- raise InvalidArguments('Invalid source type: {!r}'.format(src))
+ raise InvalidArguments(f'Invalid source type: {src!r}')
# Write the Ninja build command
compiler_name = self.get_compiler_rule_name('llvm_ir', compiler.for_machine)
element = NinjaBuildElement(self.all_outputs, rel_obj, compiler_name, rel_src)
@@ -2437,7 +2437,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
order_deps = order_deps if order_deps is not None else []
if isinstance(src, str) and src.endswith('.h'):
- raise AssertionError('BUG: sources should not contain headers {!r}'.format(src))
+ raise AssertionError(f'BUG: sources should not contain headers {src!r}')
compiler = get_compiler_for_source(target.compilers.values(), src)
commands = self._generate_single_compile(target, compiler, is_generated)
@@ -2459,9 +2459,9 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
assert rel_src.startswith(build_dir)
rel_src = rel_src[len(build_dir) + 1:]
elif is_generated:
- raise AssertionError('BUG: broken generated source file handling for {!r}'.format(src))
+ raise AssertionError(f'BUG: broken generated source file handling for {src!r}')
else:
- raise InvalidArguments('Invalid source type: {!r}'.format(src))
+ raise InvalidArguments(f'Invalid source type: {src!r}')
obj_basename = self.object_filename_from_source(target, src)
rel_obj = os.path.join(self.get_target_private_dir(target), obj_basename)
dep_file = compiler.depfile_for_object(rel_obj)
@@ -2808,7 +2808,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
cmd = self.replace_paths(target, cmd)
elem.add_item('COMMAND', cmd)
- elem.add_item('description', 'Prelinking {}.'.format(prelink_name))
+ elem.add_item('description', f'Prelinking {prelink_name}.')
self.add_build(elem)
return [prelink_name]
diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py
index 82891cd..93b7f78 100644
--- a/mesonbuild/backend/vs2010backend.py
+++ b/mesonbuild/backend/vs2010backend.py
@@ -233,7 +233,7 @@ class Vs2010Backend(backends.Backend):
target_arch = os.environ.get('Platform', 'x86')
host_arch = target_arch
arch = host_arch + '_' + target_arch if host_arch != target_arch else target_arch
- return '"%s" %s' % (script_path, arch)
+ return f'"{script_path}" {arch}'
# Otherwise try the VS2017 Developer Command Prompt.
if 'VS150COMNTOOLS' in os.environ and has_arch_values:
@@ -405,10 +405,10 @@ class Vs2010Backend(backends.Backend):
'preSolution\n')
for p in projlist:
if p[1].parent != PurePath('.'):
- ofile.write("\t\t{%s} = {%s}\n" % (p[2], self.subdirs[p[1].parent][0]))
+ ofile.write("\t\t{{{}}} = {{{}}}\n".format(p[2], self.subdirs[p[1].parent][0]))
for subdir in self.subdirs.values():
if subdir[1]:
- ofile.write("\t\t{%s} = {%s}\n" % (subdir[0], subdir[1]))
+ ofile.write("\t\t{{{}}} = {{{}}}\n".format(subdir[0], subdir[1]))
ofile.write('\tEndGlobalSection\n')
ofile.write('EndGlobal\n')
replace_if_different(sln_filename, sln_filename_tmp)
@@ -690,7 +690,7 @@ class Vs2010Backend(backends.Backend):
# kidding, this is how escaping works for process args on Windows.
if option.endswith('\\'):
option += '\\'
- return '"{}"'.format(option)
+ return f'"{option}"'
@staticmethod
def split_link_args(args):
diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py
index 7ee4e80..d87188e 100644
--- a/mesonbuild/backend/xcodebackend.py
+++ b/mesonbuild/backend/xcodebackend.py
@@ -118,7 +118,7 @@ class XCodeBackend(backends.Backend):
xcodetype = self.xcodetypemap.get(fname.split('.')[-1].lower())
if not xcodetype:
xcodetype = 'sourcecode.unknown'
- mlog.warning('Unknown file type "%s" fallbacking to "%s". Xcode project might be malformed.' % (fname, xcodetype))
+ mlog.warning(f'Unknown file type "{fname}" fallbacking to "{xcodetype}". Xcode project might be malformed.')
return xcodetype
def generate_filemap(self):
@@ -228,10 +228,10 @@ class XCodeBackend(backends.Backend):
buildconf_id = t[2]
build_phases = t[3]
dependencies = t[4]
- self.write_line('%s /* %s */ = {' % (t[0], name))
+ self.write_line('{} /* {} */ = {{'.format(t[0], name))
self.indent_level += 1
self.write_line('isa = PBXAggregateTarget;')
- self.write_line('buildConfigurationList = %s /* Build configuration list for PBXAggregateTarget "%s" */;' % (buildconf_id, name))
+ self.write_line(f'buildConfigurationList = {buildconf_id} /* Build configuration list for PBXAggregateTarget "{name}" */;')
self.write_line('buildPhases = (')
self.indent_level += 1
for bp in build_phases:
@@ -260,7 +260,7 @@ class XCodeBackend(backends.Backend):
for dep in t.get_external_deps():
if isinstance(dep, dependencies.AppleFrameworks):
for f in dep.frameworks:
- self.write_line('%s /* %s.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = %s /* %s.framework */; };\n' % (self.native_frameworks[f], f, self.native_frameworks_fileref[f], f))
+ self.write_line('{} /* {}.framework in Frameworks */ = {{isa = PBXBuildFile; fileRef = {} /* {}.framework */; }};\n'.format(self.native_frameworks[f], f, self.native_frameworks_fileref[f], f))
for s in t.sources:
if isinstance(s, mesonlib.File):
@@ -287,7 +287,7 @@ class XCodeBackend(backends.Backend):
# FIXME: Xcode 9 and later does not uses PBXBuildStyle and it gets removed. Maybe we can remove this part.
self.ofile.write('\n/* Begin PBXBuildStyle section */\n')
for name, idval in self.buildstylemap.items():
- self.write_line('%s /* %s */ = {\n' % (idval, name))
+ self.write_line(f'{idval} /* {name} */ = {{\n')
self.indent_level += 1
self.write_line('isa = PBXBuildStyle;\n')
self.write_line('buildSettings = {\n')
@@ -320,7 +320,7 @@ class XCodeBackend(backends.Backend):
for dep in t.get_external_deps():
if isinstance(dep, dependencies.AppleFrameworks):
for f in dep.frameworks:
- self.write_line('%s /* %s.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = %s.framework; path = System/Library/Frameworks/%s.framework; sourceTree = SDKROOT; };\n' % (self.native_frameworks_fileref[f], f, f, f))
+ self.write_line('{} /* {}.framework */ = {{isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = {}.framework; path = System/Library/Frameworks/{}.framework; sourceTree = SDKROOT; }};\n'.format(self.native_frameworks_fileref[f], f, f, f))
src_templ = '%s /* %s */ = { isa = PBXFileReference; explicitFileType = "%s"; fileEncoding = 4; name = "%s"; path = "%s"; sourceTree = SOURCE_ROOT; };\n'
for fname, idval in self.filemap.items():
fullpath = os.path.join(self.environment.get_source_dir(), fname)
@@ -348,7 +348,7 @@ class XCodeBackend(backends.Backend):
def generate_pbx_frameworks_buildphase(self):
for t in self.build.get_build_targets().values():
self.ofile.write('\n/* Begin PBXFrameworksBuildPhase section */\n')
- self.write_line('%s /* %s */ = {\n' % (t.buildphasemap['Frameworks'], 'Frameworks'))
+ self.write_line('{} /* {} */ = {{\n'.format(t.buildphasemap['Frameworks'], 'Frameworks'))
self.indent_level += 1
self.write_line('isa = PBXFrameworksBuildPhase;\n')
self.write_line('buildActionMask = %s;\n' % (2147483647))
@@ -357,7 +357,7 @@ class XCodeBackend(backends.Backend):
for dep in t.get_external_deps():
if isinstance(dep, dependencies.AppleFrameworks):
for f in dep.frameworks:
- self.write_line('%s /* %s.framework in Frameworks */,\n' % (self.native_frameworks[f], f))
+ self.write_line('{} /* {}.framework in Frameworks */,\n'.format(self.native_frameworks[f], f))
self.indent_level -= 1
self.write_line(');\n')
self.write_line('runOnlyForDeploymentPostprocessing = 0;\n')
@@ -398,7 +398,7 @@ class XCodeBackend(backends.Backend):
self.write_line('children = (')
self.indent_level += 1
for t in self.build.get_build_targets():
- self.write_line('%s /* %s */,' % (groupmap[t], t))
+ self.write_line('{} /* {} */,'.format(groupmap[t], t))
self.indent_level -= 1
self.write_line(');')
self.write_line('name = Sources;')
@@ -427,7 +427,7 @@ class XCodeBackend(backends.Backend):
for dep in t.get_external_deps():
if isinstance(dep, dependencies.AppleFrameworks):
for f in dep.frameworks:
- self.write_line('%s /* %s.framework */,\n' % (self.native_frameworks_fileref[f], f))
+ self.write_line('{} /* {}.framework */,\n'.format(self.native_frameworks_fileref[f], f))
self.indent_level -= 1
self.write_line(');')
@@ -438,7 +438,7 @@ class XCodeBackend(backends.Backend):
# Targets
for t in self.build.get_build_targets():
- self.write_line('%s /* %s */ = {' % (groupmap[t], t))
+ self.write_line('{} /* {} */ = {{'.format(groupmap[t], t))
self.indent_level += 1
self.write_line('isa = PBXGroup;')
self.write_line('children = (')
@@ -458,10 +458,10 @@ class XCodeBackend(backends.Backend):
for s in self.build.get_build_targets()[t].sources:
s = os.path.join(s.subdir, s.fname)
if isinstance(s, str):
- self.write_line('%s /* %s */,' % (self.filemap[s], s))
+ self.write_line('{} /* {} */,'.format(self.filemap[s], s))
for o in self.build.get_build_targets()[t].objects:
o = os.path.join(self.build.get_build_targets()[t].subdir, o)
- self.write_line('%s /* %s */,' % (self.filemap[o], o))
+ self.write_line('{} /* {} */,'.format(self.filemap[o], o))
self.indent_level -= 1
self.write_line(');')
self.write_line('name = "Source files";')
@@ -476,7 +476,7 @@ class XCodeBackend(backends.Backend):
self.write_line('children = (')
self.indent_level += 1
for t in self.build.get_build_targets():
- self.write_line('%s /* %s */,' % (self.target_filemap[t], t))
+ self.write_line('{} /* {} */,'.format(self.target_filemap[t], t))
self.indent_level -= 1
self.write_line(');')
self.write_line('name = Products;')
@@ -489,7 +489,7 @@ class XCodeBackend(backends.Backend):
self.ofile.write('\n/* Begin PBXNativeTarget section */\n')
for tname, idval in self.native_targets.items():
t = self.build.get_build_targets()[tname]
- self.write_line('%s /* %s */ = {' % (idval, tname))
+ self.write_line(f'{idval} /* {tname} */ = {{')
self.indent_level += 1
self.write_line('isa = PBXNativeTarget;')
self.write_line('buildConfigurationList = %s /* Build configuration list for PBXNativeTarget "%s" */;'
@@ -497,7 +497,7 @@ class XCodeBackend(backends.Backend):
self.write_line('buildPhases = (')
self.indent_level += 1
for bpname, bpval in t.buildphasemap.items():
- self.write_line('%s /* %s yyy */,' % (bpval, bpname))
+ self.write_line(f'{bpval} /* {bpname} yyy */,')
self.indent_level -= 1
self.write_line(');')
self.write_line('buildRules = (')
@@ -513,7 +513,7 @@ class XCodeBackend(backends.Backend):
self.write_line(");")
self.write_line('name = "%s";' % tname)
self.write_line('productName = "%s";' % tname)
- self.write_line('productReference = %s /* %s */;' % (self.target_filemap[tname], tname))
+ self.write_line('productReference = {} /* {} */;'.format(self.target_filemap[tname], tname))
if isinstance(t, build.Executable):
typestr = 'com.apple.product-type.tool'
elif isinstance(t, build.StaticLibrary):
@@ -544,7 +544,7 @@ class XCodeBackend(backends.Backend):
self.write_line('buildStyles = (')
self.indent_level += 1
for name, idval in self.buildstylemap.items():
- self.write_line('%s /* %s */,' % (idval, name))
+ self.write_line(f'{idval} /* {name} */,')
self.indent_level -= 1
self.write_line(');')
self.write_line('compatibilityVersion = "Xcode 3.2";')
@@ -557,7 +557,7 @@ class XCodeBackend(backends.Backend):
self.write_line('%s /* ALL_BUILD */,' % self.all_id)
self.write_line('%s /* RUN_TESTS */,' % self.test_id)
for t in self.build.get_build_targets():
- self.write_line('%s /* %s */,' % (self.native_targets[t], t))
+ self.write_line('{} /* {} */,'.format(self.native_targets[t], t))
self.indent_level -= 1
self.write_line(');')
self.indent_level -= 1
@@ -599,7 +599,7 @@ class XCodeBackend(backends.Backend):
for s in self.build.get_build_targets()[name].sources:
s = os.path.join(s.subdir, s.fname)
if not self.environment.is_header(s):
- self.write_line('%s /* %s */,' % (self.buildmap[s], os.path.join(self.environment.get_source_dir(), s)))
+ self.write_line('{} /* {} */,'.format(self.buildmap[s], os.path.join(self.environment.get_source_dir(), s)))
self.indent_level -= 1
self.write_line(');')
self.write_line('runOnlyForDeploymentPostprocessing = 0;')
@@ -620,7 +620,7 @@ class XCodeBackend(backends.Backend):
self.write_line('%s /* PBXTargetDependency */ = {' % t[0])
self.indent_level += 1
self.write_line('isa = PBXTargetDependency;')
- self.write_line('target = %s /* %s */;' % (t[1], t[2]))
+ self.write_line('target = {} /* {} */;'.format(t[1], t[2]))
self.write_line('targetProxy = %s /* PBXContainerItemProxy */;' % t[3])
self.indent_level -= 1
self.write_line('};')
@@ -630,7 +630,7 @@ class XCodeBackend(backends.Backend):
self.ofile.write('\n/* Begin XCBuildConfiguration section */\n')
# First the setup for the toplevel project.
for buildtype in self.buildtypes:
- self.write_line('%s /* %s */ = {' % (self.project_configurations[buildtype], buildtype))
+ self.write_line('{} /* {} */ = {{'.format(self.project_configurations[buildtype], buildtype))
self.indent_level += 1
self.write_line('isa = XCBuildConfiguration;')
self.write_line('buildSettings = {')
@@ -647,7 +647,7 @@ class XCodeBackend(backends.Backend):
# Then the all target.
for buildtype in self.buildtypes:
- self.write_line('%s /* %s */ = {' % (self.buildall_configurations[buildtype], buildtype))
+ self.write_line('{} /* {} */ = {{'.format(self.buildall_configurations[buildtype], buildtype))
self.indent_level += 1
self.write_line('isa = XCBuildConfiguration;')
self.write_line('buildSettings = {')
@@ -675,7 +675,7 @@ class XCodeBackend(backends.Backend):
# Then the test target.
for buildtype in self.buildtypes:
- self.write_line('%s /* %s */ = {' % (self.test_configurations[buildtype], buildtype))
+ self.write_line('{} /* {} */ = {{'.format(self.test_configurations[buildtype], buildtype))
self.indent_level += 1
self.write_line('isa = XCBuildConfiguration;')
self.write_line('buildSettings = {')
@@ -763,7 +763,7 @@ class XCodeBackend(backends.Backend):
langargs[langname] = args
langargs[langname] += lang_cargs
symroot = os.path.join(self.environment.get_build_dir(), target.subdir)
- self.write_line('%s /* %s */ = {' % (valid, buildtype))
+ self.write_line(f'{valid} /* {buildtype} */ = {{')
self.indent_level += 1
self.write_line('isa = XCBuildConfiguration;')
self.write_line('buildSettings = {')
@@ -789,7 +789,7 @@ class XCodeBackend(backends.Backend):
pchs = [pch for pch in pchs if pch.endswith('.h') or pch.endswith('.hh') or pch.endswith('hpp')]
if pchs:
if len(pchs) > 1:
- mlog.warning('Unsupported Xcode configuration: More than 1 precompiled header found "%s". Target "%s" might not compile correctly.' % (str(pchs), target.name))
+ mlog.warning('Unsupported Xcode configuration: More than 1 precompiled header found "{}". Target "{}" might not compile correctly.'.format(str(pchs), target.name))
relative_pch_path = os.path.join(target.get_subdir(), pchs[0]) # Path relative to target so it can be used with "$(PROJECT_DIR)"
self.write_line('GCC_PRECOMPILE_PREFIX_HEADER = YES;')
self.write_line('GCC_PREFIX_HEADER = "$(PROJECT_DIR)/%s";' % relative_pch_path)
@@ -822,13 +822,13 @@ class XCodeBackend(backends.Backend):
def generate_xc_configurationList(self):
# FIXME: sort items
self.ofile.write('\n/* Begin XCConfigurationList section */\n')
- self.write_line('%s /* Build configuration list for PBXProject "%s" */ = {' % (self.project_conflist, self.build.project_name))
+ self.write_line(f'{self.project_conflist} /* Build configuration list for PBXProject "{self.build.project_name}" */ = {{')
self.indent_level += 1
self.write_line('isa = XCConfigurationList;')
self.write_line('buildConfigurations = (')
self.indent_level += 1
for buildtype in self.buildtypes:
- self.write_line('%s /* %s */,' % (self.project_configurations[buildtype], buildtype))
+ self.write_line('{} /* {} */,'.format(self.project_configurations[buildtype], buildtype))
self.indent_level -= 1
self.write_line(');')
self.write_line('defaultConfigurationIsVisible = 0;')
@@ -843,7 +843,7 @@ class XCodeBackend(backends.Backend):
self.write_line('buildConfigurations = (')
self.indent_level += 1
for buildtype in self.buildtypes:
- self.write_line('%s /* %s */,' % (self.buildall_configurations[buildtype], buildtype))
+ self.write_line('{} /* {} */,'.format(self.buildall_configurations[buildtype], buildtype))
self.indent_level -= 1
self.write_line(');')
self.write_line('defaultConfigurationIsVisible = 0;')
@@ -858,7 +858,7 @@ class XCodeBackend(backends.Backend):
self.write_line('buildConfigurations = (')
self.indent_level += 1
for buildtype in self.buildtypes:
- self.write_line('%s /* %s */,' % (self.test_configurations[buildtype], buildtype))
+ self.write_line('{} /* {} */,'.format(self.test_configurations[buildtype], buildtype))
self.indent_level -= 1
self.write_line(');')
self.write_line('defaultConfigurationIsVisible = 0;')
@@ -868,14 +868,14 @@ class XCodeBackend(backends.Backend):
for target_name in self.build.get_build_targets():
listid = self.buildconflistmap[target_name]
- self.write_line('%s /* Build configuration list for PBXNativeTarget "%s" */ = {' % (listid, target_name))
+ self.write_line(f'{listid} /* Build configuration list for PBXNativeTarget "{target_name}" */ = {{')
self.indent_level += 1
self.write_line('isa = XCConfigurationList;')
self.write_line('buildConfigurations = (')
self.indent_level += 1
typestr = 'debug'
idval = self.buildconfmap[target_name][typestr]
- self.write_line('%s /* %s */,' % (idval, typestr))
+ self.write_line(f'{idval} /* {typestr} */,')
self.indent_level -= 1
self.write_line(');')
self.write_line('defaultConfigurationIsVisible = 0;')
@@ -890,9 +890,9 @@ class XCodeBackend(backends.Backend):
value = flag_values[0]
if (' ' in value):
# If path contains spaces surround it with double colon
- self.write_line('%s = "\\"%s\\"";' % (flag_name, value))
+ self.write_line(f'{flag_name} = "\\"{value}\\"";')
else:
- self.write_line('%s = "%s";' % (flag_name, value))
+ self.write_line(f'{flag_name} = "{value}";')
else:
self.write_line('%s = (' % flag_name)
self.indent_level += 1