path interpreter--silently discard invalid Unix relative paths on Windows

fixes #6000

The idea is that end-users want to specify an array of directories to search by default
without an if/elif stack. It's obvious that Unix absolute paths are not absolute on
Windows, so silently discard Unix absolute paths here for Windows instead of raising
exception.
pull/6032/head
Michael Hirsch, Ph.D 5 years ago committed by Dylan Baker
parent 9f0f595b35
commit ebb1ad528a
  1. 4
      mesonbuild/interpreter.py

@ -1557,6 +1557,10 @@ class CompilerHolder(InterpreterObject):
search_dirs = mesonlib.stringlistify(kwargs.get('dirs', []))
search_dirs = [Path(d).expanduser() for d in search_dirs]
for d in search_dirs:
if mesonlib.is_windows() and d.root.startswith('\\'):
# a Unix-path starting with `/` that is not absolute on Windows.
# discard without failing for end-user ease of cross-platform directory arrays
continue
if not d.is_absolute():
raise InvalidCode('Search directory {} is not an absolute path.'.format(d))
search_dirs = list(map(str, search_dirs))

Loading…
Cancel
Save