aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter
diff options
context:
space:
mode:
authorDaniele Nicolodi <daniele@grinta.net>2023-06-26 16:24:53 +0200
committerEli Schwartz <eschwartz93@gmail.com>2023-07-26 13:30:49 -0400
commit9eb7fe332f6a6a8babd040b76ad2a6808faf0423 (patch)
treec52b1c241f7f77e2e2beee8281c50ec39e32c569 /mesonbuild/interpreter
parenta0f165b2fa57653a44c97398c00c453ec28e6dcc (diff)
downloadmeson-9eb7fe332f6a6a8babd040b76ad2a6808faf0423.zip
meson-9eb7fe332f6a6a8babd040b76ad2a6808faf0423.tar.gz
meson-9eb7fe332f6a6a8babd040b76ad2a6808faf0423.tar.bz2
Fix install_data() default install path
This fixes two issues in constructing the default installation path when install_dir is not specified: - inside a subproject, install_data() would construct the destination path using the parent project name instead than the current project name, - when specifying preserve_path, install_data() would construct the destination path omitting the project name. Fixes #11910.
Diffstat (limited to 'mesonbuild/interpreter')
-rw-r--r--mesonbuild/interpreter/interpreter.py28
1 files changed, 18 insertions, 10 deletions
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index d891fa6..dc24312 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -2465,24 +2465,31 @@ class Interpreter(InterpreterBase, HoldableObject):
'"rename" and "sources" argument lists must be the same length if "rename" is given. '
f'Rename has {len(rename)} elements and sources has {len(sources)}.')
+ install_dir = kwargs['install_dir']
+ if not install_dir:
+ subdir = self.active_projectname
+ install_dir = P_OBJ.OptionString(os.path.join(self.environment.get_datadir(), subdir), os.path.join('{datadir}', subdir))
+ if self.is_subproject():
+ FeatureNew.single_use('install_data() without install_dir inside of a subproject', '1.3.0', self.subproject,
+ 'This was broken and would install to the project name of the parent project instead',
+ node)
+ if kwargs['preserve_path']:
+ FeatureNew.single_use('install_data() with preserve_path and without install_dir', '1.3.0', self.subproject,
+ 'This was broken and would not add the project name to the install path',
+ node)
+
install_mode = self._warn_kwarg_install_mode_sticky(kwargs['install_mode'])
- return self.install_data_impl(sources, kwargs['install_dir'], install_mode,
- rename, kwargs['install_tag'],
+ return self.install_data_impl(sources, install_dir, install_mode, rename, kwargs['install_tag'],
preserve_path=kwargs['preserve_path'])
- def install_data_impl(self, sources: T.List[mesonlib.File], install_dir: T.Optional[str],
+ def install_data_impl(self, sources: T.List[mesonlib.File], install_dir: str,
install_mode: FileMode, rename: T.Optional[str],
tag: T.Optional[str],
- install_dir_name: T.Optional[str] = None,
install_data_type: T.Optional[str] = None,
preserve_path: bool = False) -> build.Data:
+ install_dir_name = install_dir.optname if isinstance(install_dir, P_OBJ.OptionString) else install_dir
- idir = install_dir or ''
- idir_name = install_dir_name or idir or '{datadir}'
- if isinstance(idir_name, P_OBJ.OptionString):
- idir_name = idir_name.optname
dirs = collections.defaultdict(list)
- ret_data = []
if preserve_path:
for file in sources:
dirname = os.path.dirname(file.fname)
@@ -2490,8 +2497,9 @@ class Interpreter(InterpreterBase, HoldableObject):
else:
dirs[''].extend(sources)
+ ret_data = []
for childdir, files in dirs.items():
- d = build.Data(files, os.path.join(idir, childdir), os.path.join(idir_name, childdir),
+ d = build.Data(files, os.path.join(install_dir, childdir), os.path.join(install_dir_name, childdir),
install_mode, self.subproject, rename, tag, install_data_type)
ret_data.append(d)