aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2021-02-03 09:15:45 +1000
committerJussi Pakkanen <jpakkane@gmail.com>2021-02-07 12:38:31 +0000
commit3f8585676ba6d2c1bcd5d80a44275fdfa695f8c2 (patch)
tree29b849967b89688572f17c26d8d40a28eb5ac581
parent034b81a09f20902c2d8cb907e162c7e6cb48e8c1 (diff)
downloadmeson-3f8585676ba6d2c1bcd5d80a44275fdfa695f8c2.zip
meson-3f8585676ba6d2c1bcd5d80a44275fdfa695f8c2.tar.gz
meson-3f8585676ba6d2c1bcd5d80a44275fdfa695f8c2.tar.bz2
Make installing non-existing subdirs a supported feature
install_subdir() with a non-existing subdir creates the directory in the target directory. This seems like an implementation detail but is quite useful to create new directories for e.g. configuration or plugins in the installed locations. git bisect says this started with 8fe816101467e66792251b4f57e0ddddb537764a. Let's add a test for it and document it to make this behavior official. Limitation: it can only create at the install_dir location, trying to create nested subdirectories does not work and indeed creates the wrong directory structure. That is a bug that should be fixed separately: install_subdir('blah', install_dir: get_option('prefix')) install_subdir('sub/foobar', install_dir: get_option('prefix')) install_subdir('foo/baz', install_dir: get_option('prefix')) $ tree ../_inst ../_inst β”œβ”€β”€ baz β”œβ”€β”€ blah └── foobar Fixes #2904
-rw-r--r--docs/markdown/Reference-manual.md10
-rwxr-xr-xrun_unittests.py1
-rw-r--r--test cases/common/60 install subdir/meson.build3
-rw-r--r--test cases/common/60 install subdir/test.json3
4 files changed, 16 insertions, 1 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md
index f12f695..46ea1c0 100644
--- a/docs/markdown/Reference-manual.md
+++ b/docs/markdown/Reference-manual.md
@@ -1143,6 +1143,10 @@ Installs the entire given subdirectory and its contents from the
source tree to the location specified by the keyword argument
`install_dir`.
+If the subdirectory does not exist in the source tree, an empty directory is
+created in the specified location. *(since 0.45.0)* A newly created
+subdirectory may only be created in the keyword argument `install_dir`.
+
The following keyword arguments are supported:
- `exclude_files`: a list of file names that should not be installed.
@@ -1192,6 +1196,12 @@ share/
file1
```
+`install_subdir('new_directory', install_dir : 'share')` creates
+```text
+share/
+ new_directory/
+```
+
### is_disabler()
``` meson
diff --git a/run_unittests.py b/run_unittests.py
index 2e7fe91..3f97c0c 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -2414,6 +2414,7 @@ class AllPlatformTests(BasePlatformTests):
'sub/sub1': 'share/sub1',
'sub_elided': 'share',
'nested_elided/sub': 'share',
+ 'new_directory': 'share/new_directory',
}
self.assertEqual(len(intro), len(expected))
diff --git a/test cases/common/60 install subdir/meson.build b/test cases/common/60 install subdir/meson.build
index 6f92efd..59f3b4d 100644
--- a/test cases/common/60 install subdir/meson.build
+++ b/test cases/common/60 install subdir/meson.build
@@ -16,3 +16,6 @@ install_subdir('sub/sub1', install_dir : 'share')
# strip_directory
install_subdir('sub_elided', install_dir : 'share', strip_directory : true)
install_subdir('nested_elided/sub', install_dir : 'share', strip_directory : true)
+
+# Create new empty directory that doesn't exist in the source tree
+install_subdir('new_directory', install_dir : 'share')
diff --git a/test cases/common/60 install subdir/test.json b/test cases/common/60 install subdir/test.json
index 88c6f4b..0dd885c 100644
--- a/test cases/common/60 install subdir/test.json
+++ b/test cases/common/60 install subdir/test.json
@@ -11,6 +11,7 @@
{"type": "file", "file": "usr/share/sub1/third.dat"},
{"type": "file", "file": "usr/share/sub1/sub2/data2.dat"},
{"type": "file", "file": "usr/share/sub2/one.dat"},
- {"type": "file", "file": "usr/share/sub2/dircheck/excluded-three.dat"}
+ {"type": "file", "file": "usr/share/sub2/dircheck/excluded-three.dat"},
+ {"type": "dir", "file": "usr/share/new_directory"}
]
}