aboutsummaryrefslogtreecommitdiffstats
path: root/src/app
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2014-01-10 17:16:32 +0100
committerChristian Kandeler <christian.kandeler@digia.com>2014-01-16 16:51:48 +0100
commitf4b6d84baa16440812127099f7b03ec79f87bd2a (patch)
tree2f0e8a7959cc357684e887297faa4792b11facad /src/app
parent008992106eea60f0a63efc0978399c454fdab2ca (diff)
Move knowledge about Qt modules into libsetupqt.
In addition, we make less hard-coded assumptions than before, instead generating almost all modules dynamically from the respective Qt installation when setup-qt is being run. This way, qbs does not have to know about all the modules beforehand, and only the Qt modules that are actually present will have qbs counterparts, making it possible for project file authors to make use of soft dependencies for Qt modules. Task-number: QBS-479 Change-Id: Ie20d2acf249cd159ce4caff2ede4721ab879fad2 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'src/app')
-rw-r--r--src/app/qbs-setup-qt/setupqt.cpp57
1 files changed, 31 insertions, 26 deletions
diff --git a/src/app/qbs-setup-qt/setupqt.cpp b/src/app/qbs-setup-qt/setupqt.cpp
index 0d180ae5e..c04011e01 100644
--- a/src/app/qbs-setup-qt/setupqt.cpp
+++ b/src/app/qbs-setup-qt/setupqt.cpp
@@ -162,37 +162,45 @@ static Version extractVersion(const QString &versionString)
return v;
}
+typedef QMap<QByteArray, QByteArray> QueryMap;
+
+static QString pathQueryValue(const QueryMap &queryMap, const QByteArray &key)
+{
+ return QDir::fromNativeSeparators(QString::fromLocal8Bit(queryMap.value(key)));
+}
+
QtEnvironment SetupQt::fetchEnvironment(const QString &qmakePath)
{
QtEnvironment qtEnvironment;
- QMap<QByteArray, QByteArray> queryOutput = qmakeQueryOutput(qmakePath);
-
- qtEnvironment.installPrefixPath =
- QString::fromLocal8Bit(queryOutput.value("QT_INSTALL_PREFIX"));
- qtEnvironment.documentationPath = QString::fromLocal8Bit(queryOutput.value("QT_INSTALL_DOCS"));
- qtEnvironment.includePath = QString::fromLocal8Bit(queryOutput.value("QT_INSTALL_HEADERS"));
- qtEnvironment.libraryPath = QString::fromLocal8Bit(queryOutput.value("QT_INSTALL_LIBS"));
- qtEnvironment.binaryPath = QString::fromLocal8Bit(queryOutput.value("QT_INSTALL_BINS"));
- qtEnvironment.documentationPath = QString::fromLocal8Bit(queryOutput.value("QT_INSTALL_DOCS"));
- qtEnvironment.pluginPath = QString::fromLocal8Bit(queryOutput.value("QT_INSTALL_PLUGINS"));
- qtEnvironment.qmlImportPath = QString::fromLocal8Bit(queryOutput.value("QT_INSTALL_IMPORTS"));
+ QueryMap queryOutput = qmakeQueryOutput(qmakePath);
+
+ qtEnvironment.installPrefixPath = pathQueryValue(queryOutput, "QT_INSTALL_PREFIX");
+ qtEnvironment.documentationPath = pathQueryValue(queryOutput, "QT_INSTALL_DOCS");
+ qtEnvironment.includePath = pathQueryValue(queryOutput, "QT_INSTALL_HEADERS");
+ qtEnvironment.libraryPath = pathQueryValue(queryOutput, "QT_INSTALL_LIBS");
+ qtEnvironment.binaryPath = pathQueryValue(queryOutput, "QT_INSTALL_BINS");
+ qtEnvironment.documentationPath = pathQueryValue(queryOutput, "QT_INSTALL_DOCS");
+ qtEnvironment.pluginPath = pathQueryValue(queryOutput, "QT_INSTALL_PLUGINS");
+ qtEnvironment.qmlImportPath = pathQueryValue(queryOutput, "QT_INSTALL_IMPORTS");
qtEnvironment.qtVersion = QString::fromLocal8Bit(queryOutput.value("QT_VERSION"));
const Version qtVersion = extractVersion(qtEnvironment.qtVersion);
- QByteArray mkspecsBasePath;
- QByteArray mkspecsBaseSrcPath;
+ QString mkspecsBaseSrcPath;
if (qtVersion.majorVersion >= 5) {
- mkspecsBasePath = queryOutput.value("QT_HOST_DATA") + "/mkspecs";
- mkspecsBaseSrcPath = queryOutput.value("QT_HOST_DATA/src") + "/mkspecs";
+ qtEnvironment.mkspecBasePath
+ = pathQueryValue(queryOutput, "QT_HOST_DATA") + QLatin1String("/mkspecs");
+ mkspecsBaseSrcPath
+ = pathQueryValue(queryOutput, "QT_HOST_DATA/src") + QLatin1String("/mkspecs");
} else {
- mkspecsBasePath = queryOutput.value("QT_INSTALL_DATA") + "/mkspecs";
+ qtEnvironment.mkspecBasePath
+ = pathQueryValue(queryOutput, "QT_INSTALL_DATA") + QLatin1String("/mkspecs");
}
- if (!QFile::exists(QString::fromLocal8Bit(mkspecsBasePath)))
+ if (!QFile::exists(qtEnvironment.mkspecBasePath))
throw ErrorInfo(tr("Cannot extract the mkspecs directory."));
- const QByteArray qconfigContent = readFileContent(QString::fromLocal8Bit(mkspecsBasePath)
+ const QByteArray qconfigContent = readFileContent(qtEnvironment.mkspecBasePath
+ QLatin1String("/qconfig.pri"));
qtEnvironment.qtMajorVersion = configVariable(qconfigContent,
QLatin1String("QT_MAJOR_VERSION")).toInt();
@@ -214,20 +222,18 @@ QtEnvironment SetupQt::fetchEnvironment(const QString &qmakePath)
if (qtVersion.majorVersion >= 5) {
const QString mkspecName = QString::fromLocal8Bit(queryOutput.value("QMAKE_XSPEC"));
qtEnvironment.mkspecName = mkspecName;
- qtEnvironment.mkspecPath = QString::fromLocal8Bit(mkspecsBasePath)
- + QLatin1Char('/') + mkspecName;
+ qtEnvironment.mkspecPath = qtEnvironment.mkspecBasePath + QLatin1Char('/') + mkspecName;
if (!mkspecsBaseSrcPath.isEmpty() && !QFile::exists(qtEnvironment.mkspecPath))
- qtEnvironment.mkspecPath = QString::fromLocal8Bit(mkspecsBaseSrcPath)
- + QLatin1Char('/') + mkspecName;
+ qtEnvironment.mkspecPath = mkspecsBaseSrcPath + QLatin1Char('/') + mkspecName;
} else {
if (HostOsInfo::isWindowsHost()) {
- const QByteArray fileContent = readFileContent(QString::fromLocal8Bit(mkspecsBasePath)
+ const QByteArray fileContent = readFileContent(qtEnvironment.mkspecBasePath
+ QLatin1String("/default/qmake.conf"));
qtEnvironment.mkspecPath = configVariable(fileContent,
QLatin1String("QMAKESPEC_ORIGINAL"));
} else {
- qtEnvironment.mkspecPath = QFileInfo(QString::fromLocal8Bit(mkspecsBasePath)
- + QLatin1String("/default")).symLinkTarget();
+ qtEnvironment.mkspecPath
+ = QFileInfo(qtEnvironment.mkspecBasePath + "/default").symLinkTarget();
}
qtEnvironment.mkspecName = qtEnvironment.mkspecPath;
int idx = qtEnvironment.mkspecName.lastIndexOf(QLatin1Char('/'));
@@ -286,7 +292,6 @@ QtEnvironment SetupQt::fetchEnvironment(const QString &qmakePath)
if (!QFileInfo(qtEnvironment.mkspecPath).exists())
throw ErrorInfo(tr("mkspec '%1' does not exist").arg(qtEnvironment.mkspecPath));
- qtEnvironment.mkspecPath = QDir::toNativeSeparators(qtEnvironment.mkspecPath);
return qtEnvironment;
}