diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2019-03-19 20:44:51 -0400 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2019-03-27 10:54:56 -0400 |
commit | f4da210f464446d92600456508439d2f926e6cea (patch) | |
tree | 453a9a73eebc21dc055e20fa3911c0093d265245 /mesonbuild/compilers/swift.py | |
parent | b565eff084faeea8a8952ec2c1fe40483705aaef (diff) | |
download | meson-f4da210f464446d92600456508439d2f926e6cea.zip meson-f4da210f464446d92600456508439d2f926e6cea.tar.gz meson-f4da210f464446d92600456508439d2f926e6cea.tar.bz2 |
Sanity check with external args
Previously cross, but not native, external args were used. Then in
d451a4bd97f827bb492fd0c0e357cb20b6056ed9 the cross special cases were
removed, so external args are never used.
This commit switches that so they are always used. Sanity checking works
just the same as compiler checks like has header / has library.
Diffstat (limited to 'mesonbuild/compilers/swift.py')
-rw-r--r-- | mesonbuild/compilers/swift.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/mesonbuild/compilers/swift.py b/mesonbuild/compilers/swift.py index 94e6736..17705ac 100644 --- a/mesonbuild/compilers/swift.py +++ b/mesonbuild/compilers/swift.py @@ -14,7 +14,7 @@ import subprocess, os.path -from ..mesonlib import EnvironmentException +from ..mesonlib import EnvironmentException, MachineChoice from .compilers import Compiler, swift_buildtype_args, clike_debug_args @@ -102,13 +102,25 @@ class SwiftCompiler(Compiler): src = 'swifttest.swift' source_name = os.path.join(work_dir, src) output_name = os.path.join(work_dir, 'swifttest') + if environment.is_cross_build() and not self.is_cross: + for_machine = MachineChoice.BUILD + else: + for_machine = MachineChoice.HOST + extra_flags = environment.coredata.get_external_args(for_machine, self.language) + if self.is_cross: + extra_flags += self.get_compile_only_args() + else: + extra_flags += environment.coredata.get_external_link_args(for_machine, self.language) with open(source_name, 'w') as ofile: ofile.write('''print("Swift compilation is working.") ''') - pc = subprocess.Popen(self.exelist + ['-emit-executable', '-o', output_name, src], cwd=work_dir) + 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 can not 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()) |