diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2020-06-11 12:44:53 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2020-06-22 12:06:10 -0700 |
commit | 93c3ec7e2dd6d425baff5fd80e5a46c88d152cb0 (patch) | |
tree | d5913f089b2a69de191e5c67b1e8dc8010742b6d /mesonbuild/compilers/compilers.py | |
parent | 9d0ad66c29fccd2ff72c2b40da02cdb2b03ccba6 (diff) | |
download | meson-93c3ec7e2dd6d425baff5fd80e5a46c88d152cb0.zip meson-93c3ec7e2dd6d425baff5fd80e5a46c88d152cb0.tar.gz meson-93c3ec7e2dd6d425baff5fd80e5a46c88d152cb0.tar.bz2 |
compilers: Return CompilerArgs from compiler instance
Since the CompileArgs class already needs to know about the compiler,
and we really need at least per-lanaguage if not per-compiler
CompilerArgs classes, let's get the CompilerArgs instance from the
compiler using a method.
Diffstat (limited to 'mesonbuild/compilers/compilers.py')
-rw-r--r-- | mesonbuild/compilers/compilers.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index bf66982..8ecb972 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import abc import contextlib, os.path, re, tempfile import itertools import typing as T @@ -401,7 +402,7 @@ class RunResult: self.stderr = stderr -class Compiler: +class Compiler(metaclass=abc.ABCMeta): # Libraries to ignore in find_library() since they are provided by the # compiler or the C library. Currently only used for MSVC. ignore_libs = () @@ -624,6 +625,10 @@ class Compiler: args += self.get_preprocess_only_args() return args + def compiler_args(self, args: T.Optional[T.Iterable[str]] = None) -> CompilerArgs: + """Return an appropriate CompilerArgs instance for this class.""" + return CompilerArgs(self, args) + @contextlib.contextmanager def compile(self, code: str, extra_args: list = None, *, mode: str = 'link', want_output: bool = False, temp_dir: str = None): if extra_args is None: @@ -642,7 +647,7 @@ class Compiler: srcname = code.fname # Construct the compiler command-line - commands = CompilerArgs(self) + commands = self.compiler_args() commands.append(srcname) # Preprocess mode outputs to stdout, so no output args if mode != 'preprocess': |