diff options
| author | Dylan Baker <dylan@pnwbakers.com> | 2025-10-31 11:15:01 -0700 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-11-19 10:48:48 -0800 |
| commit | 25af927a6e5ebd4c53b4e43ccab35ed89a7ee0d8 (patch) | |
| tree | c1ee0cc2ece86f3eb1c419e5393e80fb6ee2af2e | |
| parent | 3832a592db68e935e6653a503a26b41f5777ae2e (diff) | |
| download | meson-25af927a6e5ebd4c53b4e43ccab35ed89a7ee0d8.tar.gz | |
compilers: Remove Environment parameter from Compiler._build_wrapper
| -rw-r--r-- | mesonbuild/compilers/compilers.py | 14 | ||||
| -rw-r--r-- | mesonbuild/compilers/mixins/clike.py | 4 | ||||
| -rw-r--r-- | mesonbuild/compilers/mixins/gnu.py | 8 | ||||
| -rw-r--r-- | mesonbuild/compilers/mixins/visualstudio.py | 2 | ||||
| -rw-r--r-- | mesonbuild/compilers/vala.py | 2 |
5 files changed, 15 insertions, 15 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 5862e82a8..4fb36feb3 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -686,7 +686,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): need_exe_wrapper = env.need_exe_wrapper(self.for_machine) if need_exe_wrapper and not env.has_exe_wrapper(): raise CrossNoRunException('Can not run test applications in this cross environment.') - with self._build_wrapper(code, env, extra_args, dependencies, mode=CompileCheckMode.LINK, want_output=True) as p: + with self._build_wrapper(code, extra_args, dependencies, mode=CompileCheckMode.LINK, want_output=True) as p: if p.returncode != 0: mlog.debug(f'Could not compile test file {p.input_name}: {p.returncode}\n') return RunResult(False) @@ -1339,7 +1339,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): return args @contextlib.contextmanager - def _build_wrapper(self, code: 'mesonlib.FileOrString', env: 'Environment', + def _build_wrapper(self, code: 'mesonlib.FileOrString', extra_args: T.Union[None, CompilerArgs, T.List[str], T.Callable[[CompileCheckMode], T.List[str]]] = None, dependencies: T.Optional[T.List['Dependency']] = None, mode: CompileCheckMode = CompileCheckMode.COMPILE, want_output: bool = False, @@ -1349,12 +1349,12 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): This method isn't meant to be called externally, it's mean to be wrapped by other methods like compiles() and links(). """ - args = self.build_wrapper_args(env, extra_args, dependencies, mode) + args = self.build_wrapper_args(self.environment, extra_args, dependencies, mode) if disable_cache or want_output: - with self.compile(code, extra_args=args, mode=mode, want_output=want_output, temp_dir=env.scratch_dir) as r: + with self.compile(code, extra_args=args, mode=mode, want_output=want_output, temp_dir=self.environment.scratch_dir) as r: yield r else: - with self.cached_compile(code, env.coredata, extra_args=args, mode=mode, temp_dir=env.scratch_dir) as r: + with self.cached_compile(code, self.environment.coredata, extra_args=args, mode=mode, temp_dir=self.environment.scratch_dir) as r: yield r def compiles(self, code: 'mesonlib.FileOrString', *, @@ -1368,7 +1368,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): A tuple of (bool, bool). The first value is whether the check succeeded, and the second is whether it was retrieved from a cache """ - with self._build_wrapper(code, self.environment, extra_args, dependencies, mode, disable_cache=disable_cache) as p: + with self._build_wrapper(code, extra_args, dependencies, mode, disable_cache=disable_cache) as p: return p.returncode == 0, p.cached def links(self, code: 'mesonlib.FileOrString', *, @@ -1377,7 +1377,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): dependencies: T.Optional[T.List['Dependency']] = None, disable_cache: bool = False) -> T.Tuple[bool, bool]: if compiler: - with compiler._build_wrapper(code, self.environment, dependencies=dependencies, want_output=True) as r: + with compiler._build_wrapper(code, dependencies=dependencies, want_output=True) as r: objfile = mesonlib.File.from_absolute_file(r.output_name) return self.compiles(objfile, extra_args=extra_args, dependencies=dependencies, mode=CompileCheckMode.LINK, disable_cache=True) diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 8bbd4d423..a4c49fc86 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -909,7 +909,7 @@ class CLikeCompiler(Compiler): ''' args = self.get_compiler_check_args(CompileCheckMode.COMPILE) n = '_symbols_have_underscore_prefix_searchbin' - with self._build_wrapper(code, env, extra_args=args, mode=CompileCheckMode.COMPILE, want_output=True) as p: + with self._build_wrapper(code, extra_args=args, mode=CompileCheckMode.COMPILE, want_output=True) as p: if p.returncode != 0: raise RuntimeError(f'BUG: Unable to compile {n!r} check: {p.stderr}') if not os.path.isfile(p.output_name): @@ -944,7 +944,7 @@ class CLikeCompiler(Compiler): #endif {delim}MESON_UNDERSCORE_PREFIX ''' - with self._build_wrapper(code, env, mode=CompileCheckMode.PREPROCESS, want_output=False) as p: + with self._build_wrapper(code, mode=CompileCheckMode.PREPROCESS, want_output=False) as p: if p.returncode != 0: raise RuntimeError(f'BUG: Unable to preprocess _symbols_have_underscore_prefix_define check: {p.stdout}') symbol_prefix = p.stdout.partition(delim)[-1].rstrip() diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py index d8f4f68a8..6a6f48606 100644 --- a/mesonbuild/compilers/mixins/gnu.py +++ b/mesonbuild/compilers/mixins/gnu.py @@ -438,9 +438,9 @@ class GnuLikeCompiler(Compiler, metaclass=abc.ABCMeta): return parameter_list @functools.lru_cache() - def _get_search_dirs(self, env: 'Environment') -> str: + def _get_search_dirs(self) -> str: extra_args = ['--print-search-dirs'] - with self._build_wrapper('', env, extra_args=extra_args, + with self._build_wrapper('', extra_args=extra_args, dependencies=None, mode=CompileCheckMode.COMPILE, want_output=True) as p: return p.stdout @@ -486,7 +486,7 @@ class GnuLikeCompiler(Compiler, metaclass=abc.ABCMeta): ''' Get dirs from the compiler, either `libraries:` or `programs:` ''' - stdo = self._get_search_dirs(env) + stdo = self._get_search_dirs() for line in stdo.split('\n'): if line.startswith(name + ':'): return self._split_fetch_real_dirs(line.split('=', 1)[1]) @@ -607,7 +607,7 @@ class GnuCompiler(GnuLikeCompiler): # For some compiler command line arguments, the GNU compilers will # emit a warning on stderr indicating that an option is valid for a # another language, but still complete with exit_success - with self._build_wrapper(code, env, args, None, mode) as p: + with self._build_wrapper(code, args, None, mode) as p: result = p.returncode == 0 if self.language in {'cpp', 'objcpp'} and 'is valid for C/ObjC' in p.stderr: result = False diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py index 6d9b7ac7b..1a00721b6 100644 --- a/mesonbuild/compilers/mixins/visualstudio.py +++ b/mesonbuild/compilers/mixins/visualstudio.py @@ -297,7 +297,7 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta): # http://stackoverflow.com/questions/15259720/how-can-i-make-the-microsoft-c-compiler-treat-unknown-flags-as-errors-rather-t def has_arguments(self, args: T.List[str], env: 'Environment', code: str, mode: CompileCheckMode) -> T.Tuple[bool, bool]: warning_text = '4044' if mode == CompileCheckMode.LINK else '9002' - with self._build_wrapper(code, env, extra_args=args, mode=mode) as p: + with self._build_wrapper(code, extra_args=args, mode=mode) as p: if p.returncode != 0: return False, p.cached return not (warning_text in p.stderr or warning_text in p.stdout), p.cached diff --git a/mesonbuild/compilers/vala.py b/mesonbuild/compilers/vala.py index ca16da4eb..ce893d435 100644 --- a/mesonbuild/compilers/vala.py +++ b/mesonbuild/compilers/vala.py @@ -202,7 +202,7 @@ class ValaCompiler(Compiler): disable_cache: bool = False) -> T.Tuple[bool, bool]: self.force_link = True if compiler: - with compiler._build_wrapper(code, self.environment, dependencies=dependencies, want_output=True) as r: + with compiler._build_wrapper(code, dependencies=dependencies, want_output=True) as r: objfile = mesonlib.File.from_absolute_file(r.output_name) result = self.compiles(objfile, extra_args=extra_args, dependencies=dependencies, mode=CompileCheckMode.LINK, disable_cache=True) |
