diff options
| author | Jouke Witteveen <j.witteveen@gmail.com> | 2024-02-03 17:24:58 +0100 |
|---|---|---|
| committer | Eli Schwartz <eschwartz93@gmail.com> | 2024-02-10 20:04:18 -0500 |
| commit | 10e269271d9fb6cbb69afa91bcf0cfc03e214bca (patch) | |
| tree | 1a5ba05fe976b2290bd4b37d32c3d23a75cdac15 /mesonbuild/backend/backends.py | |
| parent | 3c7bc8cac3737796ef2ee1ce0ba6dd601f5f080b (diff) | |
| download | meson-10e269271d9fb6cbb69afa91bcf0cfc03e214bca.tar.gz | |
backends: restore shlex quoting of MESONINTROSPECT
The type of quoting was changed in 522392e to one that is suitable for
use with cmd.exe on Windows. However, the documentation states that the
type of quoting in MESONINTROSPECT is compatible with shlex.split() and
elsewhere in the code, the same variable is still quoted with
shlex.quote(). As mostly identified in #12148, there are a few choices:
1. Use shlex.quote() consistently and support Python but not cmd.exe.
2. Use join_args and support cmd.exe but not Python.
3. Use join_args and support splitting through the mesonbuild Python library.
This commit implements the first option and reverts part of 522392e.
Regression testing is implemented in #12115.
Fixes #12148
Diffstat (limited to 'mesonbuild/backend/backends.py')
| -rw-r--r-- | mesonbuild/backend/backends.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 5b9479915..01ec422f4 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -14,6 +14,7 @@ import json import os import pickle import re +import shlex import shutil import typing as T import hashlib @@ -26,8 +27,7 @@ from .. import mlog from ..compilers import LANGUAGES_USING_LDFLAGS, detect from ..mesonlib import ( File, MachineChoice, MesonException, OrderedSet, - classify_unity_sources, OptionKey, join_args, - ExecutableSerialisation + ExecutableSerialisation, classify_unity_sources, OptionKey ) if T.TYPE_CHECKING: @@ -1598,22 +1598,23 @@ class Backend: cmd = [i.replace('\\', '/') for i in cmd] return inputs, outputs, cmd + def get_introspect_command(self) -> str: + return ' '.join(shlex.quote(x) for x in self.environment.get_build_command() + ['introspect']) + def get_run_target_env(self, target: build.RunTarget) -> mesonlib.EnvironmentVariables: env = target.env if target.env else mesonlib.EnvironmentVariables() if target.default_env: - introspect_cmd = join_args(self.environment.get_build_command() + ['introspect']) env.set('MESON_SOURCE_ROOT', [self.environment.get_source_dir()]) env.set('MESON_BUILD_ROOT', [self.environment.get_build_dir()]) env.set('MESON_SUBDIR', [target.subdir]) - env.set('MESONINTROSPECT', [introspect_cmd]) + env.set('MESONINTROSPECT', [self.get_introspect_command()]) return env def run_postconf_scripts(self) -> None: from ..scripts.meson_exe import run_exe - introspect_cmd = join_args(self.environment.get_build_command() + ['introspect']) env = {'MESON_SOURCE_ROOT': self.environment.get_source_dir(), 'MESON_BUILD_ROOT': self.environment.get_build_dir(), - 'MESONINTROSPECT': introspect_cmd, + 'MESONINTROSPECT': self.get_introspect_command(), } for s in self.build.postconf_scripts: |
