From 728fe7d7c0ea88c27f1436cfe75ad16f6082b601 Mon Sep 17 00:00:00 2001 From: El Mehdi Fekari Date: Wed, 12 Jun 2013 14:40:30 +0200 Subject: [PATCH] Qnx: Add support for internal 10.2 NDKs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Nicolas Arnaud-Cormos --- src/plugins/qnx/qnxutils.cpp | 57 ++++++++++++++++++++++++++++++++++++ src/plugins/qnx/qnxutils.h | 2 ++ 2 files changed, 59 insertions(+) diff --git a/src/plugins/qnx/qnxutils.cpp b/src/plugins/qnx/qnxutils.cpp index f7a7104b6aa..64eff9cea15 100644 --- a/src/plugins/qnx/qnxutils.cpp +++ b/src/plugins/qnx/qnxutils.cpp @@ -36,6 +36,7 @@ #include #include +#include using namespace Qnx; using namespace Qnx::Internal; @@ -99,6 +100,12 @@ QMultiMap 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(); +} diff --git a/src/plugins/qnx/qnxutils.h b/src/plugins/qnx/qnxutils.h index 571a11f6441..f12518fd312 100644 --- a/src/plugins/qnx/qnxutils.h +++ b/src/plugins/qnx/qnxutils.h @@ -58,6 +58,8 @@ public: static void prependQnxMapToEnvironment(const QMultiMap &qnxMap, Utils::Environment &env); static Utils::FileName executableWithExtension(const Utils::FileName &fileName); static QString dataDirPath(); + static QString qConfigPath(); + static QString ndkVersion(const QString& ndkPath); }; } // namespace Internal