Skip to content

Commit

Permalink
interpreter: handle multiple dirs in install_emptydir
Browse files Browse the repository at this point in the history
Fixes: #12717
  • Loading branch information
Hi-Angel committed Jan 9, 2024
1 parent efc4cfc commit 4c636b8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
5 changes: 5 additions & 0 deletions docs/markdown/snippets/install-many-emptydirs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## [[install_emptydir]] now supports multiple dirs inside one call

Prior to this release passing multiple paths as `dirpath` argument was resulting in only the first path to get created. The rest were ignored. That was expected behavior as [[install_emptydir]] was documented to only take a single path. But it also had an incorrect type annotation that claimed for it to take multiple paths, which led to confusion.

Now passing more than one path in `dirpath` will create all of them.
9 changes: 5 additions & 4 deletions docs/yaml/functions/install_emptydir.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ name: install_emptydir
returns: void
since: 0.60.0
description: |
Installs a new directory entry to the location specified by the positional
argument. If the directory exists and is not empty, the contents are left in
place.
Installs a directory (more than one allowed since 1.4.0) to the location
specified by the positional argument. If the directory exists and is not
empty, the contents are left in place.
warnings:
- the `install_mode` kwarg ignored integer values before 1.1.0.
- second path and beyond passed as dirpath were ignored before 1.4.0.

varargs:
name: dirpath
type: str
description: Directory to create during installation.
description: Directories to create during installation.

kwargs:
install_mode:
Expand Down
10 changes: 7 additions & 3 deletions mesonbuild/interpreter/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2301,14 +2301,18 @@ def func_install_man(self, node: mparser.BaseNode,
return m

@FeatureNew('install_emptydir', '0.60.0')
@typed_pos_args('install_emptydir', varargs=str, min_varargs=1)
@typed_kwargs(
'install_emptydir',
INSTALL_MODE_KW,
KwargInfo('install_tag', (str, NoneType), since='0.62.0')
)
def func_install_emptydir(self, node: mparser.BaseNode, args: T.Tuple[str], kwargs) -> None:
d = build.EmptyDir(args[0], kwargs['install_mode'], self.subproject, kwargs['install_tag'])
self.build.emptydir.append(d)
def func_install_emptydir(self, node: mparser.BaseNode, args: T.Tuple[T.List[str]], kwargs) -> None:
if len(args[0]) > 1:
FeatureNew.single_use('install_emptydir with more than one directory', '1.4.0', self.subproject, location=node)
self.build.emptydir += \
[build.EmptyDir(one_dir, kwargs['install_mode'], self.subproject, kwargs['install_tag'])
for one_dir in args[0]]

@FeatureNew('install_symlink', '0.61.0')
@typed_pos_args('symlink_name', str)
Expand Down
4 changes: 4 additions & 0 deletions test cases/common/248 install_emptydir/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ project('install_emptydir')

install_emptydir(get_option('datadir')/'new_directory', install_mode: 'rwx------')
install_emptydir(get_option('datadir')/'new_directory/subdir', install_mode: 'rwxr-----')
install_emptydir([get_option('datadir')/'dir1',
get_option('datadir')/'dir2',
get_option('datadir')/'dir3'
])
6 changes: 4 additions & 2 deletions test cases/common/248 install_emptydir/test.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"installed": [
{ "type": "dir", "file": "usr/share/new_directory" },
{ "type": "dir", "file": "usr/share/new_directory/subdir" }
{ "type": "dir", "file": "usr/share/new_directory/subdir" },
{ "type": "dir", "file": "usr/share/dir1" },
{ "type": "dir", "file": "usr/share/dir2" },
{ "type": "dir", "file": "usr/share/dir3" }
]
}

0 comments on commit 4c636b8

Please sign in to comment.