diff options
| -rw-r--r-- | mesonbuild/backend/ninjabackend.py | 18 | ||||
| -rw-r--r-- | mesonbuild/compilers/swift.py | 8 |
2 files changed, 19 insertions, 7 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 24758866c..7b0e1dc83 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2434,12 +2434,18 @@ class NinjaBackend(backends.Backend): def generate_swift_compile_rules(self, compiler) -> None: rule = self.compiler_to_rule_name(compiler) - full_exe = self.environment.get_build_command() + [ - '--internal', - 'dirchanger', - '$RUNDIR', - ] - invoc = full_exe + compiler.get_exelist() + wd_args = compiler.get_working_directory_args('$RUNDIR') + + if wd_args is not None: + invoc = compiler.get_exelist() + ['-working-directory', '$RUNDIR'] + else: + full_exe = self.environment.get_build_command() + [ + '--internal', + 'dirchanger', + '$RUNDIR', + ] + invoc = full_exe + compiler.get_exelist() + command = invoc + ['$ARGS', '$in'] description = 'Compiling Swift source $in' self.add_rule(NinjaRule(rule, command, [], description)) diff --git a/mesonbuild/compilers/swift.py b/mesonbuild/compilers/swift.py index d92688231..91c17f0ba 100644 --- a/mesonbuild/compilers/swift.py +++ b/mesonbuild/compilers/swift.py @@ -8,7 +8,7 @@ import subprocess, os.path import typing as T from .. import mlog -from ..mesonlib import EnvironmentException, MesonException +from ..mesonlib import EnvironmentException, MesonException, version_compare from .compilers import Compiler, clike_debug_args @@ -115,6 +115,12 @@ class SwiftCompiler(Compiler): def get_compile_only_args(self) -> T.List[str]: return ['-c'] + def get_working_directory_args(self, path: str) -> T.Optional[T.List[str]]: + if version_compare(self.version, '<4.2'): + return None + + return ['-working-directory', path] + def compute_parameters_with_absolute_paths(self, parameter_list: T.List[str], build_dir: str) -> T.List[str]: for idx, i in enumerate(parameter_list): |
