forked from qt-creator/qt-creator
Qnx: Add a BlackBerry setup page to setup the plugin
Change-Id: I7a15f29d1b0d25f41c8bec7c907da7c60d59dcc1 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
committed by
Tobias Hunger
parent
f3b353545a
commit
37527b559c
@@ -30,9 +30,10 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "qnxutils.h"
|
||||
|
||||
#include "qnxabstractqtversion.h"
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
|
||||
#include <QDir>
|
||||
|
||||
using namespace Qnx;
|
||||
@@ -73,3 +74,142 @@ QStringList QnxUtils::searchPaths(QnxAbstractQtVersion *qtVersion)
|
||||
|
||||
return searchPaths;
|
||||
}
|
||||
|
||||
QMultiMap<QString, QString> QnxUtils::parseEnvironmentFile(const QString &fileName)
|
||||
{
|
||||
QMultiMap<QString, QString> result;
|
||||
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
return result;
|
||||
|
||||
QTextStream str(&file);
|
||||
QMap<QString, QString> fileContent;
|
||||
while (!str.atEnd()) {
|
||||
QString line = str.readLine();
|
||||
if (!line.contains(QLatin1Char('=')))
|
||||
continue;
|
||||
|
||||
int equalIndex = line.indexOf(QLatin1Char('='));
|
||||
QString var = line.left(equalIndex);
|
||||
//Remove set in front
|
||||
if (var.startsWith(QLatin1String("set ")))
|
||||
var = var.right(var.size() - 4);
|
||||
|
||||
QString value = line.mid(equalIndex + 1);
|
||||
|
||||
if (Utils::HostOsInfo::isWindowsHost()) {
|
||||
QRegExp systemVarRegExp(QLatin1String("IF NOT DEFINED ([\\w\\d]+)\\s+set ([\\w\\d]+)=([\\w\\d]+)"));
|
||||
if (line.contains(systemVarRegExp)) {
|
||||
var = systemVarRegExp.cap(2);
|
||||
Utils::Environment sysEnv = Utils::Environment::systemEnvironment();
|
||||
QString sysVar = systemVarRegExp.cap(1);
|
||||
if (sysEnv.hasKey(sysVar))
|
||||
value = sysEnv.value(sysVar);
|
||||
else
|
||||
value = systemVarRegExp.cap(3);
|
||||
}
|
||||
}
|
||||
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();
|
||||
QString sysVar = systemVarRegExp.cap(1);
|
||||
if (sysEnv.hasKey(sysVar))
|
||||
value = sysEnv.value(sysVar);
|
||||
else
|
||||
value = systemVarRegExp.cap(2);
|
||||
}
|
||||
}
|
||||
|
||||
if (value.startsWith(QLatin1Char('"')))
|
||||
value = value.mid(1);
|
||||
if (value.endsWith(QLatin1Char('"')))
|
||||
value = value.left(value.size() - 1);
|
||||
|
||||
fileContent[var] = value;
|
||||
}
|
||||
file.close();
|
||||
|
||||
QMapIterator<QString, QString> it(fileContent);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
QStringList values;
|
||||
if (Utils::HostOsInfo::isWindowsHost())
|
||||
values = it.value().split(QLatin1Char(';'));
|
||||
else if (Utils::HostOsInfo::isAnyUnixHost())
|
||||
values = it.value().split(QLatin1Char(':'));
|
||||
|
||||
QString key = it.key();
|
||||
foreach (const QString &value, values) {
|
||||
const QString ownKeyAsWindowsVar = QLatin1Char('%') + key + QLatin1Char('%');
|
||||
const QString ownKeyAsUnixVar = QLatin1Char('$') + key;
|
||||
if (value != ownKeyAsUnixVar && value != ownKeyAsWindowsVar) { // to ignore e.g. PATH=$PATH
|
||||
QString val = value;
|
||||
if (val.contains(QLatin1Char('%')) || val.contains(QLatin1Char('$'))) {
|
||||
QMapIterator<QString, QString> replaceIt(fileContent);
|
||||
while (replaceIt.hasNext()) {
|
||||
replaceIt.next();
|
||||
const QString replaceKey = replaceIt.key();
|
||||
if (replaceKey == key)
|
||||
continue;
|
||||
|
||||
const QString keyAsWindowsVar = QLatin1Char('%') + replaceKey + QLatin1Char('%');
|
||||
const QString keyAsUnixVar = QLatin1Char('$') + replaceKey;
|
||||
if (val.contains(keyAsWindowsVar))
|
||||
val.replace(keyAsWindowsVar, replaceIt.value());
|
||||
if (val.contains(keyAsUnixVar))
|
||||
val.replace(keyAsUnixVar, replaceIt.value());
|
||||
}
|
||||
}
|
||||
result.insert(key, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!result.contains(QLatin1String("CPUVARDIR")))
|
||||
result.insert(QLatin1String("CPUVARDIR"), QLatin1String("armle-v7"));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool QnxUtils::isValidNdkPath(const QString &ndkPath)
|
||||
{
|
||||
return (QFileInfo(envFilePath(ndkPath)).exists());
|
||||
}
|
||||
|
||||
QString QnxUtils::envFilePath(const QString &ndkPath)
|
||||
{
|
||||
QString envFile;
|
||||
if (Utils::HostOsInfo::isWindowsHost())
|
||||
envFile = ndkPath + QLatin1String("/bbndk-env.bat");
|
||||
else if (Utils::HostOsInfo::isAnyUnixHost())
|
||||
envFile = ndkPath + QLatin1String("/bbndk-env.sh");
|
||||
|
||||
return envFile;
|
||||
}
|
||||
|
||||
void QnxUtils::prependQnxMapToEnvironment(const QMultiMap<QString, QString> &qnxMap, Utils::Environment &env)
|
||||
{
|
||||
QMultiMap<QString, QString>::const_iterator it;
|
||||
QMultiMap<QString, QString>::const_iterator end(qnxMap.constEnd());
|
||||
for (it = qnxMap.constBegin(); it != end; ++it) {
|
||||
const QString key = it.key();
|
||||
const QString value = it.value();
|
||||
|
||||
if (key == QLatin1String("PATH"))
|
||||
env.prependOrSetPath(value);
|
||||
else if (key == QLatin1String("LD_LIBRARY_PATH"))
|
||||
env.prependOrSetLibrarySearchPath(value);
|
||||
else
|
||||
env.set(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
Utils::FileName QnxUtils::executableWithExtension(const Utils::FileName &fileName)
|
||||
{
|
||||
Utils::FileName result = fileName;
|
||||
if (Utils::HostOsInfo::isWindowsHost())
|
||||
result.append(QLatin1String(".exe"));
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user