Commit f9212100 authored by El Mehdi Fekari's avatar El Mehdi Fekari Committed by Mehdi Fekari

Qnx: Sort configurations per version number

Change-Id: I52b656ebc1134c25941348769d7de4dc5286bdda
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 0e4de8c1
......@@ -33,7 +33,8 @@
#include "blackberryqtversion.h"
#include "qnxtoolchain.h"
#include "qnxutils.h"
#include <utils/qtcassert.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/kitmanager.h>
......@@ -62,14 +63,30 @@ using namespace Debugger;
namespace Qnx {
namespace Internal {
BlackBerryConfiguration::BlackBerryConfiguration(const FileName &ndkEnvFile, bool isAutoDetected,
const QString &displayName)
BlackBerryConfiguration::BlackBerryConfiguration(const NdkInstallInformation &ndkInstallInfo)
: m_isAutoDetected(true)
{
QString envFilePath = QnxUtils::envFilePath(ndkInstallInfo.path, ndkInstallInfo.version);
QTC_ASSERT(!envFilePath.isEmpty(), return);
m_ndkEnvFile = Utils::FileName::fromString(envFilePath);
m_displayName = ndkInstallInfo.name;
m_qnxEnv = QnxUtils::qnxEnvironmentFromNdkFile(m_ndkEnvFile.toString());
QString sep = QString::fromLatin1("/qnx6");
// The QNX_TARGET value is using Unix-like separator on all platforms.
m_targetName = ndkInstallInfo.target.split(sep).first().split(QLatin1Char('/')).last();
m_qnxHost = ndkInstallInfo.host;
m_sysRoot = FileName::fromString(ndkInstallInfo.target);
m_version = BlackBerryVersionNumber(ndkInstallInfo.version);
ctor();
}
BlackBerryConfiguration::BlackBerryConfiguration(const FileName &ndkEnvFile)
: m_isAutoDetected(false)
{
Q_ASSERT(!QFileInfo(ndkEnvFile.toString()).isDir());
QTC_ASSERT(!QFileInfo(ndkEnvFile.toString()).isDir(), return);
m_ndkEnvFile = ndkEnvFile;
m_isAutoDetected = isAutoDetected;
QString ndkPath = ndkEnvFile.parentDir().toString();
m_displayName = displayName.isEmpty() ? ndkPath.split(QDir::separator()).last() : displayName;
QString ndkPath = m_ndkEnvFile.parentDir().toString();
m_displayName = ndkPath.split(QDir::separator()).last();
m_qnxEnv = QnxUtils::qnxEnvironmentFromNdkFile(m_ndkEnvFile.toString());
QString ndkTarget;
......@@ -89,6 +106,15 @@ BlackBerryConfiguration::BlackBerryConfiguration(const FileName &ndkEnvFile, boo
if (QDir(ndkTarget).exists())
m_sysRoot = FileName::fromString(ndkTarget);
m_version = BlackBerryVersionNumber::fromNdkEnvFileName(QFileInfo(m_ndkEnvFile.toString()).baseName());
if (m_version.isEmpty())
m_version = BlackBerryVersionNumber::fromTargetName(m_targetName);
ctor();
}
void BlackBerryConfiguration::ctor()
{
FileName qmake4Path = QnxUtils::executableWithExtension(FileName::fromString(m_qnxHost + QLatin1String("/usr/bin/qmake")));
FileName qmake5Path = QnxUtils::executableWithExtension(FileName::fromString(m_qnxHost + QLatin1String("/usr/bin/qt5/qmake")));
FileName gccPath = QnxUtils::executableWithExtension(FileName::fromString(m_qnxHost + QLatin1String("/usr/bin/qcc")));
......@@ -131,6 +157,11 @@ QString BlackBerryConfiguration::qnxHost() const
return m_qnxHost;
}
BlackBerryVersionNumber BlackBerryConfiguration::version() const
{
return m_version;
}
bool BlackBerryConfiguration::isAutoDetected() const
{
return m_isAutoDetected;
......
......@@ -32,6 +32,8 @@
#ifndef BLACKBERRYCONFIGURATIONS_H
#define BLACKBERRYCONFIGURATIONS_H
#include "qnxutils.h"
#include "blackberryversionnumber.h"
#include "qnxconstants.h"
#include <utils/environment.h>
......@@ -60,13 +62,15 @@ class BlackBerryConfiguration
{
Q_DECLARE_TR_FUNCTIONS(Qnx::Internal::BlackBerryConfiguration)
public:
BlackBerryConfiguration(const Utils::FileName &ndkEnvFile, bool isAutoDetected, const QString &displayName = QString());
BlackBerryConfiguration(const NdkInstallInformation &ndkInstallInfo);
BlackBerryConfiguration(const Utils::FileName &ndkEnvFile);
bool activate();
void deactivate();
QString ndkPath() const;
QString displayName() const;
QString targetName() const;
QString qnxHost() const;
BlackBerryVersionNumber version() const;
bool isAutoDetected() const;
bool isActive() const;
bool isValid() const;
......@@ -84,6 +88,7 @@ private:
QString m_targetName;
QString m_qnxHost;
bool m_isAutoDetected;
BlackBerryVersionNumber m_version;
Utils::FileName m_ndkEnvFile;
Utils::FileName m_qmake4BinaryFile;
Utils::FileName m_qmake5BinaryFile;
......@@ -93,6 +98,7 @@ private:
Utils::FileName m_sysRoot;
QList<Utils::EnvironmentItem> m_qnxEnv;
void ctor();
QnxAbstractQtVersion* createQtVersion(
const Utils::FileName &qmakePath, Qnx::QnxArchitecture arch, const QString &versionName);
QnxToolChain* createToolChain(
......
......@@ -66,6 +66,11 @@ const QLatin1String ManualNDKsGroup("ManualNDKs");
const QLatin1String ActiveNDKsGroup("ActiveNDKs");
}
static bool sortConfigurationsByVersion(const BlackBerryConfiguration *a, const BlackBerryConfiguration *b)
{
return a->version() > b->version();
}
BlackBerryConfigurationManager::BlackBerryConfigurationManager(QObject *parent)
:QObject(parent)
{
......@@ -90,8 +95,7 @@ void BlackBerryConfigurationManager::loadManualConfigurations()
ndkEnvPath = QnxUtils::envFilePath(ndkPath);
}
BlackBerryConfiguration *config = new BlackBerryConfiguration(Utils::FileName::fromString(ndkEnvPath),
false);
BlackBerryConfiguration *config = new BlackBerryConfiguration(Utils::FileName::fromString(ndkEnvPath));
if (!addConfiguration(config))
delete config;
......@@ -106,9 +110,7 @@ void BlackBerryConfigurationManager::loadAutoDetectedConfigurations()
{
QStringList activePaths = activeConfigurationNdkEnvPaths();
foreach (const NdkInstallInformation &ndkInfo, QnxUtils::installedNdks()) {
QString envFilePath = QnxUtils::envFilePath(ndkInfo.path, ndkInfo.version);
BlackBerryConfiguration *config = new BlackBerryConfiguration(Utils::FileName::fromString(envFilePath),
true, ndkInfo.name);
BlackBerryConfiguration *config = new BlackBerryConfiguration(ndkInfo);
if (!addConfiguration(config)) {
delete config;
continue;
......@@ -242,7 +244,9 @@ bool BlackBerryConfigurationManager::addConfiguration(BlackBerryConfiguration *c
}
if (config->isValid()) {
m_configs.append(config);
QList<BlackBerryConfiguration *>::iterator it = qLowerBound(m_configs.begin(), m_configs.end(),
config, &sortConfigurationsByVersion);
m_configs.insert(it, config);
return true;
}
......
......@@ -479,7 +479,7 @@ void BlackBerryInstallWizardFinalPage::initializePage()
BlackBerryConfiguration *config = configManager.configurationFromEnvFile(Utils::FileName::fromString(m_data.ndkPath));
if (!config) {
config = new BlackBerryConfiguration(Utils::FileName::fromString(m_data.ndkPath), false);
config = new BlackBerryConfiguration(Utils::FileName::fromString(m_data.ndkPath));
if (!configManager.addConfiguration(config)) {
delete config;
// TODO: more explicit error message!
......
......@@ -148,16 +148,7 @@ void BlackBerryNDKSettingsWidget::updateInfoTable(QTreeWidgetItem* currentItem)
m_ui->ndkPathLabel->setText(QDir::toNativeSeparators(config->ndkPath()));
m_ui->hostLabel->setText(QDir::toNativeSeparators(config->qnxHost()));
m_ui->targetLabel->setText(QDir::toNativeSeparators(config->sysRoot().toString()));
m_ui->versionLabel->clear();
// TODO: Add a versionNumber attribute for the BlackBerryConfiguration class
if (config->isAutoDetected()) {
foreach (const NdkInstallInformation &ndkInfo, QnxUtils::installedNdks()) {
if (ndkInfo.name == config->displayName()) {
m_ui->versionLabel->setText(ndkInfo.version);
break;
}
}
}
m_ui->versionLabel->setText(config->version().toString());
updateUi(currentItem, config);
}
......
/**************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
**
** Contact: BlackBerry (qt@blackberry.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 "blackberryversionnumber.h"
#include <QDir>
namespace Qnx {
namespace Internal {
static const char NONDIGIT_SEGMENT_REGEXP[] = "(?<=\\d)(?=\\D)|(?<=\\D)(?=\\d)";
BlackBerryVersionNumber::BlackBerryVersionNumber(const QStringList &listNumber)
: m_segments(listNumber)
{
}
BlackBerryVersionNumber::BlackBerryVersionNumber(const QString &version)
{
m_segments = version.split(QLatin1Char('.'));
}
BlackBerryVersionNumber::BlackBerryVersionNumber()
{
}
QString BlackBerryVersionNumber::toString() const
{
return m_segments.join(QLatin1String("."));
}
bool BlackBerryVersionNumber::operator <(const BlackBerryVersionNumber &b) const
{
int minSize = size() > b.size() ? b.size() : size();
for (int i = 0; i < minSize; i++) {
if (segment(i) != b.segment(i)) {
// Segment can contain digits and non digits expressions
QStringList aParts = segment(i).split(QLatin1String(NONDIGIT_SEGMENT_REGEXP));
QStringList bParts = b.segment(i).split(QLatin1String(NONDIGIT_SEGMENT_REGEXP));
int minPartSize = aParts.length() > bParts.length() ? bParts.length() : aParts.length();
for (int j = 0; j < minPartSize; j++) {
bool aOk = true;
bool bOk = true;
int aInt = aParts[j].toInt(&aOk);
int bInt = bParts[j].toInt(&bOk);
if (aOk && bOk)
return aInt < bInt;
return aParts[j].compare(bParts[j]) < 0;
}
}
}
return false;
}
bool BlackBerryVersionNumber::operator ==(const BlackBerryVersionNumber &b) const
{
int minSize = size() > b.size() ? b.size() : size();
for (int i = 0; i < minSize; i++) {
if (segment(i) != b.segment(i))
return false;
}
return true;
}
QString BlackBerryVersionNumber::segment(int index) const
{
if (index < m_segments.length())
return m_segments.at(index);
return QString();
}
BlackBerryVersionNumber BlackBerryVersionNumber::fromNdkEnvFileName(const QString &ndkEnvFileName)
{
return fromFileName(ndkEnvFileName, QRegExp(QLatin1String("^bbndk-env_(.*)$")));
}
BlackBerryVersionNumber BlackBerryVersionNumber::fromTargetName(const QString &targetName)
{
return fromFileName(targetName, QRegExp(QLatin1String("^target_(.*)$")));
}
BlackBerryVersionNumber BlackBerryVersionNumber::fromFileName(const QString &fileName, const QRegExp &regExp)
{
QStringList segments;
if (regExp.exactMatch(fileName) && regExp.captureCount() == 1)
segments << regExp.cap(1).split(QLatin1Char('_'));
return BlackBerryVersionNumber(segments);
}
int BlackBerryVersionNumber::size() const
{
return m_segments.length();
}
bool BlackBerryVersionNumber::isEmpty() const
{
return m_segments.isEmpty();
}
} // namespace Internal
} // namespace Qnx
/**************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
**
** Contact: BlackBerry (qt@blackberry.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 BLACKBERRY_VERSION_NUMBER_H
#define BLACKBERRY_VERSION_NUMBER_H
#include <qstringlist.h>
using namespace std::rel_ops;
namespace Qnx {
namespace Internal {
class BlackBerryVersionNumber
{
public:
BlackBerryVersionNumber(const QStringList &segments);
BlackBerryVersionNumber(const QString &version);
BlackBerryVersionNumber();
int size() const;
bool isEmpty() const;
QString segment(int index) const;
QString toString() const;
static BlackBerryVersionNumber fromNdkEnvFileName(const QString &ndkEnvFileName);
static BlackBerryVersionNumber fromTargetName(const QString &targetName);
static BlackBerryVersionNumber fromFileName(const QString &fileName, const QRegExp &regExp);
bool operator <(const BlackBerryVersionNumber &b) const;
bool operator ==(const BlackBerryVersionNumber &b) const;
private:
QStringList m_segments;
};
} // namespace Internal
} // namespace Qnx
#endif // VERSIONNUMBER_H
......@@ -98,7 +98,8 @@ SOURCES += qnxplugin.cpp \
qnxdeviceprocesssignaloperation.cpp \
qnxdeviceprocesslist.cpp \
qnxtoolchain.cpp \
slog2inforunner.cpp
slog2inforunner.cpp \
blackberryversionnumber.cpp
HEADERS += qnxplugin.h\
qnxconstants.h \
......@@ -196,7 +197,8 @@ HEADERS += qnxplugin.h\
qnxdeviceprocesssignaloperation.h \
qnxdeviceprocesslist.h \
qnxtoolchain.h \
slog2inforunner.h
slog2inforunner.h \
blackberryversionnumber.h
FORMS += \
......
......@@ -185,6 +185,8 @@ QtcPlugin {
"blackberrysetupwizardfinishpage.ui",
"blackberrysigningutils.cpp",
"blackberrysigningutils.h",
"blackberryversionnumber.cpp",
"blackberryversionnumber.h",
"pathchooserdelegate.cpp",
"pathchooserdelegate.h",
"qnxtoolchain.cpp",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment