Merge pull request #250 from Jcw87/makefile_header_deps_wsl

transform-dep.py: fix for wsl
This commit is contained in:
TakaRikka 2023-01-24 00:32:34 -08:00 committed by GitHub
commit 14a682035c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 3 deletions

View File

@ -9,7 +9,9 @@ if os.name != 'nt':
winedevices = os.path.join(wineprefix, 'dosdevices')
def in_wsl() -> bool:
return 'microsoft-standard' in uname().release
# wsl1 has Microsoft, wsl2 has microsoft-standard
release = uname().release
return 'microsoft-standard' in release or 'Microsoft' in release
def import_d_file(in_file) -> str:
out_lines = []
@ -36,8 +38,15 @@ def import_d_file(in_file) -> str:
# shortcut for z:
path = path[2:].replace('\\', '/')
elif in_wsl():
path = path[0:1] + path[2:]
path = os.path.join('/mnt', path.replace('\\', '/'))
if path.startswith(r'\\wsl'):
# first part could be wsl$ or wsl.localhost
pos = path.find('\\', 2)
pos = path.find('\\', pos + 1)
path = path[pos:]
path = path.replace('\\', '/')
else:
path = path[0:1] + path[2:]
path = os.path.join('/mnt', path.replace('\\', '/'))
else:
# use $WINEPREFIX/dosdevices to resolve path
path = os.path.realpath(os.path.join(winedevices, path.replace('\\', '/')))