diff --git a/src/plugins/qnx/blackberryapilevelconfiguration.cpp b/src/plugins/qnx/blackberryapilevelconfiguration.cpp index 82021dc1226..2f3035d4f8d 100644 --- a/src/plugins/qnx/blackberryapilevelconfiguration.cpp +++ b/src/plugins/qnx/blackberryapilevelconfiguration.cpp @@ -67,7 +67,6 @@ using namespace Debugger; namespace Qnx { namespace Internal { -const QLatin1String NDKEnvFileKey("NDKEnvFile"); const QLatin1String NDKPathKey("NDKPath"); const QLatin1String NDKDisplayNameKey("NDKDisplayName"); const QLatin1String NDKTargetKey("NDKTarget"); @@ -81,16 +80,13 @@ bool BlackBerryApiLevelConfiguration::m_fakeConfig = false; #endif BlackBerryApiLevelConfiguration::BlackBerryApiLevelConfiguration(const NdkInstallInformation &ndkInstallInfo) + : QnxBaseConfiguration(FileName::fromString( + QnxUtils::envFilePath(ndkInstallInfo.path, ndkInstallInfo.version))) { - 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); m_autoDetectionSource = Utils::FileName::fromString(ndkInstallInfo.installationXmlFilePath); @@ -98,32 +94,17 @@ BlackBerryApiLevelConfiguration::BlackBerryApiLevelConfiguration(const NdkInstal } BlackBerryApiLevelConfiguration::BlackBerryApiLevelConfiguration(const FileName &ndkEnvFile) - : m_autoDetectionSource(Utils::FileName()) + : QnxBaseConfiguration(ndkEnvFile) { - QTC_ASSERT(!QFileInfo(ndkEnvFile.toString()).isDir(), return); - m_ndkEnvFile = ndkEnvFile; - QString ndkPath = m_ndkEnvFile.parentDir().toString(); - m_displayName = ndkPath.split(QDir::separator()).last(); - m_qnxEnv = QnxUtils::qnxEnvironmentFromNdkFile(m_ndkEnvFile.toString()); - - QString ndkTarget; - foreach (const Utils::EnvironmentItem &item, m_qnxEnv) { - if (item.name == QLatin1String("QNX_TARGET")) - ndkTarget = item.value; - - else if (item.name == QLatin1String("QNX_HOST")) - m_qnxHost = item.value; - - } - + m_displayName = ndkPath().split(QDir::separator()).last(); + QString ndkTarget = qnxTarget().toString(); // The QNX_TARGET value is using Unix-like separator on all platforms. QString sep = QString::fromLatin1("/qnx6"); m_targetName = ndkTarget.split(sep).first().split(QLatin1Char('/')).last(); - if (QDir(ndkTarget).exists()) m_sysRoot = FileName::fromString(ndkTarget); - m_version = BlackBerryVersionNumber::fromNdkEnvFileName(QFileInfo(m_ndkEnvFile.toString()).baseName()); + m_version = BlackBerryVersionNumber::fromNdkEnvFileName(QFileInfo(envFile().toString()).baseName()); if (m_version.isEmpty()) m_version = BlackBerryVersionNumber::fromTargetName(m_targetName); @@ -131,16 +112,12 @@ BlackBerryApiLevelConfiguration::BlackBerryApiLevelConfiguration(const FileName } BlackBerryApiLevelConfiguration::BlackBerryApiLevelConfiguration(const QVariantMap &data) + : QnxBaseConfiguration(data) { - QString envFilePath = data.value(NDKEnvFileKey).toString(); - QTC_ASSERT(!envFilePath.isEmpty(), return); - m_ndkEnvFile = Utils::FileName::fromString(envFilePath); m_displayName = data.value(NDKDisplayNameKey).toString(); - 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 = data.value(NDKTargetKey).toString().split(sep).first().split(QLatin1Char('/')).last(); - m_qnxHost = data.value(NDKHostKey).toString(); m_sysRoot = FileName::fromString(data.value(NDKTargetKey).toString()); m_version = BlackBerryVersionNumber(data.value(NDKVersionKey).toString()); if (data.value(QLatin1String(NDKAutoDetectedKey)).toBool()) @@ -151,31 +128,19 @@ BlackBerryApiLevelConfiguration::BlackBerryApiLevelConfiguration(const QVariantM void BlackBerryApiLevelConfiguration::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"))); - FileName deviceGdbPath = QnxUtils::executableWithExtension(FileName::fromString(m_qnxHost + QLatin1String("/usr/bin/ntoarm-gdb"))); - FileName simulatorGdbPath = QnxUtils::executableWithExtension(FileName::fromString(m_qnxHost + QLatin1String("/usr/bin/ntox86-gdb"))); - + QString host = qnxHost().toString(); + FileName qmake4Path = QnxUtils::executableWithExtension(FileName::fromString(host + QLatin1String("/usr/bin/qmake"))); + FileName qmake5Path = QnxUtils::executableWithExtension(FileName::fromString(host + QLatin1String("/usr/bin/qt5/qmake"))); if (qmake4Path.toFileInfo().exists()) m_qmake4BinaryFile = qmake4Path; if (qmake5Path.toFileInfo().exists()) m_qmake5BinaryFile = qmake5Path; - - if (gccPath.toFileInfo().exists()) - m_gccCompiler = gccPath; - - if (deviceGdbPath.toFileInfo().exists()) - m_deviceDebugger = deviceGdbPath; - - if (simulatorGdbPath.toFileInfo().exists()) - m_simulatorDebugger = simulatorGdbPath; } QString BlackBerryApiLevelConfiguration::ndkPath() const { - return m_ndkEnvFile.parentDir().toString(); + return envFile().parentDir().toString(); } QString BlackBerryApiLevelConfiguration::displayName() const @@ -188,11 +153,6 @@ QString BlackBerryApiLevelConfiguration::targetName() const return m_targetName; } -QString BlackBerryApiLevelConfiguration::qnxHost() const -{ - return m_qnxHost; -} - BlackBerryVersionNumber BlackBerryApiLevelConfiguration::version() const { return m_version; @@ -212,7 +172,7 @@ bool BlackBerryApiLevelConfiguration::isActive() const { foreach (Kit *kit, KitManager::kits()) { if (kit->isAutoDetected() && - kit->autoDetectionSource() == m_ndkEnvFile.toString()) + kit->autoDetectionSource() == envFile().toString()) return true; } @@ -226,17 +186,13 @@ bool BlackBerryApiLevelConfiguration::isValid() const return true; #endif - return ((!m_qmake4BinaryFile.isEmpty() || !m_qmake5BinaryFile.isEmpty()) && !m_gccCompiler.isEmpty() - && !m_deviceDebugger.isEmpty() && !m_simulatorDebugger.isEmpty() - && m_ndkEnvFile.toFileInfo().exists() && (m_autoDetectionSource.isEmpty() || - m_autoDetectionSource.toFileInfo().exists()) - && m_sysRoot.toFileInfo().exists()); + return QnxBaseConfiguration::isValid() && + ((!m_qmake4BinaryFile.isEmpty() || !m_qmake5BinaryFile.isEmpty()) + && (m_autoDetectionSource.isEmpty() || + m_autoDetectionSource.toFileInfo().exists()) + && (!m_sysRoot.isEmpty() && m_sysRoot.toFileInfo().exists())); } -FileName BlackBerryApiLevelConfiguration::ndkEnvFile() const -{ - return m_ndkEnvFile; -} FileName BlackBerryApiLevelConfiguration::qmake4BinaryFile() const { @@ -248,41 +204,19 @@ FileName BlackBerryApiLevelConfiguration::qmake5BinaryFile() const return m_qmake5BinaryFile; } -FileName BlackBerryApiLevelConfiguration::gccCompiler() const -{ - return m_gccCompiler; -} - -FileName BlackBerryApiLevelConfiguration::deviceDebuger() const -{ - return m_deviceDebugger; -} - -FileName BlackBerryApiLevelConfiguration::simulatorDebuger() const -{ - return m_simulatorDebugger; -} - FileName BlackBerryApiLevelConfiguration::sysRoot() const { return m_sysRoot; } -QList BlackBerryApiLevelConfiguration::qnxEnv() const -{ - return m_qnxEnv; -} - QVariantMap BlackBerryApiLevelConfiguration::toMap() const { - QVariantMap data; + QVariantMap data = QnxBaseConfiguration::toMap(); data.insert(QLatin1String(Qnx::Constants::QNX_BB_KEY_CONFIGURATION_TYPE), QLatin1String(Qnx::Constants::QNX_BB_APILEVEL_TYPE)); - data.insert(QLatin1String(NDKEnvFileKey), m_ndkEnvFile.toString()); data.insert(QLatin1String(NDKDisplayNameKey), m_displayName); data.insert(QLatin1String(NDKPathKey), ndkPath()); data.insert(QLatin1String(NDKTargetKey), m_sysRoot.toString()); - data.insert(QLatin1String(NDKHostKey), m_qnxHost); data.insert(QLatin1String(NDKVersionKey), m_version.toString()); data.insert(QLatin1String(NDKAutoDetectionSourceKey), m_autoDetectionSource.toString()); data.insert(QLatin1String(NDKAutoDetectedKey), isAutoDetected()); @@ -293,38 +227,12 @@ QnxAbstractQtVersion *BlackBerryApiLevelConfiguration::createQtVersion( const FileName &qmakePath, Qnx::QnxArchitecture arch, const QString &versionName) { QnxAbstractQtVersion *version = new BlackBerryQtVersion( - arch, qmakePath, true, QString(), m_ndkEnvFile.toString()); + arch, qmakePath, true, QString(), envFile().toString()); version->setDisplayName(tr("Qt %1 for %2").arg(version->qtVersionString(), versionName)); QtVersionManager::addVersion(version); return version; } -QnxToolChain *BlackBerryApiLevelConfiguration::createToolChain( - ProjectExplorer::Abi abi, const QString &versionName) -{ - QnxToolChain* toolChain = new QnxToolChain(ToolChain::AutoDetection); - toolChain->setDisplayName(tr("QCC for %1").arg(versionName)); - toolChain->setCompilerCommand(m_gccCompiler); - toolChain->setNdkPath(ndkPath()); - if (abi.isValid()) - toolChain->setTargetAbi(abi); - ToolChainManager::registerToolChain(toolChain); - return toolChain; -} - -QVariant BlackBerryApiLevelConfiguration::createDebuggerItem( - QList abis, Qnx::QnxArchitecture arch, const QString &versionName) -{ - Utils::FileName command = arch == X86 ? m_simulatorDebugger : m_deviceDebugger; - DebuggerItem debugger; - debugger.setCommand(command); - debugger.setEngineType(GdbEngineType); - debugger.setAutoDetected(true); - debugger.setAbis(abis); - debugger.setDisplayName(tr("Debugger for %1").arg(versionName)); - return DebuggerItemManager::registerDebugger(debugger); -} - Kit *BlackBerryApiLevelConfiguration::createKit( QnxAbstractQtVersion *version, QnxToolChain *toolChain, const QVariant &debuggerItemId) { @@ -354,7 +262,7 @@ Kit *BlackBerryApiLevelConfiguration::createKit( kit->setIconPath(FileName::fromString(QLatin1String(Constants::QNX_BB_CATEGORY_ICON))); kit->setAutoDetected(true); - kit->setAutoDetectionSource(m_ndkEnvFile.toString()); + kit->setAutoDetectionSource(envFile().toString()); kit->setMutable(DeviceKitInformation::id(), true); kit->setSticky(QtKitInformation::id(), true); @@ -368,25 +276,30 @@ Kit *BlackBerryApiLevelConfiguration::createKit( return kit; } +QStringList BlackBerryApiLevelConfiguration::validationErrors() const +{ + QStringList errorStrings = QnxBaseConfiguration::validationErrors(); + if (m_qmake4BinaryFile.isEmpty() && m_qmake5BinaryFile.isEmpty()) + errorStrings << tr("- No Qt version found."); + + if (!m_autoDetectionSource.isEmpty() && !m_autoDetectionSource.toFileInfo().exists()) + errorStrings << tr("- No auto detection source found."); + + if (m_sysRoot.isEmpty() && m_sysRoot.toFileInfo().exists()) + errorStrings << tr("- No sysroot found."); + + + return errorStrings; +} + bool BlackBerryApiLevelConfiguration::activate() { if (!isValid()) { if (!m_autoDetectionSource.isEmpty()) return false; - QString errorMessage = tr("The following errors occurred while activating target: %1").arg(m_targetName); - if (m_qmake4BinaryFile.isEmpty() && m_qmake5BinaryFile.isEmpty()) - errorMessage += QLatin1Char('\n') + tr("- No Qt version found."); - - if (m_gccCompiler.isEmpty()) - errorMessage += QLatin1Char('\n') + tr("- No GCC compiler found."); - - if (m_deviceDebugger.isEmpty()) - errorMessage += QLatin1Char('\n') + tr("- No GDB debugger found for BB10 Device."); - - if (!m_simulatorDebugger.isEmpty()) - errorMessage += QLatin1Char('\n') + tr("- No GDB debugger found for BB10 Simulator."); - + QString errorMessage = tr("The following errors occurred while activating target: %1\n").arg(m_targetName); + errorMessage.append(validationErrors().join(QLatin1String("\n"))); QMessageBox::warning(Core::ICore::mainWindow(), tr("Cannot Set up BB10 Configuration"), errorMessage, QMessageBox::Ok); return false; @@ -425,25 +338,29 @@ bool BlackBerryApiLevelConfiguration::activate() x86Abis << abi; } - // create toolchains - QnxToolChain *armToolChain = createToolChain( - !armAbis.isEmpty() ? armAbis.first() : Abi(), armVersionName); - QnxToolChain *x86ToolChain = createToolChain( - !x86Abis.isEmpty() ? x86Abis.first() : Abi(), x86VersionName); + // Create tool chains + QnxToolChain *armvle7ToolChain = createToolChain(QnxArchitecture::ArmLeV7, + tr("QCC for %1").arg(armVersionName), + ndkPath()); + QnxToolChain *x86ToolChain = createToolChain(QnxArchitecture::X86, + tr("QCC for %1").arg(x86VersionName), + ndkPath()); + // Create debuggers + QVariant armDebuggerId = createDebuggerItem(QnxArchitecture::ArmLeV7, + tr("Debugger for %1").arg(armVersionName)); - // create debuggers - QVariant armDebuggerItemId = createDebuggerItem(armAbis, Qnx::ArmLeV7, armVersionName); - QVariant x86DebuggerItemId = createDebuggerItem(x86Abis, Qnx::X86, x86VersionName); + QVariant x86DebuggerId = createDebuggerItem(QnxArchitecture::X86, + tr("Debugger for %1").arg(x86VersionName)); // create kits if (qt4ArmVersion) - createKit(qt4ArmVersion, armToolChain, armDebuggerItemId); + createKit(qt4ArmVersion, armvle7ToolChain, armDebuggerId); if (qt4X86Version) - createKit(qt4X86Version, x86ToolChain, x86DebuggerItemId); + createKit(qt4X86Version, x86ToolChain, x86DebuggerId); if (qt5ArmVersion) - createKit(qt5ArmVersion, armToolChain, armDebuggerItemId); + createKit(qt5ArmVersion, armvle7ToolChain, armDebuggerId); if (qt5X86Version) - createKit(qt5X86Version, x86ToolChain, x86DebuggerItemId); + createKit(qt5X86Version, x86ToolChain, x86DebuggerId); BlackBerryConfigurationManager::instance()->emitSettingsChanged(); @@ -458,7 +375,7 @@ void BlackBerryApiLevelConfiguration::deactivate() foreach (Kit *kit, KitManager::kits()) { if (kit->isAutoDetected() && - kit->autoDetectionSource() == ndkEnvFile().toString()) { + kit->autoDetectionSource() == envFile().toString()) { BaseQtVersion *version = QtKitInformation::qtVersion(kit); ToolChain *toolChain = ToolChainKitInformation::toolChain(kit); const DebuggerItem *debugger = DebuggerKitInformation::debugger(kit); @@ -498,6 +415,7 @@ bool BlackBerryApiLevelConfiguration::fakeConfig() { return m_fakeConfig; } + #endif } // namespace Internal diff --git a/src/plugins/qnx/blackberryapilevelconfiguration.h b/src/plugins/qnx/blackberryapilevelconfiguration.h index c49dda17eec..b0045b99625 100644 --- a/src/plugins/qnx/blackberryapilevelconfiguration.h +++ b/src/plugins/qnx/blackberryapilevelconfiguration.h @@ -34,6 +34,7 @@ #include "qnxutils.h" #include "blackberryversionnumber.h" +#include "qnxbaseconfiguration.h" #include "qnxconstants.h" #include @@ -54,7 +55,7 @@ namespace Internal { class QnxAbstractQtVersion; class QnxToolChain; -class BlackBerryApiLevelConfiguration +class BlackBerryApiLevelConfiguration : public QnxBaseConfiguration { Q_DECLARE_TR_FUNCTIONS(Qnx::Internal::BlackBerryApiLevelConfiguration) public: @@ -66,20 +67,14 @@ public: QString ndkPath() const; QString displayName() const; QString targetName() const; - QString qnxHost() const; BlackBerryVersionNumber version() const; bool isAutoDetected() const; Utils::FileName autoDetectionSource() const; bool isActive() const; bool isValid() const; - Utils::FileName ndkEnvFile() const; Utils::FileName qmake4BinaryFile() const; Utils::FileName qmake5BinaryFile() const; - Utils::FileName gccCompiler() const; - Utils::FileName deviceDebuger() const; - Utils::FileName simulatorDebuger() const; Utils::FileName sysRoot() const; - QList qnxEnv() const; QVariantMap toMap() const; #ifdef WITH_TESTS @@ -87,33 +82,24 @@ public: static bool fakeConfig(); #endif +protected: + QnxAbstractQtVersion *createQtVersion( + const Utils::FileName &qmakePath, Qnx::QnxArchitecture arch, const QString &versionName); + ProjectExplorer::Kit *createKit( + QnxAbstractQtVersion *version, QnxToolChain *armToolChain, const QVariant &debuggerItemId); + QStringList validationErrors() const; + private: QString m_displayName; QString m_targetName; - QString m_qnxHost; BlackBerryVersionNumber m_version; Utils::FileName m_autoDetectionSource; - Utils::FileName m_ndkEnvFile; Utils::FileName m_qmake4BinaryFile; Utils::FileName m_qmake5BinaryFile; - Utils::FileName m_gccCompiler; - Utils::FileName m_deviceDebugger; - Utils::FileName m_simulatorDebugger; Utils::FileName m_sysRoot; - QList m_qnxEnv; void ctor(); - QnxAbstractQtVersion* createQtVersion( - const Utils::FileName &qmakePath, Qnx::QnxArchitecture arch, const QString &versionName); - QnxToolChain* createToolChain( - ProjectExplorer::Abi abi, const QString &versionName); - QVariant createDebuggerItem( - QList abis, Qnx::QnxArchitecture arch, const QString &versionName); - ProjectExplorer::Kit* createKit( - QnxAbstractQtVersion* version, QnxToolChain* toolChain, - const QVariant &debuggerItemId); - #ifdef WITH_TESTS static bool m_fakeConfig; #endif diff --git a/src/plugins/qnx/blackberryconfigurationmanager.cpp b/src/plugins/qnx/blackberryconfigurationmanager.cpp index 2895710e520..2f239be9ec2 100644 --- a/src/plugins/qnx/blackberryconfigurationmanager.cpp +++ b/src/plugins/qnx/blackberryconfigurationmanager.cpp @@ -126,7 +126,7 @@ void BlackBerryConfigurationManager::saveConfigurations() data.insert(QLatin1String(BBConfigCountKey), count); const QString newestConfig = (newestApiLevelEnabled()) - ? NewestConfigurationValue : defaultApiLevel()->ndkEnvFile().toString(); + ? NewestConfigurationValue : defaultApiLevel()->envFile().toString(); //save default configuration data.insert(QLatin1String(DefaultConfigurationKey), newestConfig); @@ -167,7 +167,7 @@ void BlackBerryConfigurationManager::restoreConfigurations() BlackBerryApiLevelConfiguration *apiLevel = new BlackBerryApiLevelConfiguration(dMap); insertApiLevelByVersion(apiLevel); - if (!useNewestConfiguration && (apiLevel->ndkEnvFile().toString() == ndkEnvFile)) + if (!useNewestConfiguration && (apiLevel->envFile().toString() == ndkEnvFile)) setDefaultConfiguration(apiLevel); } } @@ -240,7 +240,7 @@ void BlackBerryConfigurationManager::setDefaultConfiguration( if (config && !m_apiLevels.contains(config)) { qWarning() << "BlackBerryConfigurationManager::setDefaultConfiguration -" " configuration does not belong to this instance: " - << config->ndkEnvFile().toString(); + << config->envFile().toString(); return; } @@ -269,7 +269,7 @@ void BlackBerryConfigurationManager::setKitsAutoDetectionSource() if ((version && (version->qmakeCommand() == config->qmake4BinaryFile() || version->qmakeCommand() == config->qmake5BinaryFile())) && (SysRootKitInformation::sysRoot(kit) == config->sysRoot())) { - kit->setAutoDetectionSource(config->ndkEnvFile().toString()); + kit->setAutoDetectionSource(config->envFile().toString()); // Set stickyness since not necessary saved for those kits kit->setSticky(QtSupport::QtKitInformation::id(), true); kit->setSticky(ToolChainKitInformation::id(), true); @@ -306,7 +306,7 @@ void BlackBerryConfigurationManager::checkToolChainConfiguration() { foreach (BlackBerryApiLevelConfiguration *config, m_apiLevels) { foreach (ToolChain *tc, ToolChainManager::toolChains()) { - if (tc->compilerCommand() == config->gccCompiler() + if (tc->compilerCommand() == config->qccCompilerPath() && !tc->id().startsWith(QLatin1String(Constants::QNX_TOOLCHAIN_ID))) { if (config->isActive()) { // reset @@ -322,7 +322,7 @@ void BlackBerryConfigurationManager::checkToolChainConfiguration() bool BlackBerryConfigurationManager::addApiLevel(BlackBerryApiLevelConfiguration *config) { foreach (BlackBerryApiLevelConfiguration *c, m_apiLevels) { - if (config->ndkEnvFile() == c->ndkEnvFile()) { + if (config->envFile() == c->envFile()) { if (!config->isAutoDetected()) QMessageBox::warning(Core::ICore::mainWindow(), tr("NDK Already Known"), tr("The NDK already has a configuration."), QMessageBox::Ok); @@ -416,7 +416,7 @@ BlackBerryApiLevelConfiguration *BlackBerryConfigurationManager::apiLevelFromEnv return 0; foreach (BlackBerryApiLevelConfiguration *config, m_apiLevels) { - if (config->ndkEnvFile() == envFile) + if (config->envFile() == envFile) return config; } diff --git a/src/plugins/qnx/blackberryndksettingswidget.cpp b/src/plugins/qnx/blackberryndksettingswidget.cpp index 1bcfbcc801d..370cbcc0489 100644 --- a/src/plugins/qnx/blackberryndksettingswidget.cpp +++ b/src/plugins/qnx/blackberryndksettingswidget.cpp @@ -155,9 +155,9 @@ void BlackBerryNDKSettingsWidget::updateInfoTable(QTreeWidgetItem* currentItem) BlackBerryApiLevelConfiguration *config = static_cast( currentItem->data(0, Qt::UserRole).value()); - m_ui->path->setText(config->ndkEnvFile().toString()); + m_ui->path->setText(config->envFile().toString()); m_ui->baseName->setText(config->displayName()); - m_ui->host->setText(QDir::toNativeSeparators(config->qnxHost())); + m_ui->host->setText(QDir::toNativeSeparators(config->qnxHost().toString())); m_ui->target->setText(QDir::toNativeSeparators(config->sysRoot().toString())); m_ui->version->setText(config->version().toString()); } @@ -189,20 +189,20 @@ void BlackBerryNDKSettingsWidget::updateConfigurationList() if (config->isAutoDetected() && !config->autoDetectionSource().toFileInfo().exists()) toolTip += QLatin1Char('\n') + tr("- Target no longer installed."); - if (!config->ndkEnvFile().toFileInfo().exists()) + if (!config->envFile().toFileInfo().exists()) toolTip += QLatin1Char('\n') + tr("- No NDK environment file found."); if (config->qmake4BinaryFile().isEmpty() && config->qmake5BinaryFile().isEmpty()) toolTip += QLatin1Char('\n') + tr("- No Qt version found."); - if (config->gccCompiler().isEmpty()) + if (config->qccCompilerPath().isEmpty()) toolTip += QLatin1Char('\n') + tr("- No compiler found."); - if (config->deviceDebuger().isEmpty()) + if (config->armDebuggerPath().isEmpty()) toolTip += QLatin1Char('\n') + tr("- No debugger found for device."); - if (config->simulatorDebuger().isEmpty()) + if (config->x86DebuggerPath().isEmpty()) toolTip += QLatin1Char('\n') + tr("- No debugger found for simulator."); item->setToolTip(0, toolTip); diff --git a/src/plugins/qnx/blackberryqtversion.cpp b/src/plugins/qnx/blackberryqtversion.cpp index d7c00634fd8..678ec244a39 100644 --- a/src/plugins/qnx/blackberryqtversion.cpp +++ b/src/plugins/qnx/blackberryqtversion.cpp @@ -112,7 +112,7 @@ QList BlackBerryQtVersion::environment() const return QList(); QString envFile = m_ndkEnvFile.isEmpty() ? QnxUtils::envFilePath(sdkPath()) : m_ndkEnvFile; - QList env = QnxUtils::qnxEnvironmentFromNdkFile(envFile); + QList env = QnxUtils::qnxEnvironmentFromEnvFile(envFile); // BB NDK Host is having qmake executable which is using qt.conf file to specify // base information. The qt.conf file is using 'CPUVARDIR' environment variable diff --git a/src/plugins/qnx/qnx.pro b/src/plugins/qnx/qnx.pro index e38f35ff474..c6e9fba7830 100644 --- a/src/plugins/qnx/qnx.pro +++ b/src/plugins/qnx/qnx.pro @@ -106,7 +106,9 @@ SOURCES += qnxplugin.cpp \ blackberryapilevelconfiguration.cpp \ blackberrypotentialkit.cpp \ bardescriptorfilenode.cpp \ - bardescriptorfilenodemanager.cpp + bardescriptorfilenodemanager.cpp \ + qnxconfiguration.cpp \ + qnxbaseconfiguration.cpp HEADERS += qnxplugin.h\ qnxconstants.h \ @@ -212,7 +214,9 @@ HEADERS += qnxplugin.h\ blackberryapilevelconfiguration.h \ blackberrypotentialkit.h \ bardescriptorfilenode.h \ - bardescriptorfilenodemanager.h + bardescriptorfilenodemanager.h \ + qnxconfiguration.h \ + qnxbaseconfiguration.h FORMS += \ blackberrydeviceconfigurationwizardsetuppage.ui \ diff --git a/src/plugins/qnx/qnx.qbs b/src/plugins/qnx/qnx.qbs index db37410db60..29ab573e9d6 100644 --- a/src/plugins/qnx/qnx.qbs +++ b/src/plugins/qnx/qnx.qbs @@ -211,10 +211,14 @@ QtcPlugin { "qnxattachdebugsupport.h", "qnxattachdebugdialog.cpp", "qnxattachdebugdialog.h", + "qnxbaseconfiguration.cpp", + "qnxbaseconfiguration.h", "qnxbaseqtconfigwidget.cpp", "qnxbaseqtconfigwidget.h", "qnxbaseqtconfigwidget.ui", "qnxconstants.h", + "qnxconfiguration.cpp", + "qnxconfiguration.h", "qnxabstractrunsupport.cpp", "qnxabstractrunsupport.h", "qnxanalyzesupport.cpp", diff --git a/src/plugins/qnx/qnxbaseconfiguration.cpp b/src/plugins/qnx/qnxbaseconfiguration.cpp new file mode 100644 index 00000000000..f623913a2c6 --- /dev/null +++ b/src/plugins/qnx/qnxbaseconfiguration.cpp @@ -0,0 +1,205 @@ +/************************************************************************** +** +** Copyright (C) 2014 BlackBerry Limited. All rights reserved. +** +** Contact: BlackBerry (qt@blackberry.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 "qnxbaseconfiguration.h" +#include +#include + +#include +#include + +#include + +#include + +#include +#include +#include + +namespace Qnx { +namespace Internal { + +const QLatin1String QNXEnvFileKey("EnvFile"); +// For backward compatibility +const QLatin1String NDKEnvFileKey("NDKEnvFile"); + +using namespace Utils; +using namespace ProjectExplorer; + +QnxBaseConfiguration::QnxBaseConfiguration() +{ +} + +QnxBaseConfiguration::QnxBaseConfiguration(const FileName &envFile) +{ + ctor(envFile); +} + +QnxBaseConfiguration::QnxBaseConfiguration(const QVariantMap &data) +{ + QString envFilePath = data.value(QNXEnvFileKey).toString(); + if (envFilePath.isEmpty()) + envFilePath = data.value(NDKEnvFileKey).toString(); + + ctor(FileName::fromString(envFilePath)); +} + +QnxBaseConfiguration::~QnxBaseConfiguration() +{ +} + +Utils::FileName QnxBaseConfiguration::envFile() const +{ + return m_envFile; +} + +Utils::FileName QnxBaseConfiguration::qnxTarget() const +{ + return m_qnxTarget; +} + +Utils::FileName QnxBaseConfiguration::qnxHost() const +{ + return m_qnxHost; +} + +Utils::FileName QnxBaseConfiguration::qccCompilerPath() const +{ + return m_qccCompiler; +} + +Utils::FileName QnxBaseConfiguration::armDebuggerPath() const +{ + return m_armlev7Debugger; +} + +Utils::FileName QnxBaseConfiguration::x86DebuggerPath() const +{ + return m_x86Debugger; +} + +QList QnxBaseConfiguration::qnxEnv() const +{ + return m_qnxEnv; +} + +QVariantMap QnxBaseConfiguration::toMap() const +{ + QVariantMap data; + data.insert(QLatin1String(QNXEnvFileKey), m_envFile.toString()); + return data; +} + +bool QnxBaseConfiguration::isValid() const +{ + return !m_qccCompiler.isEmpty() + && !m_armlev7Debugger.isEmpty() + && !m_x86Debugger.isEmpty(); +} + +void QnxBaseConfiguration::ctor(const FileName &envScript) +{ + QTC_ASSERT(!envScript.isEmpty() && envScript.toFileInfo().exists(), return); + m_envFile = envScript; + m_qnxEnv = QnxUtils::qnxEnvironmentFromEnvFile(m_envFile.toString()); + foreach (const Utils::EnvironmentItem &item, m_qnxEnv) { + if (item.name == QLatin1String("QNX_TARGET")) + m_qnxTarget = Utils::FileName::fromString(item.value); + + else if (item.name == QLatin1String("QNX_HOST")) + m_qnxHost = Utils::FileName::fromString(item.value); + } + + FileName qccPath = QnxUtils::executableWithExtension( + FileName::fromString(m_qnxHost.toString() + QLatin1String("/usr/bin/qcc"))); + FileName armlev7GdbPath = QnxUtils::executableWithExtension( + FileName::fromString(m_qnxHost.toString() + QLatin1String("/usr/bin/ntoarm-gdb"))); + if (!armlev7GdbPath.toFileInfo().exists()) + armlev7GdbPath = QnxUtils::executableWithExtension( + FileName::fromString(m_qnxHost.toString() + QLatin1String("/usr/bin/ntoarmv7-gdb"))); + + FileName x86GdbPath = QnxUtils::executableWithExtension( + FileName::fromString(m_qnxHost.toString() + QLatin1String("/usr/bin/ntox86-gdb"))); + + if (qccPath.toFileInfo().exists()) + m_qccCompiler = qccPath; + + if (armlev7GdbPath.toFileInfo().exists()) + m_armlev7Debugger = armlev7GdbPath; + + if (x86GdbPath.toFileInfo().exists()) + m_x86Debugger = x86GdbPath; +} + +QVariant QnxBaseConfiguration::createDebuggerItem(QnxArchitecture arch, + const QString &displayName) +{ + Utils::FileName command = (arch == X86) ? x86DebuggerPath() : armDebuggerPath(); + Debugger::DebuggerItem debugger; + debugger.setCommand(command); + debugger.setEngineType(Debugger::GdbEngineType); + debugger.setAbi(Abi(arch == Qnx::ArmLeV7 ? Abi::ArmArchitecture : Abi::X86Architecture, + Abi::LinuxOS, Abi::GenericLinuxFlavor, Abi::ElfFormat, 32)); + debugger.setAutoDetected(true); + debugger.setDisplayName(displayName); + return Debugger::DebuggerItemManager::registerDebugger(debugger); +} + +QnxToolChain *QnxBaseConfiguration::createToolChain(QnxArchitecture arch, + const QString &displayName, + const QString &ndkPath) +{ + QnxToolChain *toolChain = new QnxToolChain(ProjectExplorer::ToolChain::AutoDetection); + toolChain->setCompilerCommand(m_qccCompiler); + toolChain->setTargetAbi(Abi((arch == Qnx::ArmLeV7) ? Abi::ArmArchitecture : Abi::X86Architecture, + Abi::LinuxOS, Abi::GenericLinuxFlavor, Abi::ElfFormat, 32)); + toolChain->setDisplayName(displayName); + toolChain->setNdkPath(ndkPath); + ProjectExplorer::ToolChainManager::registerToolChain(toolChain); + return toolChain; +} + +QStringList QnxBaseConfiguration::validationErrors() const +{ + QStringList errorStrings; + if (m_qccCompiler.isEmpty()) + errorStrings << tr("- No GCC compiler found."); + + if (m_armlev7Debugger.isEmpty()) + errorStrings << tr("- No GDB debugger found for armvle7."); + + if (m_x86Debugger.isEmpty()) + errorStrings << tr("- No GDB debugger found for x86."); + + return errorStrings; +} + +} +} diff --git a/src/plugins/qnx/qnxbaseconfiguration.h b/src/plugins/qnx/qnxbaseconfiguration.h new file mode 100644 index 00000000000..85908b89f46 --- /dev/null +++ b/src/plugins/qnx/qnxbaseconfiguration.h @@ -0,0 +1,98 @@ +/************************************************************************** +** +** Copyright (C) 2014 BlackBerry Limited. All rights reserved. +** +** Contact: BlackBerry (qt@blackberry.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 QNXBASECONFIGURATION_H +#define QNXBASECONFIGURATION_H + +#include +#include + +#include +#include + +#include + +#include + +#include + +namespace Qnx { +namespace Internal { + +class QnxToolChain; + +class QnxBaseConfiguration +{ + Q_DECLARE_TR_FUNCTIONS(Qnx::Internal::QnxBaseConfiguration) + +public: + QnxBaseConfiguration(); + QnxBaseConfiguration(const Utils::FileName &envFile); + QnxBaseConfiguration(const QVariantMap &data); + virtual ~QnxBaseConfiguration(); + Utils::FileName envFile() const; + Utils::FileName qnxTarget() const; + Utils::FileName qnxHost() const; + Utils::FileName qccCompilerPath() const; + Utils::FileName armDebuggerPath() const; + Utils::FileName x86DebuggerPath() const; + QList qnxEnv() const; + QVariantMap toMap() const; + + virtual bool isValid() const; + virtual bool isActive() const = 0; + + virtual bool activate() = 0; + virtual void deactivate() = 0; + +protected: + QVariant createDebuggerItem(Qnx::QnxArchitecture arch, + const QString &displayName); + QnxToolChain* createToolChain(Qnx::QnxArchitecture arch, + const QString &displayName, + const QString &ndkPath); + + virtual QStringList validationErrors() const; +private: + Utils::FileName m_envFile; + Utils::FileName m_qnxTarget; + Utils::FileName m_qnxHost; + Utils::FileName m_qccCompiler; + Utils::FileName m_armlev7Debugger; + Utils::FileName m_x86Debugger; + QList m_qnxEnv; + + void ctor(const Utils::FileName &envFile); +}; + +} +} + +#endif // QNXBASECONFIGURATION_H diff --git a/src/plugins/qnx/qnxconfiguration.cpp b/src/plugins/qnx/qnxconfiguration.cpp new file mode 100644 index 00000000000..751a4942089 --- /dev/null +++ b/src/plugins/qnx/qnxconfiguration.cpp @@ -0,0 +1,134 @@ +/************************************************************************** +** +** Copyright (C) 2014 BlackBerry Limited. All rights reserved. +** +** Contact: BlackBerry (qt@blackberry.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 "qnxconfiguration.h" +#include "qnxutils.h" + +#include "qnxtoolchain.h" +#include "debugger/debuggeritem.h" + +#include + +#include + +#include +#include + +namespace Qnx { +namespace Internal { +QnxConfiguration::QnxConfiguration(const Utils::FileName &sdpEnvFile) + : QnxBaseConfiguration(sdpEnvFile) +{ +} + +bool QnxConfiguration::activate() +{ + if (isActive()) + return true; + + if (!isValid()) { + QString errorMessage = tr("The following errors occurred while activating the QNX configuration:"); + foreach (const QString &error, validationErrors()) + errorMessage += QLatin1String("\n") + error; + + QMessageBox::warning(Core::ICore::mainWindow(), tr("Cannot Set Up QNX Configuration"), + errorMessage, QMessageBox::Ok); + return false; + } + + // Create and register toolchain + createToolChain(QnxArchitecture::ArmLeV7, + tr("QCC for QNX armlev7"), + sdpPath().toString()); + createToolChain(QnxArchitecture::X86, + tr("QCC for QNX x86"), + sdpPath().toString()); + + // Create and register debuggers + createDebuggerItem(QnxArchitecture::ArmLeV7, + tr("Debugger for QNX armlev7")); + + createDebuggerItem(QnxArchitecture::X86, + tr("Debugger for QNX x86")); + + return true; +} + +void QnxConfiguration::deactivate() +{ + if (!isActive()) + return; + + foreach (ProjectExplorer::ToolChain *tc, + ProjectExplorer::ToolChainManager::toolChains()) { + if (tc->compilerCommand() == qccCompilerPath()) + ProjectExplorer::ToolChainManager::deregisterToolChain(tc); + } + + foreach (Debugger::DebuggerItem debuggerItem, + Debugger::DebuggerItemManager::debuggers()) { + if (debuggerItem.command() == armDebuggerPath() || + debuggerItem.command() == x86DebuggerPath()) + Debugger::DebuggerItemManager:: + deregisterDebugger(debuggerItem.id()); + } +} + +bool QnxConfiguration::isActive() const +{ + bool hasToolChain = false; + bool hasDebugger = false; + foreach (ProjectExplorer::ToolChain *tc, + ProjectExplorer::ToolChainManager::toolChains()) { + if (tc->compilerCommand() == qccCompilerPath()) { + hasToolChain = true; + break; + } + } + + foreach (Debugger::DebuggerItem debuggerItem, + Debugger::DebuggerItemManager::debuggers()) { + if (debuggerItem.command() == armDebuggerPath() || + debuggerItem.command() == x86DebuggerPath()) { + hasDebugger = true; + break; + } + } + + return hasToolChain && hasDebugger; +} + +Utils::FileName QnxConfiguration::sdpPath() const +{ + return envFile().parentDir(); +} + +} +} diff --git a/src/plugins/qnx/qnxconfiguration.h b/src/plugins/qnx/qnxconfiguration.h new file mode 100644 index 00000000000..43fa9359a95 --- /dev/null +++ b/src/plugins/qnx/qnxconfiguration.h @@ -0,0 +1,53 @@ +/************************************************************************** +** +** Copyright (C) 2014 BlackBerry Limited. All rights reserved. +** +** Contact: BlackBerry (qt@blackberry.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 QNXCONFIGURATION_H +#define QNXCONFIGURATION_H + +#include + +namespace Qnx { +namespace Internal { +class QnxConfiguration : public QnxBaseConfiguration +{ +public: + QnxConfiguration(const Utils::FileName &sdpEnvFile); + bool activate(); + void deactivate(); + bool isActive() const; + + Utils::FileName sdpPath() const; + +}; + +} // Internal +} // Qnx + +#endif // QNXCONFIGURATION_H diff --git a/src/plugins/qnx/qnxtoolchain.cpp b/src/plugins/qnx/qnxtoolchain.cpp index b6e214fb419..45023f4bcb4 100644 --- a/src/plugins/qnx/qnxtoolchain.cpp +++ b/src/plugins/qnx/qnxtoolchain.cpp @@ -89,7 +89,7 @@ void QnxToolChain::addToEnvironment(Utils::Environment &env) const { foreach (BlackBerryApiLevelConfiguration *config, BlackBerryConfigurationManager::instance()->apiLevels()) { - if (config->gccCompiler() == compilerCommand()) { + if (config->qccCompilerPath() == compilerCommand()) { setQnxEnvironment(env, config->qnxEnv()); break; } diff --git a/src/plugins/qnx/qnxutils.cpp b/src/plugins/qnx/qnxutils.cpp index 31332efb91b..ff7e5c6e08e 100644 --- a/src/plugins/qnx/qnxutils.cpp +++ b/src/plugins/qnx/qnxutils.cpp @@ -88,7 +88,7 @@ QStringList QnxUtils::searchPaths(QnxAbstractQtVersion *qtVersion) return searchPaths; } -QList QnxUtils::qnxEnvironmentFromNdkFile(const QString &fileName) +QList QnxUtils::qnxEnvironmentFromEnvFile(const QString &fileName) { QList items; diff --git a/src/plugins/qnx/qnxutils.h b/src/plugins/qnx/qnxutils.h index 4f402ec2432..33b1b3e3149 100644 --- a/src/plugins/qnx/qnxutils.h +++ b/src/plugins/qnx/qnxutils.h @@ -66,7 +66,7 @@ public: static QString addQuotes(const QString &string); static Qnx::QnxArchitecture cpudirToArch(const QString &cpuDir); static QStringList searchPaths(QnxAbstractQtVersion *qtVersion); - static QList qnxEnvironmentFromNdkFile(const QString &fileName); + static QList qnxEnvironmentFromEnvFile(const QString &fileName); static bool isValidNdkPath(const QString & ndkPath); static QString envFilePath(const QString & ndkPath, const QString& targetVersion = QString()); static Utils::FileName executableWithExtension(const Utils::FileName &fileName);