diff --git a/docs/markdown/snippets/install-many-emptydirs.md b/docs/markdown/snippets/install-many-emptydirs.md new file mode 100644 index 000000000000..27505ae93447 --- /dev/null +++ b/docs/markdown/snippets/install-many-emptydirs.md @@ -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. diff --git a/docs/yaml/functions/install_emptydir.yaml b/docs/yaml/functions/install_emptydir.yaml index df84f60b5d9c..b2f5df17aaf7 100644 --- a/docs/yaml/functions/install_emptydir.yaml +++ b/docs/yaml/functions/install_emptydir.yaml @@ -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: diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index bf2a21d4bd4d..cadca6b4777b 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -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) diff --git a/test cases/common/248 install_emptydir/meson.build b/test cases/common/248 install_emptydir/meson.build index a5eb046e48c1..cdeb434297c4 100644 --- a/test cases/common/248 install_emptydir/meson.build +++ b/test cases/common/248 install_emptydir/meson.build @@ -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' + ]) diff --git a/test cases/common/248 install_emptydir/test.json b/test cases/common/248 install_emptydir/test.json index 17abe74bf18e..93522abb7940 100644 --- a/test cases/common/248 install_emptydir/test.json +++ b/test cases/common/248 install_emptydir/test.json @@ -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" } ] } -