diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp index 936505369d3..91997051617 100644 --- a/src/plugins/projectexplorer/gcctoolchain.cpp +++ b/src/plugins/projectexplorer/gcctoolchain.cpp @@ -113,40 +113,7 @@ static QByteArray runGcc(const FileName &gcc, const QStringList &arguments, cons static QByteArray gccPredefinedMacros(const FileName &gcc, const QStringList &args, const QStringList &env) { - QStringList arguments; - arguments << QLatin1String("-xc++") - << QLatin1String("-E") - << QLatin1String("-dM"); - foreach (const QString &a, args) { - if (a == QLatin1String("-m128bit-long-double") || a == QLatin1String("-m32") - || a == QLatin1String("-m3dnow") || a == QLatin1String("-m3dnowa") - || a == QLatin1String("-m64") || a == QLatin1String("-m96bit-long-double") - || a == QLatin1String("-mabm") || a == QLatin1String("-maes") - || a.startsWith(QLatin1String("-march=")) || a == QLatin1String("-mavx") - || a.startsWith(QLatin1String("-masm=")) || a == QLatin1String("-mcx16") - || a == QLatin1String("-mfma") || a == QLatin1String("-mfma4") - || a == QLatin1String("-mlwp") || a == QLatin1String("-mpclmul") - || a == QLatin1String("-mpopcnt") || a == QLatin1String("-msse") - || a == QLatin1String("-msse2") || a == QLatin1String("-msse2avx") - || a == QLatin1String("-msse3") || a == QLatin1String("-msse4") - || a == QLatin1String("-msse4.1") || a == QLatin1String("-msse4.2") - || a == QLatin1String("-msse4a") || a == QLatin1String("-mssse3") - || a.startsWith(QLatin1String("-mtune=")) || a == QLatin1String("-mxop") - || a == QLatin1String("-Os") || a == QLatin1String("-O0") || a == QLatin1String("-O1") - || a == QLatin1String("-O2") || a == QLatin1String("-O3") - || a == QLatin1String("-ffinite-math-only") || a == QLatin1String("-fshort-double") - || a == QLatin1String("-fshort-wchar") || a == QLatin1String("-fsignaling-nans") - || a == QLatin1String("-fno-inline") || a == QLatin1String("-fno-exceptions") - || a == QLatin1String("-fstack-protector") || a == QLatin1String("-fstack-protector-all") - || a == QLatin1String("-fsanitize=address") || a == QLatin1String("-fno-rtti") - || a.startsWith(QLatin1String("-std=")) || a.startsWith(QLatin1String("-stdlib=")) - || a.startsWith(QLatin1String("-specs=")) - || a == QLatin1String("-ansi") || a == QLatin1String("-undef") - || a.startsWith(QLatin1String("-D")) || a.startsWith(QLatin1String("-U")) - || a == QLatin1String("-fopenmp") || a == QLatin1String("-Wno-deprecated")) - arguments << a; - } - + QStringList arguments = args; arguments << QLatin1String("-"); QByteArray predefinedMacros = runGcc(gcc, arguments, env); @@ -169,23 +136,10 @@ static QByteArray gccPredefinedMacros(const FileName &gcc, const QStringList &ar const int GccToolChain::PREDEFINED_MACROS_CACHE_SIZE = 16; -QList GccToolChain::gccHeaderPaths(const FileName &gcc, const QStringList &args, - const QStringList &env, const FileName &sysrootPath) +QList GccToolChain::gccHeaderPaths(const FileName &gcc, const QStringList &arguments, + const QStringList &env) { QList systemHeaderPaths; - QStringList arguments; - if (!sysrootPath.isEmpty()) - arguments.append(QString::fromLatin1("--sysroot=%1").arg(sysrootPath.toString())); - foreach (const QString &a, args) { - if (a.startsWith(QLatin1String("-stdlib="))) - arguments << a; - } - - arguments << QLatin1String("-xc++") - << QLatin1String("-E") - << QLatin1String("-v") - << QLatin1String("-"); - QByteArray line; QByteArray data = runGcc(gcc, arguments, env); QBuffer cpp(&data); @@ -254,6 +208,16 @@ static QList guessGccAbi(const QString &m, const QByteArray ¯os) return abiList; } +static QStringList gccPredefinedMacrosOptions() +{ + QStringList gccOptions; + gccOptions << QLatin1String("-xc++") + << QLatin1String("-E") + << QLatin1String("-dM"); + + return gccOptions; +} + static QList guessGccAbi(const FileName &path, const QStringList &env, const QStringList &extraArgs = QStringList()) { @@ -265,7 +229,7 @@ static QList guessGccAbi(const FileName &path, const QStringList &env, QString machine = QString::fromLocal8Bit(runGcc(path, arguments, env)).trimmed(); if (machine.isEmpty()) return QList(); // no need to continue if running failed once... - QByteArray macros = gccPredefinedMacros(path, QStringList(), env); + QByteArray macros = gccPredefinedMacros(path, gccPredefinedMacrosOptions(), env); return guessGccAbi(machine, macros); } @@ -388,7 +352,38 @@ QByteArray GccToolChain::predefinedMacros(const QStringList &cxxflags) const // Using a clean environment breaks ccache/distcc/etc. Environment env = Environment::systemEnvironment(); addToEnvironment(env); - runResults.second = gccPredefinedMacros(m_compilerCommand, allCxxflags, env.toStringList()); + QStringList arguments = gccPredefinedMacrosOptions(); + foreach (const QString &a, allCxxflags) { + if (a == QLatin1String("-m128bit-long-double") || a == QLatin1String("-m32") + || a == QLatin1String("-m3dnow") || a == QLatin1String("-m3dnowa") + || a == QLatin1String("-m64") || a == QLatin1String("-m96bit-long-double") + || a == QLatin1String("-mabm") || a == QLatin1String("-maes") + || a.startsWith(QLatin1String("-march=")) || a == QLatin1String("-mavx") + || a.startsWith(QLatin1String("-masm=")) || a == QLatin1String("-mcx16") + || a == QLatin1String("-mfma") || a == QLatin1String("-mfma4") + || a == QLatin1String("-mlwp") || a == QLatin1String("-mpclmul") + || a == QLatin1String("-mpopcnt") || a == QLatin1String("-msse") + || a == QLatin1String("-msse2") || a == QLatin1String("-msse2avx") + || a == QLatin1String("-msse3") || a == QLatin1String("-msse4") + || a == QLatin1String("-msse4.1") || a == QLatin1String("-msse4.2") + || a == QLatin1String("-msse4a") || a == QLatin1String("-mssse3") + || a.startsWith(QLatin1String("-mtune=")) || a == QLatin1String("-mxop") + || a == QLatin1String("-Os") || a == QLatin1String("-O0") || a == QLatin1String("-O1") + || a == QLatin1String("-O2") || a == QLatin1String("-O3") + || a == QLatin1String("-ffinite-math-only") || a == QLatin1String("-fshort-double") + || a == QLatin1String("-fshort-wchar") || a == QLatin1String("-fsignaling-nans") + || a == QLatin1String("-fno-inline") || a == QLatin1String("-fno-exceptions") + || a == QLatin1String("-fstack-protector") || a == QLatin1String("-fstack-protector-all") + || a == QLatin1String("-fsanitize=address") || a == QLatin1String("-fno-rtti") + || a.startsWith(QLatin1String("-std=")) || a.startsWith(QLatin1String("-stdlib=")) + || a.startsWith(QLatin1String("-specs=")) + || a == QLatin1String("-ansi") || a == QLatin1String("-undef") + || a.startsWith(QLatin1String("-D")) || a.startsWith(QLatin1String("-U")) + || a == QLatin1String("-fopenmp") || a == QLatin1String("-Wno-deprecated")) + arguments << a; + } + + runResults.second = gccPredefinedMacros(m_compilerCommand, reinterpretOptions(arguments), env.toStringList()); m_predefinedMacros.push_back(runResults); if (m_predefinedMacros.size() > PREDEFINED_MACROS_CACHE_SIZE) @@ -501,8 +496,24 @@ QList GccToolChain::systemHeaderPaths(const QStringList &cxxflags, c // Using a clean environment breaks ccache/distcc/etc. Environment env = Environment::systemEnvironment(); addToEnvironment(env); - m_headerPaths = gccHeaderPaths(m_compilerCommand, m_platformCodeGenFlags + cxxflags , // add only cxxflags is empty? - env.toStringList(), sysRoot); + // Prepare arguments + QStringList arguments; + if (!sysRoot.isEmpty()) + arguments.append(QString::fromLatin1("--sysroot=%1").arg(sysRoot.toString())); + + QStringList flags; + flags << m_platformCodeGenFlags << cxxflags; + foreach (const QString &a, flags) { + if (a.startsWith(QLatin1String("-stdlib="))) + arguments << a; + } + + arguments << QLatin1String("-xc++") + << QLatin1String("-E") + << QLatin1String("-v") + << QLatin1String("-"); + + m_headerPaths = gccHeaderPaths(m_compilerCommand, reinterpretOptions(arguments), env.toStringList()); } return m_headerPaths; } @@ -709,6 +720,12 @@ QString GccToolChain::detectVersion() const return gccVersion(m_compilerCommand, env.toStringList()); } +QStringList GccToolChain::reinterpretOptions(const QStringList &arg) const +{ + // Nothing todo + return arg; +} + // -------------------------------------------------------------------------- // GccToolChainFactory // -------------------------------------------------------------------------- diff --git a/src/plugins/projectexplorer/gcctoolchain.h b/src/plugins/projectexplorer/gcctoolchain.h index 1361f4b4338..a755aa06c6d 100644 --- a/src/plugins/projectexplorer/gcctoolchain.h +++ b/src/plugins/projectexplorer/gcctoolchain.h @@ -104,7 +104,10 @@ protected: virtual QList detectSupportedAbis() const; virtual QString detectVersion() const; - static QList gccHeaderPaths(const Utils::FileName &gcc, const QStringList &args, const QStringList &env, const Utils::FileName &sysrootPath); + // Reinterpret options for compiler drivers inheriting from GccToolChain (e.g qcc) to apply -Wp option + // that passes the initial options directly down to the gcc compiler + virtual QStringList reinterpretOptions(const QStringList &argument) const; + static QList gccHeaderPaths(const Utils::FileName &gcc, const QStringList &args, const QStringList &env); static const int PREDEFINED_MACROS_CACHE_SIZE; mutable GccCache m_predefinedMacros; diff --git a/src/plugins/qnx/blackberryconfiguration.cpp b/src/plugins/qnx/blackberryconfiguration.cpp index cc45468e539..c70c9fe63e3 100644 --- a/src/plugins/qnx/blackberryconfiguration.cpp +++ b/src/plugins/qnx/blackberryconfiguration.cpp @@ -32,6 +32,7 @@ #include "blackberryconfiguration.h" #include "blackberryqtversion.h" +#include "qnxtoolchain.h" #include "qnxutils.h" #include @@ -184,7 +185,7 @@ void BlackBerryConfiguration::createConfigurationPerQtVersion( const FileName &qmakePath, Qnx::QnxArchitecture arch) { QnxAbstractQtVersion *version = createQtVersion(qmakePath, arch); - ToolChain *toolChain = createGccToolChain(version); + ToolChain *toolChain = createToolChain(version); Kit *kit = createKit(version, toolChain); if (version && toolChain && kit) { @@ -206,15 +207,15 @@ QnxAbstractQtVersion *BlackBerryConfiguration::createQtVersion( return version; } -GccToolChain *BlackBerryConfiguration::createGccToolChain(QnxAbstractQtVersion *version) +QnxToolChain *BlackBerryConfiguration::createToolChain(QnxAbstractQtVersion *version) { - GccToolChain* toolChain = new GccToolChain( - QLatin1String(ProjectExplorer::Constants::GCC_TOOLCHAIN_ID), ToolChain::AutoDetection); + QnxToolChain* toolChain = new QnxToolChain(ToolChain::AutoDetection); //: QCC is the compiler for QNX. toolChain->setDisplayName(tr("QCC for Qt %1 for %2 %3 - %4").arg( version->qtVersionString(), version->platformDisplayName(), version->archString(), m_targetName)); toolChain->setCompilerCommand(m_gccCompiler); + toolChain->setNdkPath(ndkPath()); QList abis = version->qtAbis(); if (!abis.isEmpty()) toolChain->setTargetAbi(abis.first()); diff --git a/src/plugins/qnx/blackberryconfiguration.h b/src/plugins/qnx/blackberryconfiguration.h index a2f8f31e822..3b4902b2107 100644 --- a/src/plugins/qnx/blackberryconfiguration.h +++ b/src/plugins/qnx/blackberryconfiguration.h @@ -37,20 +37,18 @@ #include #include +#include + #include -#include #include #include -namespace QtSupport { -class BaseQtVersion; -} - namespace Qnx { namespace Internal { class QnxAbstractQtVersion; +class QnxToolChain; class BlackBerryConfiguration { @@ -91,7 +89,7 @@ private: const Utils::FileName &qmakePath, Qnx::QnxArchitecture arch); QnxAbstractQtVersion* createQtVersion( const Utils::FileName &qmakePath, Qnx::QnxArchitecture arch); - ProjectExplorer::GccToolChain* createGccToolChain(QnxAbstractQtVersion *version); + QnxToolChain* createToolChain(QnxAbstractQtVersion *version); ProjectExplorer::Kit* createKit( QnxAbstractQtVersion* version, ProjectExplorer::ToolChain* toolChain); QList findRegisteredQtVersions() const; diff --git a/src/plugins/qnx/blackberryconfigurationmanager.cpp b/src/plugins/qnx/blackberryconfigurationmanager.cpp index c5136172be4..7af64cc3d0b 100644 --- a/src/plugins/qnx/blackberryconfigurationmanager.cpp +++ b/src/plugins/qnx/blackberryconfigurationmanager.cpp @@ -33,6 +33,7 @@ #include "blackberrycertificate.h" #include "blackberryconfiguration.h" +#include "qnxtoolchain.h" #include "qnxutils.h" #include @@ -210,6 +211,24 @@ void BlackBerryConfigurationManager::clearInvalidConfigurations() } } +// Switch to QnxToolchain for exisintg configuration using GccToolChain +void BlackBerryConfigurationManager::checkToolChainConfiguration() +{ + foreach (BlackBerryConfiguration *config, m_configs) { + foreach (ToolChain *tc, ToolChainManager::toolChains()) { + if (tc->compilerCommand() == config->gccCompiler() + && !tc->id().startsWith(QLatin1String(Constants::QNX_TOOLCHAIN_ID))) { + if (config->isActive()) { + // reset + config->deactivate(); + config->activate(); + break; + } + } + } + } +} + bool BlackBerryConfigurationManager::addConfiguration(BlackBerryConfiguration *config) { foreach (BlackBerryConfiguration *c, m_configs) { @@ -298,6 +317,7 @@ void BlackBerryConfigurationManager::loadSettings() clearInvalidConfigurations(); loadAutoDetectedConfigurations(); loadManualConfigurations(); + checkToolChainConfiguration(); emit settingsLoaded(); } diff --git a/src/plugins/qnx/blackberryconfigurationmanager.h b/src/plugins/qnx/blackberryconfigurationmanager.h index 35e2325d187..97602e0633c 100644 --- a/src/plugins/qnx/blackberryconfigurationmanager.h +++ b/src/plugins/qnx/blackberryconfigurationmanager.h @@ -70,6 +70,7 @@ public: public slots: void loadSettings(); void saveSettings(); + void checkToolChainConfiguration(); signals: void settingsLoaded(); diff --git a/src/plugins/qnx/qnx.pro b/src/plugins/qnx/qnx.pro index 55e36202354..2f0b403b760 100644 --- a/src/plugins/qnx/qnx.pro +++ b/src/plugins/qnx/qnx.pro @@ -97,6 +97,7 @@ SOURCES += qnxplugin.cpp \ blackberryinstallwizard.cpp \ qnxdeviceprocesssignaloperation.cpp \ qnxdeviceprocesslist.cpp \ + qnxtoolchain.cpp \ slog2inforunner.cpp HEADERS += qnxplugin.h\ @@ -194,6 +195,7 @@ HEADERS += qnxplugin.h\ blackberryinstallwizard.h \ qnxdeviceprocesssignaloperation.h \ qnxdeviceprocesslist.h \ + qnxtoolchain.h \ slog2inforunner.h diff --git a/src/plugins/qnx/qnx.qbs b/src/plugins/qnx/qnx.qbs index cecd40ed1f6..ea26cb24472 100644 --- a/src/plugins/qnx/qnx.qbs +++ b/src/plugins/qnx/qnx.qbs @@ -187,6 +187,8 @@ QtcPlugin { "blackberrysigningutils.h", "pathchooserdelegate.cpp", "pathchooserdelegate.h", + "qnxtoolchain.cpp", + "qnxtoolchain.h", "qnx.qrc", "qnxabstractqtversion.cpp", "qnxabstractqtversion.h", diff --git a/src/plugins/qnx/qnxconstants.h b/src/plugins/qnx/qnxconstants.h index c0d5d1762d6..726657f748b 100644 --- a/src/plugins/qnx/qnxconstants.h +++ b/src/plugins/qnx/qnxconstants.h @@ -90,6 +90,8 @@ const char QNX_BB_PLATFORM_NAME[] = "BlackBerry"; const char QNX_DEBUG_EXECUTABLE[] = "pdebug"; +const char QNX_TOOLCHAIN_ID[] = "Qnx.QccToolChain"; + // BlackBerry settings constants const char QNX_BB_CATEGORY[] = "XF.BlackBerry"; const char QNX_BB_CATEGORY_TR[] = QT_TRANSLATE_NOOP("BlackBerry", "BlackBerry"); diff --git a/src/plugins/qnx/qnxplugin.cpp b/src/plugins/qnx/qnxplugin.cpp index a348dd1afc6..37c4216b2ee 100644 --- a/src/plugins/qnx/qnxplugin.cpp +++ b/src/plugins/qnx/qnxplugin.cpp @@ -53,6 +53,8 @@ #include "blackberrydeviceconnectionmanager.h" #include "blackberryconfigurationmanager.h" #include "cascadesimport/cascadesimportwizard.h" +#include "qnxtoolchain.h" + #include #include @@ -101,6 +103,9 @@ bool QNXPlugin::initialize(const QStringList &arguments, QString *errorString) addAutoReleasedObject(new QnxDeployConfigurationFactory); addAutoReleasedObject(new QnxRunConfigurationFactory); + // Handle Qcc Compiler + addAutoReleasedObject(new QnxToolChainFactory); + // bar-descriptor.xml editor Core::MimeGlobPattern barDescriptorGlobPattern(QLatin1String("*.xml"), Core::MimeGlobPattern::MinWeight + 1); Core::MimeType barDescriptorMimeType; diff --git a/src/plugins/qnx/qnxtoolchain.cpp b/src/plugins/qnx/qnxtoolchain.cpp new file mode 100644 index 00000000000..e321c3557bf --- /dev/null +++ b/src/plugins/qnx/qnxtoolchain.cpp @@ -0,0 +1,269 @@ +/************************************************************************** +** +** 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 "qnxtoolchain.h" +#include "qnxconstants.h" +#include "qnxutils.h" + +#include "blackberryconfigurationmanager.h" +#include "blackberryconfiguration.h" + +#include + +#include + +using namespace ProjectExplorer; +namespace Qnx { +namespace Internal { + +static const char CompilernNdkPath[] = "Qnx.QnxToolChain.NDKPath"; + +static const QList qccSupportedAbis() +{ + QList abis; + abis << Abi(Abi::ArmArchitecture, Abi::LinuxOS, Abi::GenericLinuxFlavor, Abi::ElfFormat, 32); + abis << Abi(Abi::X86Architecture, Abi::LinuxOS, Abi::GenericLinuxFlavor, Abi::ElfFormat, 32); + + return abis; +} + +static void setQnxEnvironment(Utils::Environment &env, const QList &qnxEnv) +{ + // We only need to set QNX_HOST and QNX_TARGET needed when running qcc + foreach (const Utils::EnvironmentItem &item, qnxEnv) { + if (item.name == QLatin1String("QNX_HOST") || + item.name == QLatin1String("QNX_TARGET") ) + env.set(item.name, item.value); + } +} + +QnxToolChain::QnxToolChain(ToolChain::Detection d) + : GccToolChain(QLatin1String(Constants::QNX_TOOLCHAIN_ID), d) +{ +} + +QString QnxToolChain::type() const +{ + return QLatin1String(Constants::QNX_TOOLCHAIN_ID); +} + +QString QnxToolChain::typeDisplayName() const +{ + return QnxToolChainFactory::tr("QCC"); +} + +ToolChainConfigWidget *QnxToolChain::configurationWidget() +{ + return new QnxToolChainConfigWidget(this); +} + +void QnxToolChain::addToEnvironment(Utils::Environment &env) const +{ + foreach (BlackBerryConfiguration* config, BlackBerryConfigurationManager::instance().configurations()) { + if (config->gccCompiler() == compilerCommand()) { + setQnxEnvironment(env, config->qnxEnv()); + break; + } + } + + if (env.value(QLatin1String("QNX_HOST")).isEmpty() + || env.value(QLatin1String("QNX_TARGET")).isEmpty()) + setQnxEnvironment(env, QnxUtils::qnxEnvironment(m_ndkPath)); + + GccToolChain::addToEnvironment(env); +} + +QList QnxToolChain::suggestedMkspecList() const +{ + QList mkspecList; + mkspecList << Utils::FileName::fromString(QLatin1String("qnx-armv7le-qcc")); + mkspecList << Utils::FileName::fromString(QLatin1String("qnx-x86-qcc")); + mkspecList << Utils::FileName::fromString(QLatin1String("blackberry-armv7le-qcc")); + mkspecList << Utils::FileName::fromString(QLatin1String("blackberry-x86-qcc")); + + return mkspecList; +} + +QVariantMap QnxToolChain::toMap() const +{ + QVariantMap data = GccToolChain::toMap(); + data.insert(QLatin1String(CompilernNdkPath), m_ndkPath); + return data; +} + +bool QnxToolChain::fromMap(const QVariantMap &data) +{ + if (!GccToolChain::fromMap(data)) + return false; + + m_ndkPath = data.value(QLatin1String(CompilernNdkPath)).toString(); + return true; +} + +QString QnxToolChain::ndkPath() const +{ + return m_ndkPath; +} + +void QnxToolChain::setNdkPath(const QString &ndkPath) +{ + m_ndkPath = ndkPath; +} + +// qcc doesn't support a "-dumpmachine" option to get supported abis +QList QnxToolChain::detectSupportedAbis() const +{ + return qccSupportedAbis(); +} + +// Qcc is a multi-compiler driver, and most of the gcc options can be accomplished by using the -Wp, and -Wc +// options to pass the options directly down to the compiler +QStringList QnxToolChain::reinterpretOptions(const QStringList &args) const +{ + QStringList arguments; + foreach (const QString &str, args) { + if (str.startsWith(QLatin1String("--sysroot="))) + continue; + QString arg = str; + if (arg == QLatin1String("-v") + || arg == QLatin1String("-dM")) + arg.prepend(QLatin1String("-Wp,")); + arguments << arg; + } + + return arguments; +} + +// -------------------------------------------------------------------------- +// QnxToolChainFactory +// -------------------------------------------------------------------------- + +QnxToolChainFactory::QnxToolChainFactory() +{ + setId(Constants::QNX_TOOLCHAIN_ID); + setDisplayName(tr("QCC")); +} + +bool QnxToolChainFactory::canRestore(const QVariantMap &data) +{ + const QString id = idFromMap(data); + return id.startsWith(QLatin1String(Constants::QNX_TOOLCHAIN_ID) + QLatin1Char(':')); +} + +ToolChain *QnxToolChainFactory::restore(const QVariantMap &data) +{ + QnxToolChain *tc = new QnxToolChain(ToolChain::ManualDetection); + if (tc->fromMap(data)) + return tc; + + delete tc; + return 0; +} + +bool QnxToolChainFactory::canCreate() +{ + return true; +} + +ToolChain *QnxToolChainFactory::create() +{ + return new QnxToolChain(ToolChain::ManualDetection); +} + +//--------------------------------------------------------------------------------- +// QnxToolChainConfigWidget +//--------------------------------------------------------------------------------- + +QnxToolChainConfigWidget::QnxToolChainConfigWidget(QnxToolChain *tc) + : ToolChainConfigWidget(tc) + , m_compilerCommand(new Utils::PathChooser) + , m_ndkPath(new Utils::PathChooser) + , m_abiWidget(new AbiWidget) +{ + m_compilerCommand->setExpectedKind(Utils::PathChooser::ExistingCommand); + m_compilerCommand->setFileName(tc->compilerCommand()); + m_compilerCommand->setEnabled(!tc->isAutoDetected()); + + m_ndkPath->setExpectedKind(Utils::PathChooser::ExistingDirectory); + m_ndkPath->setPath(tc->ndkPath()); + m_ndkPath->setEnabled(!tc->isAutoDetected()); + + m_abiWidget->setAbis(qccSupportedAbis(), tc->targetAbi()); + m_abiWidget->setEnabled(!tc->isAutoDetected()); + + m_mainLayout->addRow(tr("&Compiler path:"), m_compilerCommand); + //: SDP refers to 'Software Development Platform'. + m_mainLayout->addRow(tr("NDK/SDP path:"), m_ndkPath); + m_mainLayout->addRow(tr("&ABI:"), m_abiWidget); + + connect(m_compilerCommand, SIGNAL(changed(QString)), this, SIGNAL(dirty())); + connect(m_ndkPath, SIGNAL(changed(QString)), this, SIGNAL(dirty())); + connect(m_abiWidget, SIGNAL(abiChanged()), this, SIGNAL(dirty())); +} + +void QnxToolChainConfigWidget::applyImpl() +{ + if (toolChain()->isAutoDetected()) + return; + + QnxToolChain *tc = static_cast(toolChain()); + Q_ASSERT(tc); + QString displayName = tc->displayName(); + tc->setCompilerCommand(m_compilerCommand->fileName()); + tc->setDisplayName(displayName); // reset display name + tc->setNdkPath(m_ndkPath->fileName().toString()); + tc->setTargetAbi(m_abiWidget->currentAbi()); +} + +void QnxToolChainConfigWidget::discardImpl() +{ + // subwidgets are not yet connected! + bool blocked = blockSignals(true); + QnxToolChain *tc = static_cast(toolChain()); + m_compilerCommand->setFileName(tc->compilerCommand()); + m_ndkPath->setPath(tc->ndkPath()); + m_abiWidget->setAbis(tc->supportedAbis(), tc->targetAbi()); + if (!m_compilerCommand->path().isEmpty()) + m_abiWidget->setEnabled(true); + blockSignals(blocked); +} + +bool QnxToolChainConfigWidget::isDirtyImpl() const +{ + QnxToolChain *tc = static_cast(toolChain()); + Q_ASSERT(tc); + return m_compilerCommand->fileName() != tc->compilerCommand() + || m_ndkPath->path() != tc->ndkPath() + || m_abiWidget->currentAbi() != tc->targetAbi(); +} + +} // namespace Internal +} // namespace Qnx diff --git a/src/plugins/qnx/qnxtoolchain.h b/src/plugins/qnx/qnxtoolchain.h new file mode 100644 index 00000000000..8abbda4f9f0 --- /dev/null +++ b/src/plugins/qnx/qnxtoolchain.h @@ -0,0 +1,113 @@ +/************************************************************************** +** +** 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 QNXTOOLCHAIN_H +#define QNXTOOLCHAIN_H + +#include +#include + +namespace Qnx { +namespace Internal { + +class QnxToolChain : public ProjectExplorer::GccToolChain +{ +public: + explicit QnxToolChain(Detection d); + + QString type() const; + QString typeDisplayName() const; + + ProjectExplorer::ToolChainConfigWidget *configurationWidget(); + + void addToEnvironment(Utils::Environment &env) const; + QList suggestedMkspecList() const; + + QVariantMap toMap() const; + bool fromMap(const QVariantMap &data); + + QString ndkPath() const; + void setNdkPath(const QString &ndkPath); + +protected: + virtual QList detectSupportedAbis() const; + + QStringList reinterpretOptions(const QStringList &args) const; + +private: + QString m_ndkPath; +}; + +// -------------------------------------------------------------------------- +// QnxToolChainFactory +// -------------------------------------------------------------------------- + +class QnxToolChainFactory : public ProjectExplorer::ToolChainFactory +{ + Q_OBJECT + +public: + QnxToolChainFactory(); + + bool canRestore(const QVariantMap &data); + ProjectExplorer::ToolChain *restore(const QVariantMap &data); + + bool canCreate(); + ProjectExplorer::ToolChain *create(); +}; + +//---------------------------------------------------------------------------- +// QnxToolChainConfigWidget +//---------------------------------------------------------------------------- + +class QnxToolChainConfigWidget : public ProjectExplorer::ToolChainConfigWidget +{ + Q_OBJECT + +public: + QnxToolChainConfigWidget(QnxToolChain *tc); + +private: + void applyImpl(); + void discardImpl(); + bool isDirtyImpl() const; + void makeReadOnlyImpl() {} + + Utils::PathChooser *m_compilerCommand; + Utils::PathChooser *m_ndkPath; + ProjectExplorer::AbiWidget *m_abiWidget; + +}; + +} // namespace Internal +} // namespace Qnx + +#endif // QNXTOOLCHAIN_H