python/meson: split the f.write() call and use f-strings

This commit is contained in:
Max Kellermann 2021-08-10 14:34:17 +02:00
parent bd9e449b69
commit b8eb9b466a

View File

@ -34,41 +34,37 @@ def make_cross_file(toolchain):
path = os.path.join(toolchain.build_path, 'meson.cross') path = os.path.join(toolchain.build_path, 'meson.cross')
os.makedirs(toolchain.build_path, exist_ok=True) os.makedirs(toolchain.build_path, exist_ok=True)
with open(path, 'w') as f: with open(path, 'w') as f:
f.write(""" f.write(f"""
[binaries] [binaries]
c = '%s' c = '{toolchain.cc}'
cpp = '%s' cpp = '{toolchain.cxx}'
ar = '%s' ar = '{toolchain.ar}'
strip = '%s' strip = '{toolchain.strip}'
pkgconfig = '%s' pkgconfig = '{toolchain.pkg_config}'
%s """)
if toolchain.is_windows:
f.write(f"windres = '{toolchain.windres}'\n")
f.write(f"""
[properties] [properties]
root = '%s' root = '{toolchain.install_prefix}'
c_args = %s c_args = {repr((toolchain.cppflags + ' ' + toolchain.cflags).split())}
c_link_args = %s c_link_args = {repr(toolchain.ldflags.split() + toolchain.libs.split())}
cpp_args = %s cpp_args = {repr((toolchain.cppflags + ' ' + toolchain.cxxflags).split())}
cpp_link_args = %s cpp_link_args = {repr(toolchain.ldflags.split() + toolchain.libs.split())}
# Keep Meson from executing Android-x86 test binariees # Keep Meson from executing Android-x86 test binariees
needs_exe_wrapper = true needs_exe_wrapper = true
[host_machine] [host_machine]
system = '%s' system = '{system}'
cpu_family = '%s' cpu_family = '{cpu_family}'
cpu = '%s' cpu = '{cpu}'
endian = '%s' endian = '{endian}'
""" % (toolchain.cc, toolchain.cxx, toolchain.ar, toolchain.strip, """)
toolchain.pkg_config,
windres,
toolchain.install_prefix,
repr((toolchain.cppflags + ' ' + toolchain.cflags).split()),
repr(toolchain.ldflags.split() + toolchain.libs.split()),
repr((toolchain.cppflags + ' ' + toolchain.cxxflags).split()),
repr(toolchain.ldflags.split() + toolchain.libs.split()),
system, cpu_family, cpu, endian))
return path return path
def configure(toolchain, src, build, args=()): def configure(toolchain, src, build, args=()):