Squish: Provide functions for getting paths inside Qt installation

Change-Id: I273304f0c6d451d28a256c99588479525eef95e4
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
This commit is contained in:
Christian Stenger
2016-06-01 10:56:14 +02:00
parent 48423414f6
commit b04b5e5d75
2 changed files with 57 additions and 3 deletions
+53
View File
@@ -23,6 +23,7 @@
#
############################################################################
import __builtin__
import operator
# for easier re-usage (because Python hasn't an enum type)
@@ -200,3 +201,55 @@ class Qt5Path:
else:
return map(os.path.expanduser, ["~/Qt5.2.1/5.2.1/clang_64" + path52,
"~/Qt5.3.1" + path53])
@staticmethod
def __preCheckAndExtractQtVersionStr__(target):
if target not in Targets.ALL_TARGETS:
raise Exception("Unexpected target '%s'" % str(target))
matcher = re.match("^Desktop (5\\d{2}).*$", Targets.getStringForTarget(target))
if matcher is None:
raise Exception("Currently this is supported for Desktop Qt5 only, got target '%s'"
% str(Targets.getStringForTarget(target)))
return matcher.group(1)
@staticmethod
def __createPlatformQtPath__(qt5Minor):
# special handling for Qt5.2
if qt5Minor == 2:
if platform.system() in ('Microsoft', 'Windows'):
return "C:/Qt/Qt5.2.1/5.2.1/msvc2010"
elif platform.system() == 'Linux':
if __is64BitOS__():
return os.path.expanduser("~/Qt5.2.1/5.2.1/gcc_64")
else:
return os.path.expanduser("~/Qt5.2.1/5.2.1/gcc")
else:
return os.path.expanduser("~/Qt5.2.1/5.2.1/clang_64")
# Qt5.3+
if platform.system() in ('Microsoft', 'Windows'):
return "C:/Qt/Qt5.%d.1" % qt5Minor
else:
return os.path.expanduser("~/Qt5.%d.1" % qt5Minor)
@staticmethod
def examplesPath(target):
qtVersionStr = Qt5Path.__preCheckAndExtractQtVersionStr__(target)
qtMinorVersion = __builtin__.int(qtVersionStr[1])
if qtMinorVersion == 2:
path = "examples"
else:
path = "Examples/Qt-5.%d" % qtMinorVersion
return os.path.join(Qt5Path.__createPlatformQtPath__(qtMinorVersion), path)
@staticmethod
def docsPath(target):
qtVersionStr = Qt5Path.__preCheckAndExtractQtVersionStr__(target)
qtMinorVersion = __builtin__.int(qtVersionStr[1])
if qtMinorVersion == 2:
path = "doc"
else:
path = "Docs/Qt-5.%d" % qtMinorVersion
return os.path.join(Qt5Path.__createPlatformQtPath__(qtMinorVersion), path)