diff options
Diffstat (limited to 'src/plugins/qnx/qnxutils.cpp')
-rw-r--r-- | src/plugins/qnx/qnxutils.cpp | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/src/plugins/qnx/qnxutils.cpp b/src/plugins/qnx/qnxutils.cpp index 64eff9cea1..dadacceb0c 100644 --- a/src/plugins/qnx/qnxutils.cpp +++ b/src/plugins/qnx/qnxutils.cpp @@ -100,10 +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 (and BASE_DIR_REPLACED in some recent internal versions) 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")) + // TODO: Do not parse bbnk-env! + if (var == QLatin1String("BASE_DIR") || var == QLatin1String("BASE_DIR_REPLACED")) value = QFileInfo(fileName).dir().absolutePath(); if (Utils::HostOsInfo::isWindowsHost()) { @@ -117,8 +119,7 @@ QMultiMap<QString, QString> QnxUtils::parseEnvironmentFile(const QString &fileNa else value = systemVarRegExp.cap(3); } - } - else if (Utils::HostOsInfo::isAnyUnixHost()) { + } else if (Utils::HostOsInfo::isAnyUnixHost()) { QRegExp systemVarRegExp(QLatin1String("\\$\\{([\\w\\d]+):=([\\w\\d]+)\\}")); // to match e.g. "${QNX_HOST_VERSION:=10_0_9_52}" if (value.contains(systemVarRegExp)) { Utils::Environment sysEnv = Utils::Environment::systemEnvironment(); @@ -186,7 +187,7 @@ bool QnxUtils::isValidNdkPath(const QString &ndkPath) return (QFileInfo(envFilePath(ndkPath)).exists()); } -QString QnxUtils::envFilePath(const QString &ndkPath) +QString QnxUtils::envFilePath(const QString &ndkPath, const QString &targetVersion) { QString envFile; if (Utils::HostOsInfo::isWindowsHost()) @@ -195,7 +196,7 @@ QString QnxUtils::envFilePath(const QString &ndkPath) envFile = ndkPath + QLatin1String("/bbndk-env.sh"); if (!QFileInfo(envFile).exists()) { - QString version = ndkVersion(ndkPath); + QString version = targetVersion.isEmpty() ? defaultTargetVersion(ndkPath) : targetVersion; version = version.replace(QLatin1Char('.'), QLatin1Char('_')); if (Utils::HostOsInfo::isWindowsHost()) envFile = ndkPath + QLatin1String("/bbndk-env_") + version + QLatin1String(".bat"); @@ -261,11 +262,22 @@ QString QnxUtils::qConfigPath() } } -QString QnxUtils::ndkVersion(const QString &ndkPath) +QString QnxUtils::defaultTargetVersion(const QString &ndkPath) +{ + foreach (const NdkInstallInformation &ndkInfo, installedNdks()) { + if (!ndkInfo.path.compare(ndkPath, Utils::HostOsInfo::fileNameCaseSensitivity())) + return ndkInfo.version; + } + + return QString(); +} + +QList<NdkInstallInformation> QnxUtils::installedNdks() { + QList<NdkInstallInformation> ndkList; QString ndkConfigPath = qConfigPath(); if (!QDir(ndkConfigPath).exists()) - return QString(); + return ndkList; QFileInfoList ndkfileList = QDir(ndkConfigPath).entryInfoList(QStringList() << QLatin1String("*.xml"), QDir::Files, QDir::Time); @@ -286,11 +298,16 @@ QString QnxUtils::ndkVersion(const QString &ndkPath) // 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(); + NdkInstallInformation ndkInfo; + ndkInfo.path = childElt.firstChildElement(QLatin1String("base")).text(); + ndkInfo.name = childElt.firstChildElement(QLatin1String("name")).text(); + ndkInfo.host = childElt.firstChildElement(QLatin1String("host")).text(); + ndkInfo.target = childElt.firstChildElement(QLatin1String("target")).text(); + ndkInfo.version = childElt.firstChildElement(QLatin1String("version")).text(); + + ndkList.append(ndkInfo); } } - return QString(); + return ndkList; } |