diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-02-03 18:57:57 +0530 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2017-02-06 19:10:03 +0100 |
commit | 97911c4384238b1f77220b62e245d33f51f7b17a (patch) | |
tree | f7ed87ab83cedea60f05435809844a062f204ed5 /mesonbuild | |
parent | 14e0529a037eb8f3d809822c811d2c034d8f0788 (diff) | |
download | meson-97911c4384238b1f77220b62e245d33f51f7b17a.zip meson-97911c4384238b1f77220b62e245d33f51f7b17a.tar.gz meson-97911c4384238b1f77220b62e245d33f51f7b17a.tar.bz2 |
Fix absolute prefix/xxxdir subdir check on Windows
os.path.commonpath (and our implementation of it) both always return the
path using the native operating system path separator, so we can't just
directly compare it since the prefix could be specified in '/', and
commonpath would use '\' on Windows.
Also add a unit test for this.
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/coredata.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index 7b4059e..954e497 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -13,6 +13,7 @@ # limitations under the License. import pickle, os, uuid +from pathlib import PurePath from .mesonlib import MesonException, commonpath from .mesonlib import default_libdir, default_libexecdir, default_prefix @@ -159,7 +160,10 @@ class CoreData: if option.endswith('dir') and os.path.isabs(value) and \ option not in builtin_dir_noprefix_options: # Value must be a subdir of the prefix - if commonpath([value, prefix]) != prefix: + # commonpath will always return a path in the native format, so we + # must use pathlib.PurePath to do the same conversion before + # comparing. + if commonpath([value, prefix]) != str(PurePath(prefix)): m = 'The value of the {!r} option is {!r} which must be a ' \ 'subdir of the prefix {!r}.\nNote that if you pass a ' \ 'relative path, it is assumed to be a subdir of prefix.' |