From 4df758c9049d9616fd517c94228b56a143368610 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Mon, 6 Nov 2023 08:07:07 -0500 Subject: [PATCH] compilers: Allow setting workdir for run checks This is not exposed in API, but will be used internally. --- mesonbuild/compilers/compilers.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 19b484b16a4b..bf0bf3a9c83f 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -717,7 +717,8 @@ def has_header_symbol(self, hname: str, symbol: str, prefix: str, def run(self, code: 'mesonlib.FileOrString', env: 'Environment', *, extra_args: T.Union[T.List[str], T.Callable[[CompileCheckMode], T.List[str]], None] = None, - dependencies: T.Optional[T.List['Dependency']] = None) -> RunResult: + dependencies: T.Optional[T.List['Dependency']] = None, + run_cwd: T.Optional[str] = None) -> RunResult: need_exe_wrapper = env.need_exe_wrapper(self.for_machine) if need_exe_wrapper and self.exe_wrapper is None: raise CrossNoRunException('Can not run test applications in this cross environment.') @@ -730,7 +731,7 @@ def run(self, code: 'mesonlib.FileOrString', env: 'Environment', *, else: cmdlist = [p.output_name] try: - pe, so, se = mesonlib.Popen_safe(cmdlist) + pe, so, se = mesonlib.Popen_safe(cmdlist, cwd=run_cwd) except Exception as e: mlog.debug(f'Could not run: {cmdlist} (error: {e})\n') return RunResult(False)