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:
Mehdi Fekari
2013-01-09 09:23:37 -05:00
committed by Tobias Hunger
parent f3b353545a
commit 37527b559c
16 changed files with 1051 additions and 150 deletions

View File

@@ -0,0 +1,342 @@
/**************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion
**
** Contact: Research In Motion (blackberry-qt@qnx.com)
** Contact: KDAB (info@kdab.com)
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "blackberryconfiguration.h"
#include "blackberryqtversion.h"
#include "qnxutils.h"
#include <coreplugin/icore.h>
#include <qtsupport/baseqtversion.h>
#include <qtsupport/qtversionmanager.h>
#include <qtsupport/qtkitinformation.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/kitmanager.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/gcctoolchain.h>
#include <projectexplorer/toolchainmanager.h>
#include <qt4projectmanager/qmakekitinformation.h>
#include <debugger/debuggerkitinformation.h>
#include <utils/persistentsettings.h>
#include <utils/hostosinfo.h>
#include <QFileInfo>
#include <QDir>
#include <QMessageBox>
namespace Qnx {
namespace Internal {
namespace {
const QLatin1String SettingsGroup("BlackBerryConfiguration");
const QLatin1String NDKLocationKey("NDKLocation");
}
BlackBerryConfiguration::BlackBerryConfiguration(QObject *parent)
:QObject(parent)
{
loadSetting();
connect(Core::ICore::instance(), SIGNAL(saveSettingsRequested()), this, SLOT(saveSetting()));
}
bool BlackBerryConfiguration::setConfig(const QString &ndkPath)
{
if (ndkPath.isEmpty())
return false;
m_config.ndkPath = ndkPath;
m_config.qnxEnv = QnxUtils::parseEnvironmentFile(QnxUtils::envFilePath(ndkPath));
QString ndkTarget = m_config.qnxEnv.value(QLatin1String("QNX_TARGET"));
QString cpuDir = m_config.qnxEnv.value(QLatin1String("CPUVARDIR"));
QString sep = QString::fromLatin1("%1qnx6").arg(QDir::separator());
m_config.targetName = ndkTarget.split(sep).first().split(QDir::separator()).last();
QString sRootDir = QString::fromLatin1("%1%2%3").arg(ndkTarget, QDir::separator(), cpuDir);
if (QDir(sRootDir).exists())
m_config.sysRoot = Utils::FileName::fromString(sRootDir);
QString qnxHost = m_config.qnxEnv.value(QLatin1String("QNX_HOST"));
Utils::FileName qmakePath = QnxUtils::executableWithExtension(Utils::FileName::fromString(qnxHost + QLatin1String("/usr/bin/qmake")));
Utils::FileName gccPath = QnxUtils::executableWithExtension(Utils::FileName::fromString(qnxHost + QLatin1String("/usr/bin/qcc")));
Utils::FileName deviceGdbPath = QnxUtils::executableWithExtension(Utils::FileName::fromString(qnxHost + QLatin1String("/usr/bin/ntoarm-gdb")));
Utils::FileName simulatorGdbPath = QnxUtils::executableWithExtension(Utils::FileName::fromString(qnxHost + QLatin1String("/usr/bin/ntox86-gdb")));
if (!qmakePath.toFileInfo().exists() || !gccPath.toFileInfo().exists()
|| !deviceGdbPath.toFileInfo().exists() || !simulatorGdbPath.toFileInfo().exists() ) {
QString errorMessage = tr("The following errors occurred while setting up BB10 Configuration: \n");
if (!qmakePath.toFileInfo().exists())
errorMessage += tr("- No Qt version found\n");
if (!gccPath.toFileInfo().exists())
errorMessage += tr("- No GCC compiler found\n");
if (!deviceGdbPath.toFileInfo().exists())
errorMessage += tr("- No Gdb debugger found for BB10 Device\n");
if (!simulatorGdbPath.toFileInfo().exists())
errorMessage += tr("- No Gdb debugger found for BB10 Simulator");
QMessageBox::warning(0, tr("Cannot setup BB10 Configuartion"),
errorMessage, QMessageBox::Ok);
return false;
}
m_config.qmakeBinaryFile = qmakePath;
m_config.gccCompiler = gccPath;
m_config.deviceDebuger = deviceGdbPath;
m_config.simulatorDebuger = simulatorGdbPath;
return true;
}
void BlackBerryConfiguration::setupConfiguration(const QString &ndkPath)
{
if (ndkPath.isEmpty())
return;
if (setConfig(ndkPath)) {
QtSupport::BaseQtVersion *qtVersion = createQtVersion();
ProjectExplorer::GccToolChain *tc = createGccToolChain();
ProjectExplorer::Kit *deviceKit = createKit(ArmLeV7, qtVersion, tc);
ProjectExplorer::Kit *simulatorKit = createKit(X86, qtVersion, tc);
if (qtVersion && tc && deviceKit && simulatorKit) {
tc->setTargetAbi(qtVersion->qtAbis().first());
// register
QtSupport::QtVersionManager::instance()->addVersion(qtVersion);
ProjectExplorer::ToolChainManager::instance()->registerToolChain(tc);
ProjectExplorer::KitManager::instance()->registerKit(deviceKit);
ProjectExplorer::KitManager::instance()->registerKit(simulatorKit);
emit updated();
}
}
}
void BlackBerryConfiguration::cleanConfiguration()
{
QtSupport::BaseQtVersion *version = QtSupport::QtVersionManager::instance()->qtVersionForQMakeBinary(m_config.qmakeBinaryFile);
if (version) {
foreach (ProjectExplorer::Kit *kit, ProjectExplorer::KitManager::instance()->kits()) {
if (version == QtSupport::QtKitInformation::qtVersion(kit))
ProjectExplorer::KitManager::instance()->deregisterKit(kit);
}
QtSupport::QtVersionManager::instance()->removeVersion(version);
}
foreach (ProjectExplorer::ToolChain* tc, ProjectExplorer::ToolChainManager::instance()->toolChains()) {
if (tc->compilerCommand() == m_config.gccCompiler)
ProjectExplorer::ToolChainManager::instance()->deregisterToolChain(tc);
}
BlackBerryConfig conf;
m_config = conf;
emit updated();
clearSetting();
}
QtSupport::BaseQtVersion *BlackBerryConfiguration::createQtVersion()
{
if (m_config.qmakeBinaryFile.isEmpty())
return 0;
QString cpuDir = m_config.qnxEnv.value(QLatin1String("CPUVARDIR"));
QtSupport::BaseQtVersion *version = QtSupport::QtVersionManager::instance()->qtVersionForQMakeBinary(m_config.qmakeBinaryFile);
if (version) {
QMessageBox::warning(0, tr("Qt known"),
tr("This Qt version was already registered"), QMessageBox::Ok);
return version;
}
version = new BlackBerryQtVersion(QnxUtils::cpudirToArch(cpuDir), m_config.qmakeBinaryFile, false, QString(), m_config.ndkPath);
if (!version) {
QMessageBox::warning(0, tr("Qt not valid"),
tr("Unable to add BlackBerry Qt version"), QMessageBox::Ok);
return 0;
}
version->setDisplayName(QString::fromLatin1("Qt BlackBerry 10 (%1)").arg(m_config.targetName));
return version;
}
ProjectExplorer::GccToolChain *BlackBerryConfiguration::createGccToolChain()
{
if (m_config.qmakeBinaryFile.isEmpty() || m_config.gccCompiler.isEmpty())
return 0;
foreach (ProjectExplorer::ToolChain* tc, ProjectExplorer::ToolChainManager::instance()->toolChains()) {
if (tc->compilerCommand() == m_config.gccCompiler) {
QMessageBox::warning(0, tr("Compiler known"),
tr("This Compiler was already registered"), QMessageBox::Ok);
return dynamic_cast<ProjectExplorer::GccToolChain*>(tc);
}
}
ProjectExplorer::GccToolChain* tc = new ProjectExplorer::GccToolChain(QLatin1String(ProjectExplorer::Constants::GCC_TOOLCHAIN_ID), false);
tc->setDisplayName(QString::fromLatin1("GCC BlackBerry 10 (%1)").arg(m_config.targetName));
tc->setCompilerCommand(m_config.gccCompiler);
return tc;
}
ProjectExplorer::Kit *BlackBerryConfiguration::createKit(QnxArchitecture arch, QtSupport::BaseQtVersion *qtVersion, ProjectExplorer::GccToolChain *tc)
{
if (!qtVersion || !tc || m_config.targetName.isEmpty())
return 0;
// Check if an identical kit already exists
foreach (ProjectExplorer::Kit *kit, ProjectExplorer::KitManager::instance()->kits())
{
if (QtSupport::QtKitInformation::qtVersion(kit) == qtVersion && ProjectExplorer::ToolChainKitInformation::toolChain(kit) == tc
&& ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(kit) == Constants::QNX_BB_OS_TYPE
&& ProjectExplorer::SysRootKitInformation::sysRoot(kit) == m_config.sysRoot) {
if ((arch == X86 && Qt4ProjectManager::QmakeKitInformation::mkspec(kit).toString() == QString::fromLatin1("blackberry-x86-qcc")
&& Debugger::DebuggerKitInformation::debuggerCommand(kit) == m_config.simulatorDebuger)
|| (arch == ArmLeV7 && Debugger::DebuggerKitInformation::debuggerCommand(kit) == m_config.deviceDebuger)) {
QMessageBox::warning(0, tr("Kit Known"),
tr("This Kit was already registered"), QMessageBox::Ok);
return kit;
}
}
}
ProjectExplorer::Kit *kit = new ProjectExplorer::Kit;
QtSupport::QtKitInformation::setQtVersion(kit, qtVersion);
ProjectExplorer::ToolChainKitInformation::setToolChain(kit, tc);
if (arch == X86) {
Debugger::DebuggerKitInformation::setDebuggerCommand(kit, m_config.simulatorDebuger);
Qt4ProjectManager::QmakeKitInformation::setMkspec(kit, Utils::FileName::fromString(QString::fromLatin1("blackberry-x86-qcc")));
// TODO: Check if the name already exists(?)
kit->setDisplayName(tr("BlackBerry 10 (%1) - Simulator").arg(m_config.targetName));
} else {
Debugger::DebuggerKitInformation::setDebuggerCommand(kit, m_config.deviceDebuger);
kit->setDisplayName(tr("BlackBerry 10 (%1)").arg(m_config.targetName));
}
ProjectExplorer::DeviceTypeKitInformation::setDeviceTypeId(kit, Constants::QNX_BB_OS_TYPE);
ProjectExplorer::SysRootKitInformation::setSysRoot(kit, m_config.sysRoot);
return kit;
}
void BlackBerryConfiguration::loadSetting()
{
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(SettingsGroup);
setConfig(settings->value(NDKLocationKey).toString());
settings->endGroup();
}
void BlackBerryConfiguration::saveSetting()
{
if (m_config.ndkPath.isEmpty())
return;
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(SettingsGroup);
settings->setValue(NDKLocationKey, m_config.ndkPath);
settings->endGroup();
}
void BlackBerryConfiguration::clearSetting()
{
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(SettingsGroup);
settings->remove(NDKLocationKey);
settings->endGroup();
}
BlackBerryConfiguration &BlackBerryConfiguration::instance()
{
if (m_instance == 0)
m_instance = new BlackBerryConfiguration();
return *m_instance;
}
QString BlackBerryConfiguration::ndkPath() const
{
return m_config.ndkPath;
}
QString BlackBerryConfiguration::targetName() const
{
return m_config.targetName;
}
BlackBerryConfig BlackBerryConfiguration::config() const
{
return m_config;
}
Utils::FileName BlackBerryConfiguration::qmakePath() const
{
return m_config.qmakeBinaryFile;
}
Utils::FileName BlackBerryConfiguration::gccPath() const
{
return m_config.gccCompiler;
}
Utils::FileName BlackBerryConfiguration::deviceGdbPath() const
{
return m_config.deviceDebuger;
}
Utils::FileName BlackBerryConfiguration::simulatorGdbPath() const
{
return m_config.simulatorDebuger;
}
Utils::FileName BlackBerryConfiguration::sysRoot() const
{
return m_config.sysRoot;
}
// TODO: QnxUtils::parseEnvFile() and qnxEnv() to return Util::Enviroment instead(?)
QMultiMap<QString, QString> BlackBerryConfiguration::qnxEnv() const
{
return m_config.qnxEnv;
}
BlackBerryConfiguration* BlackBerryConfiguration::m_instance = 0;
} // namespace Internal
} // namespace Qnx

View File

@@ -0,0 +1,104 @@
/**************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion
**
** Contact: Research In Motion (blackberry-qt@qnx.com)
** Contact: KDAB (info@kdab.com)
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef BLACKBERRYCONFIGURATIONS_H
#define BLACKBERRYCONFIGURATIONS_H
#include <qnxconstants.h>
#include <utils/environment.h>
#include <utils/fileutils.h>
#include <qtsupport/baseqtversion.h>
#include <projectexplorer/kit.h>
#include <projectexplorer/gcctoolchain.h>
#include <QSettings>
#include <QObject>
namespace Qnx {
namespace Internal {
class BlackBerryConfig
{
QString ndkPath;
QString targetName;
Utils::FileName qmakeBinaryFile;
Utils::FileName gccCompiler;
Utils::FileName deviceDebuger;
Utils::FileName simulatorDebuger;
Utils::FileName sysRoot;
QMultiMap<QString, QString> qnxEnv;
friend class BlackBerryConfiguration;
};
class BlackBerryConfiguration: public QObject
{
Q_OBJECT
public:
static BlackBerryConfiguration &instance();
BlackBerryConfig config() const;
Utils::FileName qmakePath() const;
Utils::FileName gccPath() const;
Utils::FileName deviceGdbPath() const;
Utils::FileName simulatorGdbPath() const;
Utils::FileName sysRoot() const;
QMultiMap<QString, QString> qnxEnv() const;
void setupConfiguration(const QString &ndkPath);
QString ndkPath() const;
QString targetName() const;
void loadSetting();
void clearSetting();
void cleanConfiguration();
public slots:
void saveSetting();
private:
BlackBerryConfiguration(QObject *parent = 0);
static BlackBerryConfiguration *m_instance;
BlackBerryConfig m_config;
bool setConfig(const QString &ndkPath);
QtSupport::BaseQtVersion* createQtVersion();
ProjectExplorer::GccToolChain* createGccToolChain();
ProjectExplorer::Kit* createKit(QnxArchitecture arch, QtSupport::BaseQtVersion* qtVersion, ProjectExplorer::GccToolChain* tc);
signals:
void updated();
};
} // namespace Internal
} // namespace Qnx
#endif // BLACKBERRYCONFIGURATIONS_H

View File

@@ -31,6 +31,7 @@
#include "blackberryqtversion.h" #include "blackberryqtversion.h"
#include "qnxutils.h"
#include "qnxconstants.h" #include "qnxconstants.h"
#include <utils/environment.h> #include <utils/environment.h>
@@ -42,110 +43,18 @@
using namespace Qnx; using namespace Qnx;
using namespace Qnx::Internal; using namespace Qnx::Internal;
namespace {
QMultiMap<QString, QString> 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()) {
// to match e.g. "${QNX_HOST_VERSION:=10_0_9_52}"
QRegExp systemVarRegExp(QLatin1String("\\$\\{([\\w\\d]+):=([\\w\\d]+)\\}"));
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();
const QStringList values
= it.value().split(Utils::HostOsInfo::pathListSeparator());
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);
}
}
}
return result;
}
}
BlackBerryQtVersion::BlackBerryQtVersion() BlackBerryQtVersion::BlackBerryQtVersion()
: QnxAbstractQtVersion() : QnxAbstractQtVersion()
{ {
} }
BlackBerryQtVersion::BlackBerryQtVersion(QnxArchitecture arch, const Utils::FileName &path, bool isAutoDetected, const QString &autoDetectionSource) BlackBerryQtVersion::BlackBerryQtVersion(QnxArchitecture arch, const Utils::FileName &path, bool isAutoDetected, const QString &autoDetectionSource, const QString &sdkPath)
: QnxAbstractQtVersion(arch, path, isAutoDetected, autoDetectionSource) : QnxAbstractQtVersion(arch, path, isAutoDetected, autoDetectionSource)
{ {
setDisplayName(defaultDisplayName(qtVersionString(), path, false)); if (QnxUtils::isValidNdkPath(sdkPath))
setSdkPath(sdkPath);
else
setDefaultSdkPath();
} }
BlackBerryQtVersion::~BlackBerryQtVersion() BlackBerryQtVersion::~BlackBerryQtVersion()
@@ -174,12 +83,20 @@ QMultiMap<QString, QString> BlackBerryQtVersion::environment() const
if (sdkPath().isEmpty()) if (sdkPath().isEmpty())
return QMultiMap<QString, QString>(); return QMultiMap<QString, QString>();
QString envFile; return QnxUtils::parseEnvironmentFile(QnxUtils::envFilePath(sdkPath()));
if (Utils::HostOsInfo::isWindowsHost()) }
envFile = sdkPath() + QLatin1String("/bbndk-env.bat");
else if (Utils::HostOsInfo::isAnyUnixHost()) void BlackBerryQtVersion::setDefaultSdkPath()
envFile = sdkPath() + QLatin1String("/bbndk-env.sh"); {
return parseEnvironmentFile(envFile); QHash<QString, QString> info = versionInfo();
QString qtHostPrefix;
if (info.contains(QLatin1String("QT_HOST_PREFIX")))
qtHostPrefix = info.value(QLatin1String("QT_HOST_PREFIX"));
else
return;
if (QnxUtils::isValidNdkPath(qtHostPrefix))
setSdkPath(qtHostPrefix);
} }
Core::FeatureSet BlackBerryQtVersion::availableFeatures() const Core::FeatureSet BlackBerryQtVersion::availableFeatures() const

View File

@@ -44,8 +44,9 @@ class BlackBerryQtVersion : public QnxAbstractQtVersion
public: public:
BlackBerryQtVersion(); BlackBerryQtVersion();
BlackBerryQtVersion(QnxArchitecture arch, const Utils::FileName &path, BlackBerryQtVersion(QnxArchitecture arch, const Utils::FileName &path,
bool isAutoDetected = false, bool isAutoDetected = false,
const QString &autoDetectionSource = QString()); const QString &autoDetectionSource = QString(),
const QString &sdkPath = QString());
BlackBerryQtVersion *clone() const; BlackBerryQtVersion *clone() const;
~BlackBerryQtVersion(); ~BlackBerryQtVersion();
@@ -61,6 +62,7 @@ public:
private: private:
QMultiMap<QString, QString> environment() const; QMultiMap<QString, QString> environment() const;
void setDefaultSdkPath();
}; };
} // namespace Internal } // namespace Internal

View File

@@ -0,0 +1,68 @@
/**************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion
**
** Contact: Research In Motion (blackberry-qt@qnx.com)
** Contact: KDAB (info@kdab.com)
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "blackberrysettingspage.h"
#include "blackberrysettingswidget.h"
#include "qnxconstants.h"
#include <projectexplorer/projectexplorerconstants.h>
#include <QCoreApplication>
namespace Qnx {
namespace Internal {
BlackBerrySettingsPage::BlackBerrySettingsPage(QObject *parent) :
Core::IOptionsPage(parent)
{
setId(QLatin1String(Constants::QNX_SETTINGS_ID));
setDisplayName(tr("BlackBerry"));
setCategory(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY);
setDisplayCategory(QCoreApplication::translate("BlackBerry",
Constants::QNX_SETTINGS_TR_CATEGORY));
}
QWidget *BlackBerrySettingsPage::createPage(QWidget *parent)
{
m_widget = new BlackBerrySettingsWidget(parent);
return m_widget;
}
void BlackBerrySettingsPage::apply()
{
}
void BlackBerrySettingsPage::finish()
{
}
} // namespace Internal
} // namespace Qnx

View File

@@ -0,0 +1,58 @@
/**************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion
**
** Contact: Research In Motion (blackberry-qt@qnx.com)
** Contact: KDAB (info@kdab.com)
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef BLACKBERRYSETTINGSPAGE_H
#define BLACKBERRYSETTINGSPAGE_H
#include <coreplugin/dialogs/ioptionspage.h>
namespace Qnx {
namespace Internal {
class BlackBerrySettingsWidget;
class BlackBerrySettingsPage : public Core::IOptionsPage
{
Q_OBJECT
public:
explicit BlackBerrySettingsPage(QObject *parent = 0);
QWidget *createPage(QWidget *parent);
void apply();
void finish();
private:
BlackBerrySettingsWidget *m_widget;
};
} // namespace Internal
} // namespace Qnx
#endif // BLACKBERRYSETTINGSPAGE_H

View File

@@ -0,0 +1,133 @@
/**************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion
**
** Contact: Research In Motion (blackberry-qt@qnx.com)
** Contact: KDAB (info@kdab.com)
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "blackberrysettingswidget.h"
#include "ui_blackberrysettingswidget.h"
#include "qnxutils.h"
#include <utils/pathchooser.h>
#include <coreplugin/icore.h>
#include <QMessageBox>
namespace Qnx {
namespace Internal {
BlackBerrySettingsWidget::BlackBerrySettingsWidget(QWidget *parent) :
QWidget(parent),
m_ui(new Ui_BlackBerrySettingsWidget)
{
m_bbConfig = &BlackBerryConfiguration::instance();
m_ui->setupUi(this);
m_ui->sdkPath->setExpectedKind(Utils::PathChooser::ExistingDirectory);
m_ui->sdkPath->setPath(m_bbConfig->ndkPath());
initInfoTable();
connect(m_ui->sdkPath, SIGNAL(changed(QString)), this, SLOT(checkSdkPath()));
connect(m_ui->removeButton, SIGNAL(clicked()), this, SLOT(cleanConfiguration()));
connect(m_bbConfig, SIGNAL(updated()), this, SLOT(updateInfoTable()));
}
void BlackBerrySettingsWidget::checkSdkPath()
{
if (!m_ui->sdkPath->path().isEmpty() &&
QnxUtils::isValidNdkPath(m_ui->sdkPath->path()))
m_bbConfig->setupConfiguration(m_ui->sdkPath->path());
}
void BlackBerrySettingsWidget::updateInfoTable()
{
QMultiMap<QString, QString> env = m_bbConfig->qnxEnv();
if (env.isEmpty()) {
// clear
clearInfoTable();
return;
}
m_infoModel->clear();
m_infoModel->setHorizontalHeaderItem(0, new QStandardItem(QString(QLatin1String("Variable"))));
m_infoModel->setHorizontalHeaderItem(1, new QStandardItem(QString(QLatin1String("Value"))));
m_ui->ndkInfosTableView->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents);
m_ui->ndkInfosTableView->horizontalHeader()->setStretchLastSection(true);
QMultiMap<QString, QString>::const_iterator it;
QMultiMap<QString, QString>::const_iterator end(env.constEnd());
for (it = env.constBegin(); it != end; ++it) {
const QString key = it.key();
const QString value = it.value();
QList <QStandardItem*> row;
row << new QStandardItem(key) << new QStandardItem(value);
m_infoModel->appendRow(row);
}
m_infoModel->appendRow( QList<QStandardItem*>() << new QStandardItem(QString(QLatin1String("QMAKE"))) << new QStandardItem(m_bbConfig->qmakePath().toString()));
m_infoModel->appendRow( QList<QStandardItem*>() << new QStandardItem(QString(QLatin1String("COMPILER"))) << new QStandardItem(m_bbConfig->gccPath().toString()));
m_ui->removeButton->setEnabled(true);
}
void BlackBerrySettingsWidget::clearInfoTable()
{
m_infoModel->clear();
m_ui->sdkPath->setPath(QString());
m_ui->removeButton->setEnabled(false);
}
void BlackBerrySettingsWidget::cleanConfiguration()
{
QMessageBox::StandardButton button =
QMessageBox::question(Core::ICore::mainWindow(),
tr("Clean BlackBerry 10 Configuration"),
tr("Are you sure you want to remove the current BlackBerry configuration?"),
QMessageBox::Yes | QMessageBox::No);
if (button == QMessageBox::Yes)
m_bbConfig->cleanConfiguration();
}
void BlackBerrySettingsWidget::initInfoTable()
{
m_infoModel = new QStandardItemModel(this);
m_ui->ndkInfosTableView->setModel(m_infoModel);
m_ui->ndkInfosTableView->verticalHeader()->hide();
m_ui->ndkInfosTableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
updateInfoTable();
}
} // namespace Internal
} // namespace Qnx

View File

@@ -0,0 +1,74 @@
/**************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion
**
** Contact: Research In Motion (blackberry-qt@qnx.com)
** Contact: KDAB (info@kdab.com)
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef BLACKBERRYSETTINGSWIDGET_H
#define BLACKBERRYSETTINGSWIDGET_H
#include "blackberryconfiguration.h"
#include <QWidget>
#include <QStandardItemModel>
namespace Qnx {
namespace Internal {
class Ui_BlackBerrySettingsWidget;
class BlackBerrySettingsWidget : public QWidget
{
Q_OBJECT
public:
explicit BlackBerrySettingsWidget(QWidget *parent = 0);
signals:
void sdkPathChanged();
public slots:
void checkSdkPath();
void updateInfoTable();
void clearInfoTable();
void cleanConfiguration();
private:
void initInfoTable();
QString m_sdkPath;
Ui_BlackBerrySettingsWidget *m_ui;
BlackBerryConfiguration *m_bbConfig;
QStandardItemModel *m_infoModel;
};
} // namespace Internal
} // namespeace Qnx
#endif // BLACKBERRYSETTINGSWIDGET_H

View File

@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Qnx::Internal::BlackBerrySettingsWidget</class>
<widget class="QWidget" name="Qnx::Internal::BlackBerrySettingsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>794</width>
<height>473</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>BlackBerry NDK Path </string>
</property>
</widget>
</item>
<item>
<widget class="Utils::PathChooser" name="sdkPath" native="true"/>
</item>
</layout>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="removeButton">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QTableView" name="ndkInfosTableView"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Utils::PathChooser</class>
<extends>QWidget</extends>
<header location="global">utils/pathchooser.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -52,7 +52,10 @@ SOURCES += qnxplugin.cpp \
qnxdeviceconfiguration.cpp \ qnxdeviceconfiguration.cpp \
blackberrydeployinformation.cpp \ blackberrydeployinformation.cpp \
pathchooserdelegate.cpp \ pathchooserdelegate.cpp \
blackberryabstractdeploystep.cpp blackberryabstractdeploystep.cpp \
blackberrysettingswidget.cpp \
blackberrysettingspage.cpp \
blackberryconfiguration.cpp
HEADERS += qnxplugin.h\ HEADERS += qnxplugin.h\
qnxconstants.h \ qnxconstants.h \
@@ -101,7 +104,10 @@ HEADERS += qnxplugin.h\
qnxdeviceconfiguration.h \ qnxdeviceconfiguration.h \
blackberrydeployinformation.h \ blackberrydeployinformation.h \
pathchooserdelegate.h \ pathchooserdelegate.h \
blackberryabstractdeploystep.h blackberryabstractdeploystep.h \
blackberrysettingswidget.h \
blackberrysettingspage.h \
blackberryconfiguration.h
FORMS += \ FORMS += \
blackberrydeviceconfigurationwizardsetuppage.ui \ blackberrydeviceconfigurationwizardsetuppage.ui \
@@ -110,7 +116,8 @@ FORMS += \
blackberrydeployconfigurationwidget.ui \ blackberrydeployconfigurationwidget.ui \
blackberrydeviceconfigurationwidget.ui \ blackberrydeviceconfigurationwidget.ui \
qnxbaseqtconfigwidget.ui \ qnxbaseqtconfigwidget.ui \
bardescriptorfileimagewizardpage.ui bardescriptorfileimagewizardpage.ui \
blackberrysettingswidget.ui
RESOURCES += \ RESOURCES += \
qnx.qrc qnx.qrc

View File

@@ -30,9 +30,10 @@
****************************************************************************/ ****************************************************************************/
#include "qnxabstractqtversion.h" #include "qnxabstractqtversion.h"
#include "qnxbaseqtconfigwidget.h" #include "qnxbaseqtconfigwidget.h"
#include "qnxutils.h"
#include <utils/environment.h> #include <utils/environment.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
@@ -51,7 +52,6 @@ QnxAbstractQtVersion::QnxAbstractQtVersion(QnxArchitecture arch, const Utils::Fi
: QtSupport::BaseQtVersion(path, isAutoDetected, autoDetectionSource) : QtSupport::BaseQtVersion(path, isAutoDetected, autoDetectionSource)
, m_arch(arch) , m_arch(arch)
{ {
setDefaultSdkPath();
} }
QnxArchitecture QnxAbstractQtVersion::architecture() const QnxArchitecture QnxAbstractQtVersion::architecture() const
@@ -69,7 +69,6 @@ QString QnxAbstractQtVersion::archString() const
case UnknownArch: case UnknownArch:
return QString(); return QString();
} }
return QString(); return QString();
} }
@@ -97,25 +96,24 @@ QList<ProjectExplorer::Abi> QnxAbstractQtVersion::detectQtAbis() const
void QnxAbstractQtVersion::addToEnvironment(const ProjectExplorer::Kit *k, Utils::Environment &env) const void QnxAbstractQtVersion::addToEnvironment(const ProjectExplorer::Kit *k, Utils::Environment &env) const
{ {
QtSupport::BaseQtVersion::addToEnvironment(k, env); QtSupport::BaseQtVersion::addToEnvironment(k, env);
updateEnvironment();
QnxUtils::prependQnxMapToEnvironment(m_envMap, env);
env.prependOrSetLibrarySearchPath(versionInfo().value(QLatin1String("QT_INSTALL_LIBS")));
}
if (!m_environmentUpToDate) Utils::Environment QnxAbstractQtVersion::qmakeRunEnvironment() const
updateEnvironment(); {
if (!m_environmentUpToDate && !sdkPath().isEmpty())
QMultiMap<QString, QString>::const_iterator it; {
QMultiMap<QString, QString>::const_iterator end(m_envMap.constEnd()); // TODO: return Utils::Environment instead(?)
for (it = m_envMap.constBegin(); it != end; ++it) { m_envMap = QnxUtils::parseEnvironmentFile(QnxUtils::envFilePath(sdkPath()));
const QString key = it.key(); m_environmentUpToDate = true;
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);
} }
env.prependOrSetLibrarySearchPath(versionInfo().value(QLatin1String("QT_INSTALL_LIBS"))); Utils::Environment env = Utils::Environment::systemEnvironment();
QnxUtils::prependQnxMapToEnvironment(m_envMap, env);
return env;
} }
QString QnxAbstractQtVersion::sdkPath() const QString QnxAbstractQtVersion::sdkPath() const
@@ -134,8 +132,10 @@ void QnxAbstractQtVersion::setSdkPath(const QString &sdkPath)
void QnxAbstractQtVersion::updateEnvironment() const void QnxAbstractQtVersion::updateEnvironment() const
{ {
m_envMap = environment(); if (!m_environmentUpToDate) {
m_environmentUpToDate = true; m_envMap = environment();
m_environmentUpToDate = true;
}
} }
QString QnxAbstractQtVersion::qnxHost() const QString QnxAbstractQtVersion::qnxHost() const
@@ -171,20 +171,3 @@ QString QnxAbstractQtVersion::invalidReason() const
return QtSupport::BaseQtVersion::invalidReason(); return QtSupport::BaseQtVersion::invalidReason();
} }
void QnxAbstractQtVersion::setDefaultSdkPath()
{
QHash<QString, QString> info = versionInfo();
QString qtHostPrefix;
if (info.contains(QLatin1String("QT_HOST_PREFIX")))
qtHostPrefix = info.value(QLatin1String("QT_HOST_PREFIX"));
else
return;
QString envFile;
if (Utils::HostOsInfo::isWindowsHost())
envFile = qtHostPrefix + QLatin1String("/bbndk-env.bat");
else if (Utils::HostOsInfo::isAnyUnixHost())
envFile = qtHostPrefix + QLatin1String("/bbndk-env.sh");
if (QFileInfo(envFile).exists())
setSdkPath(qtHostPrefix);
}

