diff options
Diffstat (limited to 'mesonbuild/compilers/swift.py')
-rw-r--r-- | mesonbuild/compilers/swift.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/mesonbuild/compilers/swift.py b/mesonbuild/compilers/swift.py index 8410fbb..47d254b 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, options -from ..mesonlib import EnvironmentException, MesonException, version_compare +from ..mesonlib import first, MesonException, version_compare from .compilers import Compiler, clike_debug_args @@ -139,6 +139,12 @@ class SwiftCompiler(Compiler): if std != 'none': args += ['-swift-version', std] + # Pass C compiler -std=... arg to swiftc + c_lang = first(['objc', 'c'], lambda x: x in target.compilers) + if c_lang is not None: + cc = target.compilers[c_lang] + args.extend(arg for c_arg in cc.get_option_std_args(target, env, subproject) for arg in ['-Xcc', c_arg]) + return args def get_working_directory_args(self, path: str) -> T.Optional[T.List[str]]: @@ -147,6 +153,12 @@ class SwiftCompiler(Compiler): return ['-working-directory', path] + def get_cxx_interoperability_args(self, lang: T.Dict[str, Compiler]) -> T.List[str]: + if 'cpp' in lang or 'objcpp' in lang: + return ['-cxx-interoperability-mode=default'] + else: + return ['-cxx-interoperability-mode=off'] + 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): @@ -170,13 +182,7 @@ class SwiftCompiler(Compiler): ''') pc = subprocess.Popen(self.exelist + extra_flags + ['-emit-executable', '-o', output_name, src], cwd=work_dir) pc.wait() - if pc.returncode != 0: - raise EnvironmentException('Swift compiler %s cannot compile programs.' % self.name_string()) - if self.is_cross: - # Can't check if the binaries run so we have to assume they do - return - if subprocess.call(output_name) != 0: - raise EnvironmentException('Executables created by Swift compiler %s are not runnable.' % self.name_string()) + self.run_sanity_check(environment, [output_name], work_dir) def get_debug_args(self, is_debug: bool) -> T.List[str]: return clike_debug_args[is_debug] |