diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2022-03-08 16:00:42 -0800 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2022-08-18 21:57:36 -0400 |
commit | ddb95b0ed8c09808388c94da4f4f47f9dc0633af (patch) | |
tree | 712d0e4366c05458eef56ad21905c8023814b2e0 /mesonbuild/modules | |
parent | 6e75456a75ffad4cf847b03afa09ab7b1462fbbb (diff) | |
download | meson-ddb95b0ed8c09808388c94da4f4f47f9dc0633af.zip meson-ddb95b0ed8c09808388c94da4f4f47f9dc0633af.tar.gz meson-ddb95b0ed8c09808388c94da4f4f47f9dc0633af.tar.bz2 |
modules/pkgconfig: use typed_pos_args
Diffstat (limited to 'mesonbuild/modules')
-rw-r--r-- | mesonbuild/modules/pkgconfig.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py index 62a32eb..321fa97 100644 --- a/mesonbuild/modules/pkgconfig.py +++ b/mesonbuild/modules/pkgconfig.py @@ -26,6 +26,7 @@ from .. import mlog from ..coredata import BUILTIN_DIR_OPTIONS from ..dependencies import ThreadDependency from ..interpreterbase import permittedKwargs, FeatureNew, FeatureDeprecated, FeatureNewKwargs +from ..interpreterbase.decorators import typed_pos_args if T.TYPE_CHECKING: from . import ModuleState @@ -511,27 +512,24 @@ class PkgConfigModule(ExtensionModule): 'install_dir', 'extra_cflags', 'variables', 'url', 'd_module_versions', 'dataonly', 'conflicts', 'uninstalled_variables', 'unescaped_variables', 'unescaped_uninstalled_variables'}) - def generate(self, state: 'ModuleState', args, kwargs): + @typed_pos_args('pkgconfig.generate', optargs=[(build.SharedLibrary, build.StaticLibrary)]) + def generate(self, state: ModuleState, args: T.Tuple[T.Optional[T.Union[build.SharedLibrary, build.StaticLibrary]]], kwargs): default_version = state.project_version default_install_dir = None default_description = None default_name = None mainlib = None default_subdirs = ['.'] - if not args and 'version' not in kwargs: - FeatureNew.single_use('pkgconfig.generate implicit version keyword', '0.46.0', state.subproject) - elif len(args) == 1: + if args[0]: FeatureNew.single_use('pkgconfig.generate optional positional argument', '0.46.0', state.subproject) mainlib = args[0] - if not isinstance(mainlib, (build.StaticLibrary, build.SharedLibrary)): - raise mesonlib.MesonException('Pkgconfig_gen first positional argument must be a library object') default_name = mainlib.name default_description = state.project_name + ': ' + mainlib.name install_dir = mainlib.get_custom_install_dir() if install_dir and isinstance(install_dir[0], str): default_install_dir = os.path.join(install_dir[0], 'pkgconfig') - elif len(args) > 1: - raise mesonlib.MesonException('Too many positional arguments passed to Pkgconfig_gen.') + elif 'version' not in kwargs: + FeatureNew.single_use('pkgconfig.generate implicit version keyword', '0.46.0', state.subproject) dataonly = kwargs.get('dataonly', False) if not isinstance(dataonly, bool): |