diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2020-09-17 09:59:29 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2020-09-24 12:14:13 -0700 |
commit | d326c87fe22507b8c25078a7cd7ed88499ba7dc1 (patch) | |
tree | b58f159c6a1eee67c906bf38026649c64ce09b8f /mesonbuild/compilers/mixins | |
parent | 8fa0548e080dd006821ff985868fdef789935feb (diff) | |
download | meson-d326c87fe22507b8c25078a7cd7ed88499ba7dc1.zip meson-d326c87fe22507b8c25078a7cd7ed88499ba7dc1.tar.gz meson-d326c87fe22507b8c25078a7cd7ed88499ba7dc1.tar.bz2 |
compilers: Use a distinct type for compile/link results
Currently we do some crazy hackery where we add extra properties to a
Popen object and return that. That's crazy. Especially since some of our
hackery is to delete attributes off of the Popen we don't want. Instead,
let's just have a discrete type that has exactly the properties we want.
Diffstat (limited to 'mesonbuild/compilers/mixins')
-rw-r--r-- | mesonbuild/compilers/mixins/clike.py | 6 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/gnu.py | 7 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/visualstudio.py | 2 |
3 files changed, 7 insertions, 8 deletions
diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index b2942d3..6a069b6 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -446,7 +446,7 @@ class CLikeCompiler: with self._build_wrapper(code, env, extra_args, dependencies, mode, disable_cache=disable_cache) as p: return p.returncode == 0, p.cached - def _build_wrapper(self, code: str, env, extra_args, dependencies=None, mode: str = 'compile', want_output: bool = False, disable_cache: bool = False, temp_dir: str = None) -> T.Tuple[bool, bool]: + def _build_wrapper(self, code: str, env, extra_args, dependencies=None, mode: str = 'compile', want_output: bool = False, disable_cache: bool = False, temp_dir: str = None) -> T.Iterator[compilers.CompileResult]: args = self._get_compiler_check_args(env, extra_args, dependencies, mode) if disable_cache or want_output: return self.compile(code, extra_args=args, mode=mode, want_output=want_output, temp_dir=env.scratch_dir) @@ -665,7 +665,7 @@ class CLikeCompiler: # Get the preprocessed value after the delimiter, # minus the extra newline at the end and # merge string literals. - return self.concatenate_string_literals(p.stdo.split(delim + '\n')[-1][:-1]), cached + return self.concatenate_string_literals(p.stdout.split(delim + '\n')[-1][:-1]), cached def get_return_value(self, fname, rtype, prefix, env, extra_args, dependencies): if rtype == 'string': @@ -889,7 +889,7 @@ class CLikeCompiler: with self._build_wrapper(code, env, extra_args=args, mode='compile', want_output=True, temp_dir=env.scratch_dir) as p: if p.returncode != 0: m = 'BUG: Unable to compile {!r} check: {}' - raise RuntimeError(m.format(n, p.stdo)) + raise RuntimeError(m.format(n, p.stdout)) if not os.path.isfile(p.output_name): m = 'BUG: Can\'t find compiled test code for {!r} check' raise RuntimeError(m.format(n)) diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py index 83f7047..538cc03 100644 --- a/mesonbuild/compilers/mixins/gnu.py +++ b/mesonbuild/compilers/mixins/gnu.py @@ -227,8 +227,7 @@ class GnuLikeCompiler(metaclass=abc.ABCMeta): with self._build_wrapper('', env, extra_args=extra_args, dependencies=None, mode='compile', want_output=True) as p: - stdo = p.stdo - return stdo + return p.stdout def _split_fetch_real_dirs(self, pathstr: str) -> T.List[str]: # We need to use the path separator used by the compiler for printing @@ -364,9 +363,9 @@ class GnuCompiler(GnuLikeCompiler): # another language, but still complete with exit_success with self._build_wrapper(code, env, args, None, mode) as p: result = p.returncode == 0 - if self.language in {'cpp', 'objcpp'} and 'is valid for C/ObjC' in p.stde: + if self.language in {'cpp', 'objcpp'} and 'is valid for C/ObjC' in p.stderr: result = False - if self.language in {'c', 'objc'} and 'is valid for C++/ObjC++' in p.stde: + if self.language in {'c', 'objc'} and 'is valid for C++/ObjC++' in p.stderr: result = False return result, p.cached diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py index 0ea03f0..74229e3 100644 --- a/mesonbuild/compilers/mixins/visualstudio.py +++ b/mesonbuild/compilers/mixins/visualstudio.py @@ -296,7 +296,7 @@ class VisualStudioLikeCompiler(metaclass=abc.ABCMeta): with self._build_wrapper(code, env, extra_args=args, mode=mode) as p: if p.returncode != 0: return False, p.cached - return not(warning_text in p.stde or warning_text in p.stdo), p.cached + return not(warning_text in p.stderr or warning_text in p.stdout), p.cached def get_compile_debugfile_args(self, rel_obj: str, pch: bool = False) -> T.List[str]: pdbarr = rel_obj.split('.')[:-1] |