Repository: mesonbuild/meson

Issue:
Visual Studio Backend Doesn't Work when project is on different drive as include paths
**Describe the bug**
When installing the project in a specific drive, e.g. drive D, and adding include paths on a different drive , e.g. drive C, meson setup will crash:

Traceback (most recent call last):
  File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\mesonmain.py", line 140, in run
    return options.run_func(options)
  File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\msetup.py", line 253, in run
    app.generate()
  File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\msetup.py", line 161, in generate
    self._generate(env)
  File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\msetup.py", line 223, in _generate
    intr.backend.generate()                                                                                                                                                                                                                    File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\backend\vs2010backend.py", line 188, in generate
    projlist = self.generate_projects()
  File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\backend\vs2010backend.py", line 422, in generate_projects
    self.gen_vcxproj(target, str(projfile_path), proj_uuid)
  File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\backend\vs2010backend.py", line 971, in gen_vcxproj
    args.append('-I' + self.relpath(curdir, target.subdir)) # build dir
  File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\backend\backends.py", line 339, in relpath
    os.path.join('dummyprefixdir', fromdir))
  File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\ntpath.py", line 562, in relpath
    path_drive, start_drive))
ValueError: path is on mount 'C:', start on mount 'D:'

When looking at the code: 
https://github.com/mesonbuild/meson/blob/0.56/mesonbuild/backend/vs2010backend.py
 This logic is not correct:
 
for d in reversed(target.get_include_dirs()):
                # reversed is used to keep order of includes
                for i in reversed(d.get_incdirs()):
                    curdir = os.path.join(d.get_curdir(), i)
                   args.append('-I' + self.relpath(curdir, target.subdir)) # **** won't work if different drive letters ****    
 
 What if the include path is in drive D and the current directory is in drive C?
 
**To Reproduce**
Install dependency xyz in drive C and project on drive D

xyz_dep = dependency('xyz')
libxyz = library(
dependencies: [ xyz_dep ]
)

**Expected behavior**
Meson should support project directories on any drive and include directories on any drive

**system parameters**
native build
Windows 10
Python 3.7.9 



Discussion:

Resolving patch:
diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py
--- a/mesonbuild/backend/vs2010backend.py
+++ b/mesonbuild/backend/vs2010backend.py
@@ -1043,8 +1043,12 @@ def gen_vcxproj(self, target, ofname, guid):
                 # reversed is used to keep order of includes
                 for i in reversed(d.get_incdirs()):
                     curdir = os.path.join(d.get_curdir(), i)
-                    args.append('-I' + self.relpath(curdir, target.subdir))  # build dir
-                    args.append('-I' + os.path.join(proj_to_src_root, curdir))  # src dir
+                    try:
+                        args.append('-I' + self.relpath(curdir, target.subdir)) # build dir
+                        args.append('-I' + os.path.join(proj_to_src_root, curdir))  # src dir
+                    except ValueError:
+                        # Include is on different drive
+                        args.append('-I' + os.path.normpath(curdir))
                 for i in d.get_extra_build_dirs():
                     curdir = os.path.join(d.get_curdir(), i)
                     args.append('-I' + self.relpath(curdir, target.subdir))  # build dir


Test patch: