mirror of https://github.com/xemu-project/xemu.git
deploy: Use `cygpath` to translate `ldd` DLL paths
This patch adds a step in the get_deps.py script to translate the UNIX style file paths given by `ldd`, which outputs paths of the required DLLs for XQEMU, to the Windows style equivalents for deployment of XQEMU on the Windows platform. This step is necessary due to differences in path handling on variants of Python in the MSYS2 environment. All variants seem to handle the Windows style, but some do not understand the UNIX style.
This commit is contained in:
parent
c5632c9f1e
commit
592b4dbbf7
24
get_deps.py
24
get_deps.py
|
@ -22,6 +22,13 @@ def main():
|
|||
elif not os.path.isdir(args.dest):
|
||||
print('File exists with destination name')
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
subprocess.check_output(['cygpath', '--help'])
|
||||
except OSError as err:
|
||||
print("Couldn't execute cygpath (Reason: '%s')." % err)
|
||||
print("Make sure you're using a recent version of MSYS2 and that it works correctly.")
|
||||
sys.exit(1)
|
||||
|
||||
sout = subprocess.check_output(['ldd', args.prog])
|
||||
for line in sout.splitlines():
|
||||
|
@ -30,11 +37,22 @@ def main():
|
|||
if dll_name.startswith('???'):
|
||||
print('Unknown DLL?')
|
||||
continue
|
||||
if dll_path.lower().startswith('/c/windows') or dll_path.lower().startswith('c:/windows'):
|
||||
# ldd on msys gives Unix-style paths, but mingw Python wants them Windows-style
|
||||
# Use cygpath to convert the paths, because both mingw and msys Python can handle them
|
||||
dll_path = subprocess.check_output(['cygpath', '-w', dll_path]).strip()
|
||||
if dll_path.lower().startswith('c:\\windows'):
|
||||
print('Skipping system DLL %s' % dll_path)
|
||||
continue
|
||||
print('Copying %s...' % dll_path)
|
||||
shutil.copyfile(dll_path, os.path.join(args.dest, dll_name))
|
||||
|
||||
dest_path = os.path.join(args.dest, dll_name)
|
||||
if os.path.normcase(os.path.realpath(dll_path)) == os.path.normcase(os.path.realpath(dest_path)):
|
||||
# If the DLL is already in the same folder as the executable,
|
||||
# ldd will return the path to that DLL and copyfile will raise an exception
|
||||
# because we try to copy a file over itself
|
||||
print('DLL %s is already next to executable. Skipping copy.' % dll_name)
|
||||
else:
|
||||
print('Copying %s...' % dll_path)
|
||||
shutil.copyfile(dll_path, dest_path)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Reference in New Issue