From cb70a20490eb1ca9a201bb2de652726d6bb28725 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 7 May 2019 13:44:12 -0700 Subject: [PATCH] compilers: make keyword args to Compiler.compile keyword only Becuase treating args as either keyword or positional makes inheritance really awful to work with. --- mesonbuild/compilers/clike.py | 2 +- mesonbuild/compilers/compilers.py | 4 ++-- mesonbuild/compilers/cpp.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mesonbuild/compilers/clike.py b/mesonbuild/compilers/clike.py index e9d5d1dde..f62aa2a0e 100644 --- a/mesonbuild/compilers/clike.py +++ b/mesonbuild/compilers/clike.py @@ -849,7 +849,7 @@ class CLikeCompiler: ''' args = self.get_compiler_check_args() n = 'symbols_have_underscore_prefix' - with self.compile(code, args, 'compile', want_output=True) as p: + with self.compile(code, extra_args=args, mode='compile', want_output=True) as p: if p.returncode != 0: m = 'BUG: Unable to compile {!r} check: {}' raise RuntimeError(m.format(n, p.stdo)) diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index a3401e8ac..ff443b34b 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -1146,7 +1146,7 @@ class Compiler: return os.path.join(dirname, 'output.' + suffix) @contextlib.contextmanager - def compile(self, code, extra_args=None, mode='link', want_output=False): + def compile(self, code, extra_args=None, *, mode='link', want_output=False): if extra_args is None: extra_args = [] try: @@ -1199,7 +1199,7 @@ class Compiler: pass @contextlib.contextmanager - def cached_compile(self, code, cdata: coredata.CoreData, extra_args=None, mode: str = 'link'): + def cached_compile(self, code, cdata: coredata.CoreData, *, extra_args=None, mode: str = 'link'): assert(isinstance(cdata, coredata.CoreData)) # Calculate the key diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index 12644a2e2..5b5bb1cd9 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -97,7 +97,7 @@ class CPPCompiler(CLikeCompiler, Compiler): # 2. even if it did have an env object, that might contain another more # recent -std= argument, which might lead to a cascaded failure. CPP_TEST = 'int i = static_cast(0);' - with self.compile(code=CPP_TEST, extra_args=[cpp_std_value], mode='compile') as p: + with self.compile(CPP_TEST, extra_args=[cpp_std_value], mode='compile') as p: if p.returncode == 0: mlog.debug('Compiler accepts {}:'.format(cpp_std_value), 'YES') return True