diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2015-12-07 21:12:23 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2015-12-07 21:12:23 +0200 |
commit | d92504797f50ea3a4abcd8f8d0ee1d903abca8af (patch) | |
tree | 51a5bff7e4dd3806554ea51cbda0e43788379815 /environment.py | |
parent | d5bdfb5906563f031c17cfa9564a03ed475053b9 (diff) | |
download | meson-d92504797f50ea3a4abcd8f8d0ee1d903abca8af.zip meson-d92504797f50ea3a4abcd8f8d0ee1d903abca8af.tar.gz meson-d92504797f50ea3a4abcd8f8d0ee1d903abca8af.tar.bz2 |
Can build simple Swift executables.
Diffstat (limited to 'environment.py')
-rw-r--r-- | environment.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/environment.py b/environment.py index c92eb87..308a21c 100644 --- a/environment.py +++ b/environment.py @@ -19,6 +19,10 @@ import configparser build_filename = 'meson.build' +class EnvironmentException(coredata.MesonException): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + def find_coverage_tools(): gcovr_exe = 'gcovr' lcov_exe = 'lcov' @@ -457,6 +461,23 @@ class Environment(): return RustCompiler(exelist, version) raise EnvironmentException('Unknown compiler "' + ' '.join(exelist) + '"') + def detect_swift_compiler(self): + exelist = ['swiftc'] + try: + p = subprocess.Popen(exelist + ['-v'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + except OSError: + raise EnvironmentException('Could not execute Swift compiler "%s"' % ' '.join(exelist)) + (_, err) = p.communicate() + err = err.decode() + vmatch = re.search(Environment.version_regex, err) + if vmatch: + version = vmatch.group(0) + else: + version = 'unknown version' + if 'Swift' in err: + return SwiftCompiler(exelist, version) + raise EnvironmentException('Unknown compiler "' + ' '.join(exelist) + '"') + def detect_static_linker(self, compiler): if compiler.is_cross: linker = self.cross_info.config['binaries']['ar'] |