Skip to content

Visual Studio Backend Doesn't Work when project is on different drive as include paths #8329

@jmoguillansky-gpsw

Description

@jmoguillansky-gpsw

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions