From a19f3a4f9f5d67742d785434d306764aa2b836b0 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 22 Dec 2023 14:56:42 +0100 Subject: [PATCH] python/build/meson.py: put ccache prefix in array instead of stripping it Turns out Meson disables ccache auto-detection when a cross-file is used. To use ccache, the ccache prefix must be expressed in an array instead of a single string with spaces. --- python/build/meson.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/python/build/meson.py b/python/build/meson.py index c6795644c..264d9589a 100644 --- a/python/build/meson.py +++ b/python/build/meson.py @@ -4,10 +4,12 @@ import platform from .toolchain import AnyToolchain -def __no_ccache(cmd: str) -> str: - if cmd.startswith('ccache '): - cmd = cmd[7:] - return cmd +def format_meson_cross_file_command(command: str) -> str: + splitted = command.split() + if len(splitted) == 1: + return repr(command) + + return repr(splitted) def make_cross_file(toolchain: AnyToolchain) -> str: if toolchain.is_windows: @@ -43,15 +45,15 @@ def make_cross_file(toolchain: AnyToolchain) -> str: with open(path, 'w') as f: f.write(f""" [binaries] -c = '{__no_ccache(toolchain.cc)}' -cpp = '{__no_ccache(toolchain.cxx)}' -ar = '{toolchain.ar}' -strip = '{toolchain.strip}' -pkgconfig = '{toolchain.pkg_config}' +c = {format_meson_cross_file_command(toolchain.cc)} +cpp = {format_meson_cross_file_command(toolchain.cxx)} +ar = {format_meson_cross_file_command(toolchain.ar)} +strip = {format_meson_cross_file_command(toolchain.strip)} +pkgconfig = {format_meson_cross_file_command(toolchain.pkg_config)} """) if toolchain.is_windows and platform.system() != 'Windows': - f.write(f"windres = '{toolchain.windres}'\n") + f.write(f"windres = {format_meson_cross_file_command(toolchain.windres)}\n") # Run unit tests with WINE when cross-building for Windows print("exe_wrapper = 'wine'", file=f)