aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniele Nicolodi <daniele@grinta.net>2023-03-26 10:51:28 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2023-04-14 21:37:52 +0300
commit1bc3d91112c046006da26d1a5c77af4854c6899b (patch)
treead1b5bf04825703cc338f1eba77249aa0770b65e
parent1c00cb2550517917a655fc6eb6471fc575a32ace (diff)
downloadmeson-1bc3d91112c046006da26d1a5c77af4854c6899b.zip
meson-1bc3d91112c046006da26d1a5c77af4854c6899b.tar.gz
meson-1bc3d91112c046006da26d1a5c77af4854c6899b.tar.bz2
minstall: Fix install_subdir() excludes with path separators on Win
The paths in meson.build use / as path separator, however, the paths constructed during the directory structure walk use native path separators, thus the path never compare equal to the excluded ones. Normalize the exclusion paths before the comparison.
-rw-r--r--mesonbuild/minstall.py2
-rw-r--r--test cases/common/59 install subdir/meson.build6
-rw-r--r--test cases/common/59 install subdir/sub3/data/data.txt1
-rw-r--r--test cases/common/59 install subdir/sub3/data/excluded.txt1
-rw-r--r--test cases/common/59 install subdir/sub3/data/excluded/excluded.txt1
-rw-r--r--test cases/common/59 install subdir/test.json1
-rw-r--r--unittests/allplatformstests.py11
7 files changed, 18 insertions, 5 deletions
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py
index 91e87fa..c4de5c2 100644
--- a/mesonbuild/minstall.py
+++ b/mesonbuild/minstall.py
@@ -480,6 +480,8 @@ class Installer:
raise ValueError(f'dst_dir must be absolute, got {dst_dir}')
if exclude is not None:
exclude_files, exclude_dirs = exclude
+ exclude_files = {os.path.normpath(x) for x in exclude_files}
+ exclude_dirs = {os.path.normpath(x) for x in exclude_dirs}
else:
exclude_files = exclude_dirs = set()
for root, dirs, files in os.walk(src_dir):
diff --git a/test cases/common/59 install subdir/meson.build b/test cases/common/59 install subdir/meson.build
index 13d41be..fb2034b 100644
--- a/test cases/common/59 install subdir/meson.build
+++ b/test cases/common/59 install subdir/meson.build
@@ -7,6 +7,12 @@ install_subdir('sub2',
exclude_directories : ['excluded'],
install_dir : 'share')
+# More exclusions
+install_subdir('sub3',
+ exclude_files : ['data/excluded.txt'],
+ exclude_directories : ['data/excluded'],
+ install_dir : 'share')
+
subdir('subdir')
# A subdir with write perms only for the owner
# and read-list perms for owner and group
diff --git a/test cases/common/59 install subdir/sub3/data/data.txt b/test cases/common/59 install subdir/sub3/data/data.txt
new file mode 100644
index 0000000..1269488
--- /dev/null
+++ b/test cases/common/59 install subdir/sub3/data/data.txt
@@ -0,0 +1 @@
+data
diff --git a/test cases/common/59 install subdir/sub3/data/excluded.txt b/test cases/common/59 install subdir/sub3/data/excluded.txt
new file mode 100644
index 0000000..bbde3dc
--- /dev/null
+++ b/test cases/common/59 install subdir/sub3/data/excluded.txt
@@ -0,0 +1 @@
+excluded
diff --git a/test cases/common/59 install subdir/sub3/data/excluded/excluded.txt b/test cases/common/59 install subdir/sub3/data/excluded/excluded.txt
new file mode 100644
index 0000000..bbde3dc
--- /dev/null
+++ b/test cases/common/59 install subdir/sub3/data/excluded/excluded.txt
@@ -0,0 +1 @@
+excluded
diff --git a/test cases/common/59 install subdir/test.json b/test cases/common/59 install subdir/test.json
index 0dd885c..aa8e27a 100644
--- a/test cases/common/59 install subdir/test.json
+++ b/test cases/common/59 install subdir/test.json
@@ -12,6 +12,7 @@
{"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/sub3/data/data.txt"},
{"type": "dir", "file": "usr/share/new_directory"}
]
}
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index a8ec787..493cb9c 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -441,14 +441,15 @@ class AllPlatformTests(BasePlatformTests):
self.init(testdir)
intro = self.introspect('--installed')
expected = {
+ 'nested_elided/sub': 'share',
+ 'new_directory': 'share/new_directory',
+ 'sub/sub1': 'share/sub1',
+ 'sub1': 'share/sub1',
'sub2': 'share/sub2',
+ 'sub3': '/usr/share/sub3',
+ 'sub_elided': 'share',
'subdir/sub1': 'share/sub1',
'subdir/sub_elided': 'share',
- 'sub1': 'share/sub1',
- 'sub/sub1': 'share/sub1',
- 'sub_elided': 'share',
- 'nested_elided/sub': 'share',
- 'new_directory': 'share/new_directory',
}
self.assertEqual(len(intro), len(expected))