diff options
author | El Mehdi Fekari <mfekari@rim.com> | 2013-06-12 14:40:30 +0200 |
---|---|---|
committer | Mehdi Fekari <mfekari@blackberry.com> | 2013-06-24 23:03:15 +0200 |
commit | 728fe7d7c0ea88c27f1436cfe75ad16f6082b601 (patch) | |
tree | 029bb779aa1b75ea10ea64da3ad0f7150c37a14a /src/plugins/qnx/qnxutils.cpp | |
parent | 6b2162f2a95bcba6ac7284a580f803d1485a6932 (diff) | |
download | qt-creator-728fe7d7c0ea88c27f1436cfe75ad16f6082b601.tar.gz |
Qnx: Add support for internal 10.2 NDKs
Some changes in the new NDK 10.2 break the setup of BlackBerry 10.
Main changes that the current patch covers:
* Qnx environment variables are evaluated when sourcing the bbndk-env script
and are no longer hard coded when istalling the NDK
* The version number is appended to the bbndk-env file name.
More eventual changes may come and we may need to directly
parse the ndk xml descriptor file.
Task-number: QTCREATORBUG-9403
Change-Id: Ie7daf7b0eaf2a49339775cacb9973062d6101afa
Reviewed-by: Tobias Nätterlund <tobias.naetterlund@kdab.com>
Reviewed-by: Nicolas Arnaud-Cormos <nicolas@kdab.com>
Diffstat (limited to 'src/plugins/qnx/qnxutils.cpp')
-rw-r--r-- | src/plugins/qnx/qnxutils.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/plugins/qnx/qnxutils.cpp b/src/plugins/qnx/qnxutils.cpp index f7a7104b6a..64eff9cea1 100644 --- a/src/plugins/qnx/qnxutils.cpp +++ b/src/plugins/qnx/qnxutils.cpp @@ -36,6 +36,7 @@ #include <QDir> #include <QDesktopServices> +#include <QDomDocument> using namespace Qnx; using namespace Qnx::Internal; @@ -99,6 +100,12 @@ QMultiMap<QString, QString> QnxUtils::parseEnvironmentFile(const QString &fileNa QString value = line.mid(equalIndex + 1); + // BASE_DIR variable is evaluated when souring the bbnk-env script + // BASE_DIR="$( cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )" + // We already know the NDK path so we can set the variable value + if (var == QLatin1String("BASE_DIR")) + value = QFileInfo(fileName).dir().absolutePath(); + if (Utils::HostOsInfo::isWindowsHost()) { QRegExp systemVarRegExp(QLatin1String("IF NOT DEFINED ([\\w\\d]+)\\s+set ([\\w\\d]+)=([\\w\\d]+)")); if (line.contains(systemVarRegExp)) { @@ -187,6 +194,14 @@ QString QnxUtils::envFilePath(const QString &ndkPath) else if (Utils::HostOsInfo::isAnyUnixHost()) envFile = ndkPath + QLatin1String("/bbndk-env.sh"); + if (!QFileInfo(envFile).exists()) { + QString version = ndkVersion(ndkPath); + version = version.replace(QLatin1Char('.'), QLatin1Char('_')); + if (Utils::HostOsInfo::isWindowsHost()) + envFile = ndkPath + QLatin1String("/bbndk-env_") + version + QLatin1String(".bat"); + else if (Utils::HostOsInfo::isAnyUnixHost()) + envFile = ndkPath + QLatin1String("/bbndk-env_") + version + QLatin1String(".sh"); + } return envFile; } @@ -237,3 +252,45 @@ QString QnxUtils::dataDirPath() return QString(); } +QString QnxUtils::qConfigPath() +{ + if (Utils::HostOsInfo::isMacHost() || Utils::HostOsInfo::isWindowsHost()) { + return dataDirPath() + QLatin1String("/BlackBerry Native SDK/qconfig"); + } else { + return dataDirPath() + QLatin1String("/bbndk/qconfig"); + } +} + +QString QnxUtils::ndkVersion(const QString &ndkPath) +{ + QString ndkConfigPath = qConfigPath(); + if (!QDir(ndkConfigPath).exists()) + return QString(); + + QFileInfoList ndkfileList = QDir(ndkConfigPath).entryInfoList(QStringList() << QLatin1String("*.xml"), + QDir::Files, QDir::Time); + foreach (const QFileInfo &ndkFile, ndkfileList) { + QFile xmlFile(ndkFile.absoluteFilePath()); + if (!xmlFile.open(QIODevice::ReadOnly)) + continue; + + QDomDocument doc; + if (!doc.setContent(&xmlFile)) // Skip error message + continue; + + QDomElement docElt = doc.documentElement(); + if (docElt.tagName() != QLatin1String("qnxSystemDefinition")) + continue; + + QDomElement childElt = docElt.firstChildElement(QLatin1String("installation")); + // The file contains only one installation node + if (!childElt.isNull()) { + // The file contains only one base node + QDomElement elt = childElt.firstChildElement(QLatin1String("base")); + if (!elt.text().compare(ndkPath, Utils::HostOsInfo::fileNameCaseSensitivity())) + return childElt.firstChildElement(QLatin1String("version")).text(); + } + } + + return QString(); +} |