diff options
| author | Dylan Baker <dylan@pnwbakers.com> | 2024-08-27 13:19:21 -0700 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2024-10-01 08:26:40 -0700 |
| commit | c79453ed73569796130eb62fbfa913d89e9bfb54 (patch) | |
| tree | 63613a830cbd506dc8c56ddcb3c29ce3be71b251 | |
| parent | f9c2a68372fe03824297307a1d549d9fe3c71101 (diff) | |
| download | meson-c79453ed73569796130eb62fbfa913d89e9bfb54.tar.gz | |
modules/cmake: simplify _args_to_info
We don't need to pass a list, and we don't need to check length or type
| -rw-r--r-- | mesonbuild/modules/cmake.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/mesonbuild/modules/cmake.py b/mesonbuild/modules/cmake.py index d437d7d7b..8eefe11cc 100644 --- a/mesonbuild/modules/cmake.py +++ b/mesonbuild/modules/cmake.py @@ -109,11 +109,7 @@ class CMakeSubproject(ModuleObject): 'found': self.found_method, }) - def _args_to_info(self, args: T.List[str]) -> T.Dict[str, str]: - if len(args) != 1: - raise InterpreterException('Exactly one argument is required.') - - tgt = args[0] + def _args_to_info(self, tgt: str) -> T.Dict[str, str]: res = self.cm_interpreter.target_info(tgt) if res is None: raise InterpreterException(f'The CMake target {tgt} does not exist\n' + @@ -133,7 +129,7 @@ class CMakeSubproject(ModuleObject): @permittedKwargs({'include_type'}) @typed_pos_args('cmake.subproject.dependency', str) def dependency(self, state: ModuleState, args: T.Tuple[str], kwargs: T.Dict[str, str]) -> dependencies.Dependency: - info = self._args_to_info(list(args)) + info = self._args_to_info(args[0]) if info['func'] == 'executable': raise InvalidArguments(f'{args[0]} is an executable and does not support the dependency() method. Use target() instead.') if info['dep'] is None: @@ -149,19 +145,19 @@ class CMakeSubproject(ModuleObject): @noKwargs @typed_pos_args('cmake.subproject.include_directories', str) def include_directories(self, state: ModuleState, args: T.Tuple[str], kwargs: TYPE_kwargs) -> build.IncludeDirs: - info = self._args_to_info(list(args)) + info = self._args_to_info(args[0]) return self.get_variable(state, [info['inc']], kwargs) @noKwargs @typed_pos_args('cmake.subproject.target', str) def target(self, state: ModuleState, args: T.Tuple[str], kwargs: TYPE_kwargs) -> build.Target: - info = self._args_to_info(list(args)) + info = self._args_to_info(args[0]) return self.get_variable(state, [info['tgt']], kwargs) @noKwargs @typed_pos_args('cmake.subproject.target_type', str) def target_type(self, state: ModuleState, args: T.Tuple[str], kwargs: TYPE_kwargs) -> str: - info = self._args_to_info(list(args)) + info = self._args_to_info(args[0]) return info['func'] @noPosargs |
