From 13e8a6f5b247c17413a812eb07b482c04f9f4945 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Fri, 5 Jul 2019 08:46:10 +0100 Subject: qtcreator: Make paths work with cygwin Absolute paths in files created by GbuildToJson in Cygwin environment are Windows paths (like "C:/....'), while relative paths in the Python program executed in Cygwin are treated as Unix paths ('/cygdrive/c/....') which caused wrong relative paths to be generated by the call to 'os.relpath'. It would walk up to the root of the Windows path and then walk down the tree in the Unix file system path again. This converts the paths to absolute Windows paths first to avoid this issue. Change-Id: I2e3e6926e312d64aa18067933a5903ac7ad5d31a Reviewed-on: https://gerrit.libreoffice.org/75114 Tested-by: Jenkins Reviewed-by: Michael Weghorn (cherry picked from commit 22c6ffc274a4dd29fdd6c0d02415139502bddae6) --- bin/gbuild-to-ide | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bin/gbuild-to-ide b/bin/gbuild-to-ide index e76486c359b0..6e1717b37c80 100755 --- a/bin/gbuild-to-ide +++ b/bin/gbuild-to-ide @@ -9,6 +9,7 @@ # import argparse +import ntpath import os import os.path import shutil @@ -1467,6 +1468,14 @@ class QtCreatorIntegrationGenerator(IdeIntegrationGenerator): lib_folder = os.path.relpath(lib.location, self.base_folder) def lopath(path): + if platform =="cygwin": + # absolute paths from GbuildToJson are Windows paths, + # so convert everything to such ones + abs_path = path + if not ntpath.isabs(abs_path): + abs_path = ntpath.join(self.gbuildparser.srcdir, path) + return ntpath.relpath(abs_path, lib.location).replace('\\', '/') + return os.path.relpath(path, lib.location) defines_list = [] -- cgit v1.2.3