diff options
| author | Dylan Baker <dylan@pnwbakers.com> | 2025-10-20 15:51:39 -0700 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-12-17 10:27:54 -0800 |
| commit | 2488f3f4b2f192a11d62534a08e792fd36f800c0 (patch) | |
| tree | ec58c37bf3462f6f5824e19250252162d7e1157d | |
| parent | cb7431b1200871e7a70499a8e02b82dc0fa32c39 (diff) | |
| download | meson-2488f3f4b2f192a11d62534a08e792fd36f800c0.tar.gz | |
interpreter: Add type checking for BuildTarget(install_dir: )
This just puts the type checking in the frontend, there's still some
serious cleanup in the build and backend that need to happen.
| -rw-r--r-- | mesonbuild/build.py | 5 | ||||
| -rw-r--r-- | mesonbuild/interpreter/kwargs.py | 1 | ||||
| -rw-r--r-- | mesonbuild/interpreter/type_checking.py | 6 | ||||
| -rw-r--r-- | mesonbuild/modules/python.py | 9 |
4 files changed, 15 insertions, 6 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 2abe49686..37a437812 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -22,7 +22,7 @@ from . import programs from .mesonlib import ( HoldableObject, SecondLevelHolder, File, MesonException, MachineChoice, PerMachine, OrderedSet, listify, - extract_as_list, typeslistify, classify_unity_sources, + extract_as_list, classify_unity_sources, get_filenames_templates_dict, substitute_values, has_path_sep, is_parent_path, relpath, PerMachineDefaultable, MesonBugException, EnvironmentVariables, pickle_load, lazy_property, @@ -1291,8 +1291,7 @@ class BuildTarget(Target): self.add_deps(deplist) # If an item in this list is False, the output corresponding to # the list index of that item will not be installed - self.install_dir = typeslistify(kwargs.get('install_dir', []), - (str, bool)) + self.install_dir = kwargs.get('install_dir', []) self.install_mode = kwargs.get('install_mode', None) self.install_tag: T.List[T.Optional[str]] = kwargs.get('install_tag') or [None] self.extra_files = kwargs.get('extra_files', []) diff --git a/mesonbuild/interpreter/kwargs.py b/mesonbuild/interpreter/kwargs.py index 517ccee15..c08ceb759 100644 --- a/mesonbuild/interpreter/kwargs.py +++ b/mesonbuild/interpreter/kwargs.py @@ -367,6 +367,7 @@ class _BuildTarget(_BaseBuildTarget): d_import_dirs: T.List[T.Union[str, build.IncludeDirs]] d_module_versions: T.List[T.Union[str, int]] d_unittest: bool + install_dir: T.List[T.Union[str, bool]] rust_crate_type: T.Optional[Literal['bin', 'lib', 'rlib', 'dylib', 'cdylib', 'staticlib', 'proc-macro']] rust_dependency_map: T.Dict[str, str] swift_interoperability_mode: Literal['c', 'cpp'] diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py index 7d6b0073a..478924828 100644 --- a/mesonbuild/interpreter/type_checking.py +++ b/mesonbuild/interpreter/type_checking.py @@ -614,6 +614,12 @@ _ALL_TARGET_KWS: T.List[KwargInfo] = [ ), INSTALL_MODE_KW, INSTALL_TAG_KW, + KwargInfo( + 'install_dir', + ContainerTypeInfo(list, (str, bool)), + default=[], + listify=True, + ), KwargInfo('implicit_include_directories', bool, default=True, since='0.42.0'), NATIVE_KW, KwargInfo('resources', ContainerTypeInfo(list, str), default=[], listify=True), diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py index 99602c05a..3d8969f41 100644 --- a/mesonbuild/modules/python.py +++ b/mesonbuild/modules/python.py @@ -22,7 +22,7 @@ from ..interpreterbase import ( InvalidArguments, typed_pos_args, typed_kwargs, KwargInfo, FeatureNew, disablerIfNotFound, InterpreterObject ) -from ..mesonlib import MachineChoice +from ..mesonlib import MachineChoice, listify from ..options import OptionKey from ..programs import ExternalProgram, NonExistingExternalProgram @@ -60,7 +60,8 @@ mod_kwargs = {'subdir', 'limited_api'} mod_kwargs.update(known_shmod_kwargs) mod_kwargs -= {'name_prefix', 'name_suffix'} -_MOD_KWARGS = [k for k in SHARED_MOD_KWS if k.name not in {'name_prefix', 'name_suffix'}] +_MOD_KWARGS = [k for k in SHARED_MOD_KWS if + k.name not in {'name_prefix', 'name_suffix', 'install_dir'}] class PythonExternalProgram(BasicPythonExternalProgram): @@ -145,13 +146,15 @@ class PythonInstallation(_ExternalProgramHolder['PythonExternalProgram']): if 'install_dir' in kwargs: if kwargs['subdir'] is not None: raise InvalidArguments('"subdir" and "install_dir" are mutually exclusive') + # the build_target() method now expects this to be correct. + kwargs['install_dir'] = listify(kwargs['install_dir']) else: # We want to remove 'subdir', but it may be None and we want to replace it with '' # It must be done this way since we don't allow both `install_dir` # and `subdir` to be set at the same time subdir = kwargs.pop('subdir') or '' - kwargs['install_dir'] = self._get_install_dir_impl(False, subdir) + kwargs['install_dir'] = [self._get_install_dir_impl(False, subdir)] target_suffix = self.suffix |
