summaryrefslogtreecommitdiff
path: root/mesonbuild/backend
diff options
context:
space:
mode:
authorMarco Rebhan <me@dblsaiko.net>2025-02-11 03:10:29 +0100
committerDylan Baker <dylan@pnwbakers.com>2025-02-11 09:58:38 -0800
commite42cd6aff6fcbf5556261d874e731613d9345378 (patch)
tree1d08a31217d6d44670663640a76b5155d8f89161 /mesonbuild/backend
parentdf9b0757e2f0628507455e205d7f219d05d2fdd6 (diff)
downloadmeson-e42cd6aff6fcbf5556261d874e731613d9345378.tar.gz
ninja backend: Use swiftc flag -working-directory if available
This makes SourceKit-LSP work using a meson-generated compile_commands.json.
Diffstat (limited to 'mesonbuild/backend')
-rw-r--r--mesonbuild/backend/ninjabackend.py18
1 files changed, 12 insertions, 6 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))