View File

@@ -63,6 +63,7 @@ public:
QList<ProjectExplorer::Abi> detectQtAbis() const; QList<ProjectExplorer::Abi> detectQtAbis() const;
void addToEnvironment(const ProjectExplorer::Kit *k, Utils::Environment &env) const; void addToEnvironment(const ProjectExplorer::Kit *k, Utils::Environment &env) const;
Utils::Environment qmakeRunEnvironment() const;
QtSupport::QtConfigWidget *createConfigurationWidget() const; QtSupport::QtConfigWidget *createConfigurationWidget() const;
@@ -70,17 +71,15 @@ public:
QString invalidReason() const; QString invalidReason() const;
virtual QString sdkDescription() const = 0; virtual QString sdkDescription() const = 0;
void setDefaultSdkPath();
protected: protected:
QString sdkPath() const; QString sdkPath() const;
void setSdkPath(const QString &sdkPath);
private: private:
void updateEnvironment() const; void updateEnvironment() const;
virtual QMultiMap<QString, QString> environment() const = 0; virtual QMultiMap<QString, QString> environment() const = 0;
void setSdkPath(const QString &sdkPath);
QnxArchitecture m_arch; QnxArchitecture m_arch;
QString m_sdkPath; QString m_sdkPath;

View File

@@ -32,6 +32,8 @@
#ifndef QNX_QNXCONSTANTS_H #ifndef QNX_QNXCONSTANTS_H
#define QNX_QNXCONSTANTS_H #define QNX_QNXCONSTANTS_H
#include <QtGlobal>
namespace Qnx { namespace Qnx {
enum QnxArchitecture { enum QnxArchitecture {
@@ -86,6 +88,9 @@ const char QNX_BB_PLATFORM_NAME[] = "BlackBerry";
const char QNX_DEBUG_EXECUTABLE[] = "pdebug"; const char QNX_DEBUG_EXECUTABLE[] = "pdebug";
const char QNX_SETTINGS_ID[] = "ZZ.Qnx Configuration";
const char QNX_SETTINGS_TR_CATEGORY[] = QT_TRANSLATE_NOOP("BlackBerry", "BlackBerry");
} // namespace Constants } // namespace Constants
} // namespace Qnx } // namespace Qnx

View File

@@ -46,6 +46,7 @@
#include "qnxrunconfigurationfactory.h" #include "qnxrunconfigurationfactory.h"
#include "qnxqtversionfactory.h" #include "qnxqtversionfactory.h"
#include "blackberrywizardextension.h" #include "blackberrywizardextension.h"
#include "blackberrysettingspage.h"
#include <QtPlugin> #include <QtPlugin>
@@ -73,6 +74,7 @@ bool QNXPlugin::initialize(const QStringList &arguments, QString *errorString)
addAutoReleasedObject(new BlackBerryRunConfigurationFactory); addAutoReleasedObject(new BlackBerryRunConfigurationFactory);
addAutoReleasedObject(new BlackBerryRunControlFactory); addAutoReleasedObject(new BlackBerryRunControlFactory);
addAutoReleasedObject(new BlackBerryWizardExtension); addAutoReleasedObject(new BlackBerryWizardExtension);
addAutoReleasedObject(new BlackBerrySettingsPage);
// Handles QNX // Handles QNX
addAutoReleasedObject(new QnxQtVersionFactory); addAutoReleasedObject(new QnxQtVersionFactory);

View File

@@ -30,9 +30,10 @@
****************************************************************************/ ****************************************************************************/
#include "qnxutils.h" #include "qnxutils.h"
#include "qnxabstractqtversion.h" #include "qnxabstractqtversion.h"
#include <utils/hostosinfo.h>
#include <QDir> #include <QDir>
using namespace Qnx; using namespace Qnx;
@@ -73,3 +74,142 @@ QStringList QnxUtils::searchPaths(QnxAbstractQtVersion *qtVersion)
return searchPaths; 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;
}

View File

@@ -34,6 +34,11 @@
#include "qnxconstants.h" #include "qnxconstants.h"
#include <utils/environment.h>
#include <utils/qtcassert.h>
#include <utils/fileutils.h>
#include <QTextStream>
#include <QString> #include <QString>
namespace Qnx { namespace Qnx {
@@ -47,6 +52,11 @@ public:
static QString addQuotes(const QString &string); static QString addQuotes(const QString &string);
static Qnx::QnxArchitecture cpudirToArch(const QString &cpuDir); static Qnx::QnxArchitecture cpudirToArch(const QString &cpuDir);
static QStringList searchPaths(QnxAbstractQtVersion *qtVersion); static QStringList searchPaths(QnxAbstractQtVersion *qtVersion);
static QMultiMap<QString, QString> parseEnvironmentFile(const QString &fileName);
static bool isValidNdkPath(const QString & ndkPath);
static QString envFilePath(const QString & ndkPath);
static void prependQnxMapToEnvironment(const QMultiMap<QString, QString> &qnxMap, Utils::Environment &env);
static Utils::FileName executableWithExtension(const Utils::FileName &fileName);
}; };
} // namespace Internal } // namespace Internal