From 6ae4fb8d9d22275f807dcee9cd38e8b70155d12d Mon Sep 17 00:00:00 2001 From: byteblob42 <154359796+byteblob42@users.noreply.github.com> Date: Wed, 20 Dec 2023 17:56:38 +0100 Subject: [PATCH] ninja: Use platform dependent quote instead of shlex.quote() in gcc_rsp_quote() --- mesonbuild/backend/ninjabackend.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index b4a312bb2e07..16893cada6ac 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -67,16 +67,6 @@ def cmd_quote(arg: str) -> str: return arg -def gcc_rsp_quote(s: str) -> str: - # see: the function buildargv() in libiberty - # - # this differs from sh-quoting in that a backslash *always* escapes the - # following character, even inside single quotes. - - s = s.replace('\\', '\\\\') - - return shlex.quote(s) - # How ninja executes command lines differs between Unix and Windows # (see https://ninja-build.org/manual.html#ref_rule_command) if mesonlib.is_windows(): @@ -88,6 +78,15 @@ def gcc_rsp_quote(s: str) -> str: execute_wrapper = [] rmfile_prefix = ['rm', '-f', '{}', '&&'] +def gcc_rsp_quote(s: str) -> str: + # see: the function buildargv() in libiberty + # + # this differs from sh-quoting in that a backslash *always* escapes the + # following character, even inside single quotes. + + s = s.replace('\\', '\\\\') + + return quote_func(s) def get_rsp_threshold() -> int: '''Return a conservative estimate of the commandline size in bytes