2011-02-01 18:36:00 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2011-02-01 18:36:00 +01:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2011-02-01 18:36:00 +01:00
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2011-02-01 18:36:00 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2011-02-01 18:36:00 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2011-02-01 18:36:00 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "gcctoolchain.h"
|
2011-05-18 18:38:58 +02:00
|
|
|
#include "clangparser.h"
|
2011-02-28 16:50:14 +01:00
|
|
|
#include "gcctoolchainfactories.h"
|
2011-02-01 18:36:00 +01:00
|
|
|
#include "gccparser.h"
|
|
|
|
|
#include "linuxiccparser.h"
|
|
|
|
|
#include "projectexplorerconstants.h"
|
2011-03-31 10:13:35 +02:00
|
|
|
#include "toolchainmanager.h"
|
2011-02-01 18:36:00 +01:00
|
|
|
|
|
|
|
|
#include <utils/environment.h>
|
|
|
|
|
#include <utils/synchronousprocess.h>
|
2011-02-23 11:36:59 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2011-02-28 16:50:14 +01:00
|
|
|
#include <utils/pathchooser.h>
|
2011-02-01 18:36:00 +01:00
|
|
|
|
|
|
|
|
#include <QtCore/QBuffer>
|
|
|
|
|
#include <QtCore/QCoreApplication>
|
|
|
|
|
#include <QtCore/QFileInfo>
|
|
|
|
|
#include <QtCore/QProcess>
|
2011-02-23 11:36:59 +01:00
|
|
|
#include <QtCore/QScopedPointer>
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2011-03-10 14:44:49 +01:00
|
|
|
#include <QtGui/QComboBox>
|
2011-02-22 14:57:39 +01:00
|
|
|
#include <QtGui/QFormLayout>
|
2011-02-01 18:36:00 +01:00
|
|
|
#include <QtGui/QLabel>
|
|
|
|
|
|
|
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// Helpers:
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
2011-02-22 17:32:22 +01:00
|
|
|
static const char compilerPathKeyC[] = "ProjectExplorer.GccToolChain.Path";
|
2011-03-10 14:44:49 +01:00
|
|
|
static const char targetAbiKeyC[] = "ProjectExplorer.GccToolChain.TargetAbi";
|
2011-06-21 13:26:22 +02:00
|
|
|
static const char supportedAbisKeyC[] = "ProjectExplorer.GccToolChain.SupportedAbis";
|
2011-02-22 17:32:22 +01:00
|
|
|
static const char debuggerCommandKeyC[] = "ProjectExplorer.GccToolChain.Debugger";
|
2011-02-01 18:36:00 +01:00
|
|
|
|
|
|
|
|
static QByteArray runGcc(const QString &gcc, const QStringList &arguments, const QStringList &env)
|
|
|
|
|
{
|
2011-02-28 17:30:40 +01:00
|
|
|
if (gcc.isEmpty() || !QFileInfo(gcc).isExecutable())
|
2011-02-01 18:36:00 +01:00
|
|
|
return QByteArray();
|
|
|
|
|
|
|
|
|
|
QProcess cpp;
|
2011-07-29 08:53:00 +00:00
|
|
|
// Force locale: This function is used only to detect settings inside the tool chain, so this is save.
|
|
|
|
|
QStringList environment(env);
|
2011-10-17 20:22:29 +02:00
|
|
|
environment.append(QLatin1String("LC_ALL=C"));
|
2011-07-29 08:53:00 +00:00
|
|
|
|
|
|
|
|
cpp.setEnvironment(environment);
|
2011-02-01 18:36:00 +01:00
|
|
|
cpp.start(gcc, arguments);
|
|
|
|
|
if (!cpp.waitForStarted()) {
|
|
|
|
|
qWarning("%s: Cannot start '%s': %s", Q_FUNC_INFO, qPrintable(gcc),
|
|
|
|
|
qPrintable(cpp.errorString()));
|
|
|
|
|
return QByteArray();
|
|
|
|
|
}
|
|
|
|
|
cpp.closeWriteChannel();
|
|
|
|
|
if (!cpp.waitForFinished()) {
|
|
|
|
|
Utils::SynchronousProcess::stopProcess(cpp);
|
|
|
|
|
qWarning("%s: Timeout running '%s'.", Q_FUNC_INFO, qPrintable(gcc));
|
|
|
|
|
return QByteArray();
|
|
|
|
|
}
|
|
|
|
|
if (cpp.exitStatus() != QProcess::NormalExit) {
|
|
|
|
|
qWarning("%s: '%s' crashed.", Q_FUNC_INFO, qPrintable(gcc));
|
|
|
|
|
return QByteArray();
|
|
|
|
|
}
|
2011-03-01 13:23:49 +01:00
|
|
|
|
2011-04-19 15:42:14 +02:00
|
|
|
return cpp.readAllStandardOutput() + '\n' + cpp.readAllStandardError();
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QByteArray gccPredefinedMacros(const QString &gcc, const QStringList &env)
|
|
|
|
|
{
|
|
|
|
|
QStringList arguments;
|
|
|
|
|
arguments << QLatin1String("-xc++")
|
|
|
|
|
<< QLatin1String("-E")
|
|
|
|
|
<< QLatin1String("-dM")
|
|
|
|
|
<< QLatin1String("-");
|
|
|
|
|
|
|
|
|
|
QByteArray predefinedMacros = runGcc(gcc, arguments, env);
|
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
|
// Turn off flag indicating Apple's blocks support
|
|
|
|
|
const QByteArray blocksDefine("#define __BLOCKS__ 1");
|
|
|
|
|
const QByteArray blocksUndefine("#undef __BLOCKS__");
|
|
|
|
|
const int idx = predefinedMacros.indexOf(blocksDefine);
|
|
|
|
|
if (idx != -1) {
|
|
|
|
|
predefinedMacros.replace(idx, blocksDefine.length(), blocksUndefine);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Define __strong and __weak (used for Apple's GC extension of C) to be empty
|
|
|
|
|
predefinedMacros.append("#define __strong\n");
|
|
|
|
|
predefinedMacros.append("#define __weak\n");
|
|
|
|
|
#endif // Q_OS_MAC
|
|
|
|
|
return predefinedMacros;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QList<HeaderPath> gccHeaderPathes(const QString &gcc, const QStringList &env)
|
|
|
|
|
{
|
|
|
|
|
QList<HeaderPath> systemHeaderPaths;
|
|
|
|
|
QStringList arguments;
|
|
|
|
|
arguments << QLatin1String("-xc++")
|
|
|
|
|
<< QLatin1String("-E")
|
|
|
|
|
<< QLatin1String("-v")
|
|
|
|
|
<< QLatin1String("-");
|
|
|
|
|
|
|
|
|
|
QByteArray line;
|
|
|
|
|
QByteArray data = runGcc(gcc, arguments, env);
|
|
|
|
|
QBuffer cpp(&data);
|
2011-03-01 13:23:49 +01:00
|
|
|
cpp.open(QIODevice::ReadOnly);
|
2011-02-01 18:36:00 +01:00
|
|
|
while (cpp.canReadLine()) {
|
|
|
|
|
line = cpp.readLine();
|
|
|
|
|
if (line.startsWith("#include"))
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!line.isEmpty() && line.startsWith("#include")) {
|
|
|
|
|
HeaderPath::Kind kind = HeaderPath::UserHeaderPath;
|
|
|
|
|
while (cpp.canReadLine()) {
|
|
|
|
|
line = cpp.readLine();
|
|
|
|
|
if (line.startsWith("#include")) {
|
|
|
|
|
kind = HeaderPath::GlobalHeaderPath;
|
2012-01-09 16:30:33 +01:00
|
|
|
} else if (! line.isEmpty() && QChar(QLatin1Char(line.at(0))).isSpace()) {
|
2011-02-01 18:36:00 +01:00
|
|
|
HeaderPath::Kind thisHeaderKind = kind;
|
|
|
|
|
|
|
|
|
|
line = line.trimmed();
|
|
|
|
|
|
|
|
|
|
const int index = line.indexOf(" (framework directory)");
|
|
|
|
|
if (index != -1) {
|
|
|
|
|
line.truncate(index);
|
|
|
|
|
thisHeaderKind = HeaderPath::FrameworkHeaderPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
systemHeaderPaths.append(HeaderPath(QFile::decodeName(line), thisHeaderKind));
|
|
|
|
|
} else if (line.startsWith("End of search list.")) {
|
|
|
|
|
break;
|
|
|
|
|
} else {
|
2012-01-09 16:30:33 +01:00
|
|
|
qWarning("%s: Ignoring line: %s", __FUNCTION__, line.constData());
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return systemHeaderPaths;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-10 14:44:49 +01:00
|
|
|
static QList<ProjectExplorer::Abi> guessGccAbi(const QString &m)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2011-03-10 14:44:49 +01:00
|
|
|
QList<ProjectExplorer::Abi> abiList;
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
QString machine = m.toLower();
|
|
|
|
|
if (machine.isEmpty())
|
2011-03-10 14:44:49 +01:00
|
|
|
return abiList;
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2012-01-09 16:30:33 +01:00
|
|
|
QStringList parts = machine.split(QRegExp(QLatin1String("[ /-]")));
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2011-02-23 16:47:08 +01:00
|
|
|
ProjectExplorer::Abi::Architecture arch = ProjectExplorer::Abi::UnknownArchitecture;
|
|
|
|
|
ProjectExplorer::Abi::OS os = ProjectExplorer::Abi::UnknownOS;
|
|
|
|
|
ProjectExplorer::Abi::OSFlavor flavor = ProjectExplorer::Abi::UnknownFlavor;
|
|
|
|
|
ProjectExplorer::Abi::BinaryFormat format = ProjectExplorer::Abi::UnknownFormat;
|
2011-02-22 12:38:49 +01:00
|
|
|
int width = 0;
|
2011-02-01 18:36:00 +01:00
|
|
|
int unknownCount = 0;
|
|
|
|
|
|
|
|
|
|
foreach (const QString &p, parts) {
|
|
|
|
|
if (p == QLatin1String("unknown") || p == QLatin1String("pc") || p == QLatin1String("none")
|
2011-04-06 10:04:57 +02:00
|
|
|
|| p == QLatin1String("gnu") || p == QLatin1String("uclibc")
|
2011-05-11 12:14:07 +02:00
|
|
|
|| p == QLatin1String("86_64") || p == QLatin1String("redhat") || p == QLatin1String("gnueabi")) {
|
2011-02-01 18:36:00 +01:00
|
|
|
continue;
|
|
|
|
|
} else if (p == QLatin1String("i386") || p == QLatin1String("i486") || p == QLatin1String("i586")
|
|
|
|
|
|| p == QLatin1String("i686") || p == QLatin1String("x86")) {
|
2011-02-23 16:47:08 +01:00
|
|
|
arch = ProjectExplorer::Abi::X86Architecture;
|
2011-02-22 12:38:49 +01:00
|
|
|
width = 32;
|
2011-07-01 13:39:54 +02:00
|
|
|
} else if (p.startsWith(QLatin1String("arm"))) {
|
2011-02-23 16:47:08 +01:00
|
|
|
arch = ProjectExplorer::Abi::ArmArchitecture;
|
2011-02-01 18:36:00 +01:00
|
|
|
width = 32;
|
2011-04-06 10:04:57 +02:00
|
|
|
} else if (p == QLatin1String("mipsel")) {
|
2011-08-31 09:55:34 +00:00
|
|
|
arch = ProjectExplorer::Abi::MipsArchitecture;
|
2011-04-06 10:04:57 +02:00
|
|
|
width = 32;
|
2011-02-01 18:36:00 +01:00
|
|
|
} else if (p == QLatin1String("x86_64")) {
|
2011-02-23 16:47:08 +01:00
|
|
|
arch = ProjectExplorer::Abi::X86Architecture;
|
2011-02-01 18:36:00 +01:00
|
|
|
width = 64;
|
2011-03-11 12:01:39 +01:00
|
|
|
} else if (p == QLatin1String("powerpc")) {
|
|
|
|
|
arch = ProjectExplorer::Abi::PowerPCArchitecture;
|
2011-02-01 18:36:00 +01:00
|
|
|
} else if (p == QLatin1String("w64")) {
|
|
|
|
|
width = 64;
|
2011-05-03 14:40:20 +02:00
|
|
|
} else if (p == QLatin1String("linux") || p == QLatin1String("linux6e")) {
|
2011-02-23 16:47:08 +01:00
|
|
|
os = ProjectExplorer::Abi::LinuxOS;
|
2011-05-11 12:14:07 +02:00
|
|
|
if (flavor == Abi::UnknownFlavor)
|
|
|
|
|
flavor = ProjectExplorer::Abi::GenericLinuxFlavor;
|
|
|
|
|
format = ProjectExplorer::Abi::ElfFormat;
|
2012-01-09 16:30:33 +01:00
|
|
|
} else if (p.startsWith(QLatin1String("freebsd"))) {
|
2011-05-31 10:06:32 +00:00
|
|
|
os = ProjectExplorer::Abi::BsdOS;
|
2011-05-31 08:55:57 +00:00
|
|
|
if (flavor == Abi::UnknownFlavor)
|
2011-05-31 10:06:32 +00:00
|
|
|
flavor = ProjectExplorer::Abi::FreeBsdFlavor;
|
2011-05-31 08:55:57 +00:00
|
|
|
format = ProjectExplorer::Abi::ElfFormat;
|
2011-05-11 12:14:07 +02:00
|
|
|
} else if (p == QLatin1String("meego")) {
|
|
|
|
|
os = ProjectExplorer::Abi::LinuxOS;
|
|
|
|
|
flavor = ProjectExplorer::Abi::MeegoLinuxFlavor;
|
2011-02-23 16:47:08 +01:00
|
|
|
format = ProjectExplorer::Abi::ElfFormat;
|
2011-02-01 18:36:00 +01:00
|
|
|
} else if (p == QLatin1String("symbianelf")) {
|
2011-02-23 16:47:08 +01:00
|
|
|
os = ProjectExplorer::Abi::SymbianOS;
|
|
|
|
|
flavor = ProjectExplorer::Abi::SymbianDeviceFlavor;
|
|
|
|
|
format = ProjectExplorer::Abi::ElfFormat;
|
2011-02-22 12:09:27 +01:00
|
|
|
width = 32;
|
2011-05-13 11:48:34 +02:00
|
|
|
} else if (p == QLatin1String("mingw32") || p == QLatin1String("win32")) {
|
2011-02-23 16:47:08 +01:00
|
|
|
arch = ProjectExplorer::Abi::X86Architecture;
|
|
|
|
|
os = ProjectExplorer::Abi::WindowsOS;
|
|
|
|
|
flavor = ProjectExplorer::Abi::WindowsMSysFlavor;
|
|
|
|
|
format = ProjectExplorer::Abi::PEFormat;
|
2011-02-22 12:38:49 +01:00
|
|
|
if (width == 0)
|
|
|
|
|
width = 32;
|
2011-02-01 18:36:00 +01:00
|
|
|
} else if (p == QLatin1String("apple")) {
|
2011-02-23 16:47:08 +01:00
|
|
|
os = ProjectExplorer::Abi::MacOS;
|
|
|
|
|
flavor = ProjectExplorer::Abi::GenericMacFlavor;
|
|
|
|
|
format = ProjectExplorer::Abi::MachOFormat;
|
2011-02-01 18:36:00 +01:00
|
|
|
} else if (p == QLatin1String("darwin10")) {
|
|
|
|
|
width = 64;
|
2011-03-11 12:01:39 +01:00
|
|
|
} else if (p == QLatin1String("darwin9")) {
|
|
|
|
|
width = 32;
|
2011-02-01 18:36:00 +01:00
|
|
|
} else if (p == QLatin1String("gnueabi")) {
|
2011-02-23 16:47:08 +01:00
|
|
|
format = ProjectExplorer::Abi::ElfFormat;
|
2011-02-01 18:36:00 +01:00
|
|
|
} else {
|
|
|
|
|
++unknownCount;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (unknownCount == parts.count())
|
2011-03-10 14:44:49 +01:00
|
|
|
return abiList;
|
|
|
|
|
|
2011-04-08 16:33:59 +02:00
|
|
|
if (os == Abi::MacOS && arch != Abi::ArmArchitecture) {
|
2011-03-10 14:44:49 +01:00
|
|
|
// Apple does PPC and x86!
|
|
|
|
|
abiList << ProjectExplorer::Abi(arch, os, flavor, format, width);
|
2011-03-11 12:01:39 +01:00
|
|
|
abiList << ProjectExplorer::Abi(arch, os, flavor, format, width == 64 ? 32 : 64);
|
|
|
|
|
abiList << ProjectExplorer::Abi(arch == Abi::X86Architecture ? Abi::PowerPCArchitecture : Abi::X86Architecture, os, flavor, format, width);
|
|
|
|
|
abiList << ProjectExplorer::Abi(arch == Abi::X86Architecture ? Abi::PowerPCArchitecture : Abi::X86Architecture, os, flavor, format, width == 64 ? 32 : 64);
|
2011-03-10 14:44:49 +01:00
|
|
|
} else if (width == 64) {
|
|
|
|
|
abiList << ProjectExplorer::Abi(arch, os, flavor, format, width);
|
|
|
|
|
abiList << ProjectExplorer::Abi(arch, os, flavor, format, 32);
|
|
|
|
|
} else {
|
|
|
|
|
abiList << ProjectExplorer::Abi(arch, os, flavor, format, width);
|
|
|
|
|
}
|
|
|
|
|
return abiList;
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2011-03-10 14:44:49 +01:00
|
|
|
static QList<ProjectExplorer::Abi> guessGccAbi(const QString &path, const QStringList &env)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
|
|
|
|
QStringList arguments(QLatin1String("-dumpmachine"));
|
|
|
|
|
QString machine = QString::fromLocal8Bit(runGcc(path, arguments, env)).trimmed();
|
|
|
|
|
return guessGccAbi(machine);
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-06 15:19:05 +00:00
|
|
|
static QString gccVersion(const QString &path, const QStringList &env)
|
|
|
|
|
{
|
|
|
|
|
QStringList arguments(QLatin1String("-dumpversion"));
|
|
|
|
|
return QString::fromLocal8Bit(runGcc(path, arguments, env)).trimmed();
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// GccToolChain
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
GccToolChain::GccToolChain(bool autodetect) :
|
2011-03-10 14:44:49 +01:00
|
|
|
ToolChain(QLatin1String(Constants::GCC_TOOLCHAIN_ID), autodetect)
|
2011-02-01 18:36:00 +01:00
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
GccToolChain::GccToolChain(const QString &id, bool autodetect) :
|
2011-03-10 14:44:49 +01:00
|
|
|
ToolChain(id, autodetect)
|
2011-02-01 18:36:00 +01:00
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
GccToolChain::GccToolChain(const GccToolChain &tc) :
|
|
|
|
|
ToolChain(tc),
|
|
|
|
|
m_compilerPath(tc.compilerPath()),
|
2011-02-23 14:57:52 +01:00
|
|
|
m_debuggerCommand(tc.debuggerCommand()),
|
2011-02-01 18:36:00 +01:00
|
|
|
m_targetAbi(tc.m_targetAbi)
|
|
|
|
|
{
|
|
|
|
|
setCompilerPath(tc.m_compilerPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString GccToolChain::defaultDisplayName() const
|
|
|
|
|
{
|
|
|
|
|
if (!m_targetAbi.isValid())
|
|
|
|
|
return typeName();
|
|
|
|
|
return QString::fromLatin1("%1 (%2 %3)").arg(typeName(),
|
|
|
|
|
ProjectExplorer::Abi::toString(m_targetAbi.architecture()),
|
|
|
|
|
ProjectExplorer::Abi::toString(m_targetAbi.wordWidth()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GccToolChain::updateId()
|
|
|
|
|
{
|
|
|
|
|
QString i = id();
|
|
|
|
|
i = i.left(i.indexOf(QLatin1Char(':')));
|
2011-03-31 14:53:55 +02:00
|
|
|
setId(QString::fromLatin1("%1:%2.%3.%4")
|
|
|
|
|
.arg(i).arg(m_compilerPath)
|
|
|
|
|
.arg(m_targetAbi.toString()).arg(m_debuggerCommand));
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString GccToolChain::typeName() const
|
|
|
|
|
{
|
|
|
|
|
return Internal::GccToolChainFactory::tr("GCC");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Abi GccToolChain::targetAbi() const
|
|
|
|
|
{
|
|
|
|
|
return m_targetAbi;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-06 15:19:05 +00:00
|
|
|
QString GccToolChain::version() const
|
|
|
|
|
{
|
|
|
|
|
if (m_version.isEmpty())
|
|
|
|
|
m_version = detectVersion();
|
|
|
|
|
return m_version;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-10 14:44:49 +01:00
|
|
|
void GccToolChain::setTargetAbi(const Abi &abi)
|
|
|
|
|
{
|
2011-03-24 13:27:26 +01:00
|
|
|
if (abi == m_targetAbi)
|
|
|
|
|
return;
|
|
|
|
|
|
2011-03-10 14:44:49 +01:00
|
|
|
updateSupportedAbis();
|
2011-05-24 14:06:51 +00:00
|
|
|
m_targetAbi = abi;
|
2011-10-20 16:24:51 +00:00
|
|
|
updateId();
|
2011-05-24 14:06:51 +00:00
|
|
|
toolChainUpdated();
|
2011-03-10 14:44:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<Abi> GccToolChain::supportedAbis() const
|
|
|
|
|
{
|
|
|
|
|
updateSupportedAbis();
|
|
|
|
|
return m_supportedAbis;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
bool GccToolChain::isValid() const
|
|
|
|
|
{
|
|
|
|
|
return !m_compilerPath.isNull();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QByteArray GccToolChain::predefinedMacros() const
|
|
|
|
|
{
|
|
|
|
|
if (m_predefinedMacros.isEmpty()) {
|
|
|
|
|
// Using a clean environment breaks ccache/distcc/etc.
|
|
|
|
|
Utils::Environment env = Utils::Environment::systemEnvironment();
|
|
|
|
|
addToEnvironment(env);
|
|
|
|
|
m_predefinedMacros = gccPredefinedMacros(m_compilerPath, env.toStringList());
|
|
|
|
|
}
|
|
|
|
|
return m_predefinedMacros;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<HeaderPath> GccToolChain::systemHeaderPaths() const
|
|
|
|
|
{
|
|
|
|
|
if (m_headerPathes.isEmpty()) {
|
|
|
|
|
// Using a clean environment breaks ccache/distcc/etc.
|
|
|
|
|
Utils::Environment env = Utils::Environment::systemEnvironment();
|
|
|
|
|
addToEnvironment(env);
|
|
|
|
|
m_headerPathes = gccHeaderPathes(m_compilerPath, env.toStringList());
|
|
|
|
|
}
|
|
|
|
|
return m_headerPathes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GccToolChain::addToEnvironment(Utils::Environment &env) const
|
|
|
|
|
{
|
|
|
|
|
if (!m_compilerPath.isEmpty())
|
|
|
|
|
env.prependOrSetPath(QFileInfo(m_compilerPath).absolutePath());
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-22 17:32:22 +01:00
|
|
|
void GccToolChain::setDebuggerCommand(const QString &d)
|
|
|
|
|
{
|
2011-03-24 13:27:26 +01:00
|
|
|
if (m_debuggerCommand == d)
|
|
|
|
|
return;
|
2011-02-22 17:32:22 +01:00
|
|
|
m_debuggerCommand = d;
|
2011-04-14 14:49:50 +02:00
|
|
|
updateId();
|
2011-03-24 13:27:26 +01:00
|
|
|
toolChainUpdated();
|
2011-02-22 17:32:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString GccToolChain::debuggerCommand() const
|
|
|
|
|
{
|
|
|
|
|
return m_debuggerCommand;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-25 13:19:58 +01:00
|
|
|
Utils::FileName GccToolChain::mkspec() const
|
2011-04-07 13:12:55 +02:00
|
|
|
{
|
|
|
|
|
Abi abi = targetAbi();
|
2011-09-06 15:19:05 +00:00
|
|
|
if (abi.os() == Abi::MacOS) {
|
|
|
|
|
QString v = version();
|
|
|
|
|
// prefer versioned g++ on mac. This is required to enable building for older Mac OS versions
|
2011-12-15 14:10:45 +01:00
|
|
|
if (v.startsWith(QLatin1String("4.0")) && m_compilerPath.endsWith(QLatin1String("-4.0")))
|
2011-12-21 17:17:14 +01:00
|
|
|
return Utils::FileName::fromString(QLatin1String("macx-g++40"));
|
2011-12-15 14:10:45 +01:00
|
|
|
if (v.startsWith(QLatin1String("4.2")) && m_compilerPath.endsWith(QLatin1String("-4.2")))
|
2011-12-21 17:17:14 +01:00
|
|
|
return Utils::FileName::fromString(QLatin1String("macx-g++42"));
|
|
|
|
|
return Utils::FileName::fromString(QLatin1String("macx-g++"));
|
2011-09-06 15:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-08 19:44:34 +02:00
|
|
|
QList<Abi> gccAbiList = Abi::abisOfBinary(m_compilerPath);
|
|
|
|
|
Abi gccAbi;
|
|
|
|
|
if (!gccAbiList.isEmpty())
|
|
|
|
|
gccAbi = gccAbiList.first();
|
|
|
|
|
if (!gccAbi.isNull()
|
|
|
|
|
&& (gccAbi.architecture() != abi.architecture()
|
|
|
|
|
|| gccAbi.os() != abi.os()
|
|
|
|
|
|| gccAbi.osFlavor() != abi.osFlavor())) {
|
2011-09-06 15:19:05 +00:00
|
|
|
// Note: This can fail:-(
|
2011-11-25 13:19:58 +01:00
|
|
|
return Utils::FileName(); // this is a cross-compiler, leave the mkspec alone!
|
2011-09-06 15:19:05 +00:00
|
|
|
}
|
|
|
|
|
if (abi.os() == Abi::LinuxOS) {
|
|
|
|
|
if (abi.osFlavor() != Abi::GenericLinuxFlavor)
|
2011-11-25 13:19:58 +01:00
|
|
|
return Utils::FileName(); // most likely not a desktop, so leave the mkspec alone.
|
2011-09-06 15:19:05 +00:00
|
|
|
if (abi.wordWidth() == gccAbi.wordWidth())
|
2012-01-09 16:30:33 +01:00
|
|
|
return Utils::FileName::fromString(QLatin1String("linux-g++")); // no need to explicitly set the word width
|
|
|
|
|
return Utils::FileName::fromString(QLatin1String("linux-g++-") + QString::number(m_targetAbi.wordWidth()));
|
2011-09-06 15:19:05 +00:00
|
|
|
}
|
2011-05-31 10:06:32 +00:00
|
|
|
if (abi.os() == Abi::BsdOS && abi.osFlavor() == Abi::FreeBsdFlavor)
|
2012-01-09 16:30:33 +01:00
|
|
|
return Utils::FileName::fromString(QLatin1String("freebsd-g++"));
|
2011-11-25 13:19:58 +01:00
|
|
|
return Utils::FileName();
|
2011-04-07 13:12:55 +02:00
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
QString GccToolChain::makeCommand() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String("make");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IOutputParser *GccToolChain::outputParser() const
|
|
|
|
|
{
|
|
|
|
|
return new GccParser;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GccToolChain::setCompilerPath(const QString &path)
|
|
|
|
|
{
|
|
|
|
|
if (path == m_compilerPath)
|
|
|
|
|
return;
|
|
|
|
|
|
2011-04-14 14:51:28 +02:00
|
|
|
bool resetDisplayName = displayName() == defaultDisplayName();
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
m_compilerPath = path;
|
2011-03-10 14:44:49 +01:00
|
|
|
m_supportedAbis.clear();
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2011-04-14 14:51:28 +02:00
|
|
|
Abi currentAbi = m_targetAbi;
|
|
|
|
|
|
2011-03-10 14:44:49 +01:00
|
|
|
m_targetAbi = Abi();
|
|
|
|
|
if (!m_compilerPath.isEmpty()) {
|
|
|
|
|
updateSupportedAbis();
|
2011-04-14 14:51:28 +02:00
|
|
|
if (!m_supportedAbis.isEmpty()) {
|
|
|
|
|
if (m_supportedAbis.contains(currentAbi))
|
|
|
|
|
m_targetAbi = currentAbi;
|
|
|
|
|
else
|
|
|
|
|
m_targetAbi = m_supportedAbis.at(0);
|
|
|
|
|
}
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2011-04-14 14:51:28 +02:00
|
|
|
if (resetDisplayName)
|
2011-03-10 14:44:49 +01:00
|
|
|
setDisplayName(defaultDisplayName());
|
|
|
|
|
}
|
2011-03-24 13:27:26 +01:00
|
|
|
updateId(); // Will trigger toolChainUpdated()!
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString GccToolChain::compilerPath() const
|
|
|
|
|
{
|
|
|
|
|
return m_compilerPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain *GccToolChain::clone() const
|
|
|
|
|
{
|
|
|
|
|
return new GccToolChain(*this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap GccToolChain::toMap() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap data = ToolChain::toMap();
|
2011-02-22 17:32:22 +01:00
|
|
|
data.insert(QLatin1String(compilerPathKeyC), m_compilerPath);
|
2011-03-10 14:44:49 +01:00
|
|
|
data.insert(QLatin1String(targetAbiKeyC), m_targetAbi.toString());
|
2011-06-21 13:26:22 +02:00
|
|
|
QStringList abiList;
|
|
|
|
|
foreach (const ProjectExplorer::Abi &a, m_supportedAbis)
|
|
|
|
|
abiList.append(a.toString());
|
|
|
|
|
data.insert(QLatin1String(supportedAbisKeyC), abiList);
|
2011-02-22 17:32:22 +01:00
|
|
|
data.insert(QLatin1String(debuggerCommandKeyC), m_debuggerCommand);
|
2011-02-01 18:36:00 +01:00
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool GccToolChain::fromMap(const QVariantMap &data)
|
|
|
|
|
{
|
|
|
|
|
if (!ToolChain::fromMap(data))
|
|
|
|
|
return false;
|
|
|
|
|
|
2011-02-22 17:32:22 +01:00
|
|
|
m_compilerPath = data.value(QLatin1String(compilerPathKeyC)).toString();
|
2011-03-10 14:44:49 +01:00
|
|
|
m_targetAbi = Abi(data.value(QLatin1String(targetAbiKeyC)).toString());
|
2011-06-21 13:26:22 +02:00
|
|
|
QStringList abiList = data.value(QLatin1String(supportedAbisKeyC)).toStringList();
|
|
|
|
|
m_supportedAbis.clear();
|
|
|
|
|
foreach (const QString &a, abiList) {
|
|
|
|
|
ProjectExplorer::Abi abi(a);
|
|
|
|
|
if (!abi.isValid())
|
|
|
|
|
continue;
|
|
|
|
|
m_supportedAbis.append(abi);
|
|
|
|
|
}
|
2011-02-22 17:32:22 +01:00
|
|
|
m_debuggerCommand = data.value(QLatin1String(debuggerCommandKeyC)).toString();
|
2011-02-25 11:17:54 +01:00
|
|
|
updateId();
|
2011-02-01 18:36:00 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool GccToolChain::operator ==(const ToolChain &other) const
|
|
|
|
|
{
|
|
|
|
|
if (!ToolChain::operator ==(other))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
const GccToolChain *gccTc = static_cast<const GccToolChain *>(&other);
|
2011-03-10 14:44:49 +01:00
|
|
|
return m_compilerPath == gccTc->m_compilerPath && m_targetAbi == gccTc->m_targetAbi
|
2011-02-22 17:32:22 +01:00
|
|
|
&& m_debuggerCommand == gccTc->m_debuggerCommand;
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChainConfigWidget *GccToolChain::configurationWidget()
|
|
|
|
|
{
|
|
|
|
|
return new Internal::GccToolChainConfigWidget(this);
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-10 14:44:49 +01:00
|
|
|
void GccToolChain::updateSupportedAbis() const
|
|
|
|
|
{
|
2011-05-17 16:02:05 +02:00
|
|
|
if (m_supportedAbis.isEmpty())
|
|
|
|
|
m_supportedAbis = detectSupportedAbis();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<Abi> GccToolChain::detectSupportedAbis() const
|
|
|
|
|
{
|
|
|
|
|
Utils::Environment env = Utils::Environment::systemEnvironment();
|
|
|
|
|
addToEnvironment(env);
|
|
|
|
|
return guessGccAbi(m_compilerPath, env.toStringList());
|
2011-03-10 14:44:49 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-06 15:19:05 +00:00
|
|
|
QString GccToolChain::detectVersion() const
|
|
|
|
|
{
|
|
|
|
|
Utils::Environment env = Utils::Environment::systemEnvironment();
|
|
|
|
|
addToEnvironment(env);
|
|
|
|
|
return gccVersion(m_compilerPath, env.toStringList());
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// GccToolChainFactory
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
QString Internal::GccToolChainFactory::displayName() const
|
|
|
|
|
{
|
|
|
|
|
return tr("GCC");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Internal::GccToolChainFactory::id() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String(Constants::GCC_TOOLCHAIN_ID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Internal::GccToolChainFactory::canCreate()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain *Internal::GccToolChainFactory::create()
|
|
|
|
|
{
|
|
|
|
|
return createToolChain(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<ToolChain *> Internal::GccToolChainFactory::autoDetect()
|
|
|
|
|
{
|
2011-02-23 11:36:59 +01:00
|
|
|
QStringList debuggers;
|
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
|
// Fixme Prefer lldb once it is implemented: debuggers.push_back(QLatin1String("lldb"));
|
|
|
|
|
#endif
|
|
|
|
|
debuggers.push_back(QLatin1String("gdb"));
|
2011-10-31 09:52:18 +00:00
|
|
|
QList<ToolChain *> tcs = autoDetectToolchains(QLatin1String("g++"), debuggers, Abi::hostAbi());
|
|
|
|
|
|
|
|
|
|
// Old mac compilers needed to support macx-gccXY mkspecs:
|
|
|
|
|
tcs.append(autoDetectToolchains(QLatin1String("g++-4.0"), debuggers, Abi::hostAbi()));
|
|
|
|
|
tcs.append(autoDetectToolchains(QLatin1String("g++-4.2"), debuggers, Abi::hostAbi()));
|
|
|
|
|
|
|
|
|
|
return tcs;
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2011-03-16 17:59:43 +01:00
|
|
|
// Used by the ToolChainManager to restore user-generated tool chains
|
2011-02-01 18:36:00 +01:00
|
|
|
bool Internal::GccToolChainFactory::canRestore(const QVariantMap &data)
|
|
|
|
|
{
|
|
|
|
|
return idFromMap(data).startsWith(QLatin1String(Constants::GCC_TOOLCHAIN_ID) + QLatin1Char(':'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain *Internal::GccToolChainFactory::restore(const QVariantMap &data)
|
|
|
|
|
{
|
|
|
|
|
GccToolChain *tc = new GccToolChain(false);
|
|
|
|
|
if (tc->fromMap(data))
|
|
|
|
|
return tc;
|
|
|
|
|
|
|
|
|
|
delete tc;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GccToolChain *Internal::GccToolChainFactory::createToolChain(bool autoDetect)
|
|
|
|
|
{
|
|
|
|
|
return new GccToolChain(autoDetect);
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-23 11:36:59 +01:00
|
|
|
QList<ToolChain *> Internal::GccToolChainFactory::autoDetectToolchains(const QString &compiler,
|
|
|
|
|
const QStringList &debuggers,
|
|
|
|
|
const Abi &requiredAbi)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
|
|
|
|
QList<ToolChain *> result;
|
|
|
|
|
|
2011-02-23 11:36:59 +01:00
|
|
|
const Utils::Environment systemEnvironment = Utils::Environment::systemEnvironment();
|
|
|
|
|
const QString compilerPath = systemEnvironment.searchInPath(compiler);
|
|
|
|
|
if (compilerPath.isEmpty())
|
2011-02-01 18:36:00 +01:00
|
|
|
return result;
|
2011-03-10 14:44:49 +01:00
|
|
|
|
|
|
|
|
QList<Abi> abiList = guessGccAbi(compilerPath, systemEnvironment.toStringList());
|
2011-04-19 16:09:23 +02:00
|
|
|
if (!abiList.contains(requiredAbi)) {
|
|
|
|
|
if (requiredAbi.wordWidth() != 64
|
|
|
|
|
|| !abiList.contains(Abi(requiredAbi.architecture(), requiredAbi.os(), requiredAbi.osFlavor(),
|
|
|
|
|
requiredAbi.binaryFormat(), 32)))
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2011-03-10 14:44:49 +01:00
|
|
|
|
2012-01-13 14:56:58 +01:00
|
|
|
QString debuggerPath = ToolChainManager::instance()->defaultDebugger(requiredAbi).toString(); // Find the first debugger
|
2011-03-31 10:13:35 +02:00
|
|
|
if (debuggerPath.isEmpty()) {
|
|
|
|
|
foreach (const QString &debugger, debuggers) {
|
|
|
|
|
debuggerPath = systemEnvironment.searchInPath(debugger);
|
|
|
|
|
if (!debuggerPath.isEmpty())
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-02-23 11:36:59 +01:00
|
|
|
}
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2011-03-10 14:44:49 +01:00
|
|
|
foreach (const Abi &abi, abiList) {
|
|
|
|
|
QScopedPointer<GccToolChain> tc(createToolChain(true));
|
|
|
|
|
if (tc.isNull())
|
|
|
|
|
return result;
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2011-03-10 14:44:49 +01:00
|
|
|
tc->setCompilerPath(compilerPath);
|
|
|
|
|
tc->setDebuggerCommand(debuggerPath);
|
|
|
|
|
tc->setTargetAbi(abi);
|
2011-03-14 11:00:38 +01:00
|
|
|
tc->setDisplayName(tc->defaultDisplayName()); // reset displayname
|
2011-02-23 11:36:59 +01:00
|
|
|
|
|
|
|
|
result.append(tc.take());
|
2011-03-10 14:44:49 +01:00
|
|
|
}
|
2011-02-01 18:36:00 +01:00
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// GccToolChainConfigWidget
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
Internal::GccToolChainConfigWidget::GccToolChainConfigWidget(GccToolChain *tc) :
|
2011-02-22 12:25:19 +01:00
|
|
|
ToolChainConfigWidget(tc),
|
|
|
|
|
m_compilerPath(new Utils::PathChooser),
|
2011-06-27 17:24:54 +02:00
|
|
|
m_abiWidget(new AbiWidget),
|
|
|
|
|
m_isReadOnly(false)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
|
|
|
|
Q_ASSERT(tc);
|
|
|
|
|
|
2011-03-10 14:44:49 +01:00
|
|
|
QFormLayout *layout = new QFormLayout(this);
|
|
|
|
|
|
2011-02-22 17:32:22 +01:00
|
|
|
const QStringList gnuVersionArgs = QStringList(QLatin1String("--version"));
|
2011-02-01 18:36:00 +01:00
|
|
|
m_compilerPath->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
2011-02-22 17:32:22 +01:00
|
|
|
m_compilerPath->setCommandVersionArguments(gnuVersionArgs);
|
|
|
|
|
layout->addRow(tr("&Compiler path:"), m_compilerPath);
|
2011-05-24 14:06:51 +00:00
|
|
|
layout->addRow(tr("&ABI:"), m_abiWidget);
|
2011-06-08 15:39:14 +00:00
|
|
|
m_abiWidget->setEnabled(false);
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2011-04-13 15:50:14 +02:00
|
|
|
addDebuggerCommandControls(layout, gnuVersionArgs);
|
|
|
|
|
addErrorLabel(layout);
|
|
|
|
|
|
2011-02-23 11:36:59 +01:00
|
|
|
setFromToolchain();
|
2011-06-21 13:26:22 +02:00
|
|
|
|
|
|
|
|
connect(m_compilerPath, SIGNAL(changed(QString)), this, SLOT(handlePathChange()));
|
|
|
|
|
connect(m_abiWidget, SIGNAL(abiChanged()), this, SLOT(handleAbiChange()));
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Internal::GccToolChainConfigWidget::apply()
|
|
|
|
|
{
|
|
|
|
|
if (toolChain()->isAutoDetected())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
GccToolChain *tc = static_cast<GccToolChain *>(toolChain());
|
|
|
|
|
Q_ASSERT(tc);
|
|
|
|
|
QString displayName = tc->displayName();
|
|
|
|
|
QString path = m_compilerPath->path();
|
|
|
|
|
if (path.isEmpty())
|
|
|
|
|
path = m_compilerPath->rawPath();
|
|
|
|
|
tc->setCompilerPath(path);
|
2011-05-24 14:06:51 +00:00
|
|
|
tc->setTargetAbi(m_abiWidget->currentAbi());
|
2011-02-01 18:36:00 +01:00
|
|
|
tc->setDisplayName(displayName); // reset display name
|
2011-02-22 17:32:22 +01:00
|
|
|
tc->setDebuggerCommand(debuggerCommand());
|
2011-04-11 15:08:41 +02:00
|
|
|
m_autoDebuggerCommand = QLatin1String("<manually set>");
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-23 11:36:59 +01:00
|
|
|
void Internal::GccToolChainConfigWidget::setFromToolchain()
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2011-06-21 13:26:22 +02:00
|
|
|
// subwidgets are not yet connected!
|
|
|
|
|
bool blocked = blockSignals(true);
|
2011-02-01 18:36:00 +01:00
|
|
|
GccToolChain *tc = static_cast<GccToolChain *>(toolChain());
|
|
|
|
|
m_compilerPath->setPath(tc->compilerPath());
|
2011-06-08 15:39:14 +00:00
|
|
|
m_abiWidget->setAbis(tc->supportedAbis(), tc->targetAbi());
|
2011-06-27 17:24:54 +02:00
|
|
|
if (!m_isReadOnly && !m_compilerPath->path().isEmpty())
|
|
|
|
|
m_abiWidget->setEnabled(true);
|
2011-02-22 17:32:22 +01:00
|
|
|
setDebuggerCommand(tc->debuggerCommand());
|
2011-06-21 13:26:22 +02:00
|
|
|
blockSignals(blocked);
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Internal::GccToolChainConfigWidget::isDirty() const
|
|
|
|
|
{
|
|
|
|
|
GccToolChain *tc = static_cast<GccToolChain *>(toolChain());
|
|
|
|
|
Q_ASSERT(tc);
|
|
|
|
|
return m_compilerPath->path() != tc->compilerPath()
|
2011-05-24 14:06:51 +00:00
|
|
|
|| m_abiWidget->currentAbi() != tc->targetAbi();
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2011-03-29 17:51:40 +02:00
|
|
|
void Internal::GccToolChainConfigWidget::makeReadOnly()
|
|
|
|
|
{
|
|
|
|
|
m_compilerPath->setEnabled(false);
|
2011-05-24 14:06:51 +00:00
|
|
|
m_abiWidget->setEnabled(false);
|
2011-06-27 17:24:54 +02:00
|
|
|
m_isReadOnly = true;
|
2011-03-29 17:51:40 +02:00
|
|
|
ToolChainConfigWidget::makeReadOnly();
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
void Internal::GccToolChainConfigWidget::handlePathChange()
|
|
|
|
|
{
|
|
|
|
|
QString path = m_compilerPath->path();
|
2011-03-10 14:44:49 +01:00
|
|
|
QList<Abi> abiList;
|
2011-06-08 15:39:14 +00:00
|
|
|
bool haveCompiler = false;
|
|
|
|
|
if (!path.isEmpty()) {
|
|
|
|
|
QFileInfo fi(path);
|
|
|
|
|
haveCompiler = fi.isExecutable() && fi.isFile();
|
|
|
|
|
}
|
|
|
|
|
if (haveCompiler)
|
2011-03-10 14:44:49 +01:00
|
|
|
abiList = guessGccAbi(path, Utils::Environment::systemEnvironment().toStringList());
|
2011-06-08 15:39:14 +00:00
|
|
|
m_abiWidget->setEnabled(haveCompiler);
|
|
|
|
|
Abi currentAbi = m_abiWidget->currentAbi();
|
|
|
|
|
m_abiWidget->setAbis(abiList, abiList.contains(currentAbi) ? currentAbi : Abi());
|
|
|
|
|
handleAbiChange();
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2011-03-10 14:44:49 +01:00
|
|
|
void Internal::GccToolChainConfigWidget::handleAbiChange()
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2011-05-24 14:06:51 +00:00
|
|
|
if (m_autoDebuggerCommand == debuggerCommand()) {
|
|
|
|
|
ProjectExplorer::Abi abi = m_abiWidget->currentAbi();
|
2012-01-13 14:56:58 +01:00
|
|
|
m_autoDebuggerCommand = ToolChainManager::instance()->defaultDebugger(abi).toString();
|
2011-04-11 15:08:41 +02:00
|
|
|
setDebuggerCommand(m_autoDebuggerCommand);
|
|
|
|
|
}
|
2011-02-01 18:36:00 +01:00
|
|
|
emit dirty(toolChain());
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-13 11:48:34 +02:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// ClangToolChain
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
ClangToolChain::ClangToolChain(bool autodetect) :
|
2011-05-19 11:15:43 +02:00
|
|
|
GccToolChain(QLatin1String(Constants::CLANG_TOOLCHAIN_ID), autodetect)
|
2011-05-13 11:48:34 +02:00
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
QString ClangToolChain::typeName() const
|
|
|
|
|
{
|
|
|
|
|
return Internal::ClangToolChainFactory::tr("Clang");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ClangToolChain::makeCommand() const
|
|
|
|
|
{
|
|
|
|
|
#if defined(Q_OS_WIN)
|
|
|
|
|
return QLatin1String("mingw32-make.exe");
|
|
|
|
|
#else
|
|
|
|
|
return QLatin1String("make");
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-25 13:19:58 +01:00
|
|
|
Utils::FileName ClangToolChain::mkspec() const
|
2011-05-13 11:48:34 +02:00
|
|
|
{
|
2011-09-06 15:19:05 +00:00
|
|
|
Abi abi = targetAbi();
|
|
|
|
|
if (abi.os() == Abi::MacOS)
|
2012-01-09 16:30:33 +01:00
|
|
|
return Utils::FileName::fromString(QLatin1String("unsupported/macx-clang"));
|
2011-09-06 15:19:05 +00:00
|
|
|
else if (abi.os() == Abi::LinuxOS)
|
2012-01-09 16:30:33 +01:00
|
|
|
return Utils::FileName::fromString(QLatin1String("unsupported/linux-clang"));
|
2011-11-25 13:19:58 +01:00
|
|
|
return Utils::FileName(); // Note: Not supported by Qt yet, so default to the mkspec the Qt was build with
|
2011-05-18 18:38:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IOutputParser *ClangToolChain::outputParser() const
|
|
|
|
|
{
|
|
|
|
|
return new ClangParser;
|
2011-05-13 11:48:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain *ClangToolChain::clone() const
|
|
|
|
|
{
|
|
|
|
|
return new ClangToolChain(*this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// ClangToolChainFactory
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
QString Internal::ClangToolChainFactory::displayName() const
|
|
|
|
|
{
|
|
|
|
|
return tr("Clang");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Internal::ClangToolChainFactory::id() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String(Constants::CLANG_TOOLCHAIN_ID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<ToolChain *> Internal::ClangToolChainFactory::autoDetect()
|
|
|
|
|
{
|
|
|
|
|
Abi ha = Abi::hostAbi();
|
|
|
|
|
return autoDetectToolchains(QLatin1String("clang++"), QStringList(), ha);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Internal::ClangToolChainFactory::canCreate()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain *Internal::ClangToolChainFactory::create()
|
|
|
|
|
{
|
|
|
|
|
return createToolChain(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Internal::ClangToolChainFactory::canRestore(const QVariantMap &data)
|
|
|
|
|
{
|
|
|
|
|
return idFromMap(data).startsWith(QLatin1String(Constants::CLANG_TOOLCHAIN_ID) + QLatin1Char(':'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain *Internal::ClangToolChainFactory::restore(const QVariantMap &data)
|
|
|
|
|
{
|
|
|
|
|
ClangToolChain *tc = new ClangToolChain(false);
|
|
|
|
|
if (tc->fromMap(data))
|
|
|
|
|
return tc;
|
|
|
|
|
|
|
|
|
|
delete tc;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GccToolChain *Internal::ClangToolChainFactory::createToolChain(bool autoDetect)
|
|
|
|
|
{
|
|
|
|
|
return new ClangToolChain(autoDetect);
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// MingwToolChain
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
MingwToolChain::MingwToolChain(bool autodetect) :
|
|
|
|
|
GccToolChain(QLatin1String(Constants::MINGW_TOOLCHAIN_ID), autodetect)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
QString MingwToolChain::typeName() const
|
|
|
|
|
{
|
|
|
|
|
return Internal::MingwToolChainFactory::tr("MinGW");
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-25 13:19:58 +01:00
|
|
|
Utils::FileName MingwToolChain::mkspec() const
|
2011-04-07 13:12:55 +02:00
|
|
|
{
|
2012-01-09 16:30:33 +01:00
|
|
|
return Utils::FileName::fromString(QLatin1String("win32-g++"));
|
2011-04-07 13:12:55 +02:00
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
QString MingwToolChain::makeCommand() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String("mingw32-make.exe");
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-06 13:52:28 +01:00
|
|
|
QString MingwToolChain::findInstalledJom()
|
|
|
|
|
{
|
|
|
|
|
if (Abi::hostAbi().os() != Abi::WindowsOS) {
|
|
|
|
|
qWarning() << "Jom can only be used on Windows";
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We want jom! Try to find it.
|
|
|
|
|
const QString jom = QLatin1String("jom.exe");
|
|
|
|
|
const QFileInfo installedJom = QFileInfo(QCoreApplication::applicationDirPath()
|
|
|
|
|
+ QLatin1Char('/') + jom);
|
|
|
|
|
if (installedJom.isFile() && installedJom.isExecutable())
|
|
|
|
|
return installedJom.absoluteFilePath();
|
|
|
|
|
else
|
|
|
|
|
return jom;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
ToolChain *MingwToolChain::clone() const
|
|
|
|
|
{
|
|
|
|
|
return new MingwToolChain(*this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// MingwToolChainFactory
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
QString Internal::MingwToolChainFactory::displayName() const
|
|
|
|
|
{
|
|
|
|
|
return tr("MinGW");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Internal::MingwToolChainFactory::id() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String(Constants::MINGW_TOOLCHAIN_ID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<ToolChain *> Internal::MingwToolChainFactory::autoDetect()
|
|
|
|
|
{
|
2011-04-13 16:45:38 +02:00
|
|
|
// Compatibility to pre-2.2:
|
|
|
|
|
// All Mingw toolchains that exist so far are either installed by the SDK itself (in
|
|
|
|
|
// which case they most likely have debuggers set up) or were created when updating
|
|
|
|
|
// from a previous Qt version. Add debugger in that case.
|
|
|
|
|
foreach (ToolChain *tc, ToolChainManager::instance()->toolChains()) {
|
|
|
|
|
if (tc->debuggerCommand().isEmpty() && tc->id().startsWith(QLatin1String(Constants::MINGW_TOOLCHAIN_ID)))
|
|
|
|
|
static_cast<MingwToolChain *>(tc)
|
2012-01-13 14:56:58 +01:00
|
|
|
->setDebuggerCommand(ToolChainManager::instance()->defaultDebugger(tc->targetAbi()).toString());
|
2011-04-13 16:45:38 +02:00
|
|
|
}
|
|
|
|
|
|
2011-03-17 14:37:54 +01:00
|
|
|
Abi ha = Abi::hostAbi();
|
|
|
|
|
return autoDetectToolchains(QLatin1String("g++"), QStringList(),
|
|
|
|
|
Abi(ha.architecture(), Abi::WindowsOS, Abi::WindowsMSysFlavor, Abi::PEFormat, ha.wordWidth()));
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Internal::MingwToolChainFactory::canCreate()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain *Internal::MingwToolChainFactory::create()
|
|
|
|
|
{
|
|
|
|
|
return createToolChain(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Internal::MingwToolChainFactory::canRestore(const QVariantMap &data)
|
|
|
|
|
{
|
|
|
|
|
return idFromMap(data).startsWith(QLatin1String(Constants::MINGW_TOOLCHAIN_ID) + QLatin1Char(':'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain *Internal::MingwToolChainFactory::restore(const QVariantMap &data)
|
|
|
|
|
{
|
|
|
|
|
MingwToolChain *tc = new MingwToolChain(false);
|
|
|
|
|
if (tc->fromMap(data))
|
|
|
|
|
return tc;
|
|
|
|
|
|
|
|
|
|
delete tc;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GccToolChain *Internal::MingwToolChainFactory::createToolChain(bool autoDetect)
|
|
|
|
|
{
|
|
|
|
|
return new MingwToolChain(autoDetect);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// LinuxIccToolChain
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
LinuxIccToolChain::LinuxIccToolChain(bool autodetect) :
|
|
|
|
|
GccToolChain(QLatin1String(Constants::LINUXICC_TOOLCHAIN_ID), autodetect)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
QString LinuxIccToolChain::typeName() const
|
|
|
|
|
{
|
|
|
|
|
return Internal::LinuxIccToolChainFactory::tr("Linux ICC");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IOutputParser *LinuxIccToolChain::outputParser() const
|
|
|
|
|
{
|
|
|
|
|
return new LinuxIccParser;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-25 13:19:58 +01:00
|
|
|
Utils::FileName LinuxIccToolChain::mkspec() const
|
2011-04-07 13:12:55 +02:00
|
|
|
{
|
2012-01-09 16:30:33 +01:00
|
|
|
return Utils::FileName::fromString(QLatin1String("linux-icc-") + QString::number(targetAbi().wordWidth()));
|
2011-04-07 13:12:55 +02:00
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
ToolChain *LinuxIccToolChain::clone() const
|
|
|
|
|
{
|
|
|
|
|
return new LinuxIccToolChain(*this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// LinuxIccToolChainFactory
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
QString Internal::LinuxIccToolChainFactory::displayName() const
|
|
|
|
|
{
|
|
|
|
|
return tr("Linux ICC");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Internal::LinuxIccToolChainFactory::id() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String(Constants::LINUXICC_TOOLCHAIN_ID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<ToolChain *> Internal::LinuxIccToolChainFactory::autoDetect()
|
|
|
|
|
{
|
2011-02-23 11:36:59 +01:00
|
|
|
return autoDetectToolchains(QLatin1String("icpc"),
|
|
|
|
|
QStringList(QLatin1String("gdb")),
|
|
|
|
|
Abi::hostAbi());
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain *Internal::LinuxIccToolChainFactory::create()
|
|
|
|
|
{
|
|
|
|
|
return createToolChain(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Internal::LinuxIccToolChainFactory::canRestore(const QVariantMap &data)
|
|
|
|
|
{
|
|
|
|
|
return idFromMap(data).startsWith(QLatin1String(Constants::LINUXICC_TOOLCHAIN_ID) + QLatin1Char(':'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain *Internal::LinuxIccToolChainFactory::restore(const QVariantMap &data)
|
|
|
|
|
{
|
|
|
|
|
LinuxIccToolChain *tc = new LinuxIccToolChain(false);
|
|
|
|
|
if (tc->fromMap(data))
|
|
|
|
|
return tc;
|
|
|
|
|
|
|
|
|
|
delete tc;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GccToolChain *Internal::LinuxIccToolChainFactory::createToolChain(bool autoDetect)
|
|
|
|
|
{
|
|
|
|
|
return new LinuxIccToolChain(autoDetect);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace ProjectExplorer
|
|
|
|
|
|
|
|
|
|
// Unit tests:
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_TESTS
|
|
|
|
|
# include "projectexplorer.h"
|
|
|
|
|
|
|
|
|
|
# include <QTest>
|
|
|
|
|
# include <QtCore/QUrl>
|
|
|
|
|
|
|
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
void ProjectExplorerPlugin::testGccAbiGuessing_data()
|
|
|
|
|
{
|
|
|
|
|
QTest::addColumn<QString>("input");
|
2011-03-10 14:44:49 +01:00
|
|
|
QTest::addColumn<QStringList>("abiList");
|
2011-02-01 18:36:00 +01:00
|
|
|
|
|
|
|
|
QTest::newRow("invalid input")
|
|
|
|
|
<< QString::fromLatin1("Some text")
|
2011-03-10 14:44:49 +01:00
|
|
|
<< (QStringList());
|
2011-02-01 18:36:00 +01:00
|
|
|
QTest::newRow("empty input")
|
|
|
|
|
<< QString::fromLatin1("")
|
2011-03-10 14:44:49 +01:00
|
|
|
<< (QStringList());
|
2011-02-01 18:36:00 +01:00
|
|
|
QTest::newRow("broken input")
|
|
|
|
|
<< QString::fromLatin1("arm-none-foo-gnueabi")
|
2011-05-18 18:38:58 +02:00
|
|
|
<< (QStringList() << QLatin1String("arm-unknown-unknown-unknown-32bit"));
|
2011-03-10 14:44:49 +01:00
|
|
|
QTest::newRow("totally broken input")
|
|
|
|
|
<< QString::fromLatin1("foo-bar-foo")
|
|
|
|
|
<< (QStringList());
|
2011-02-01 18:36:00 +01:00
|
|
|
|
|
|
|
|
QTest::newRow("Maemo 1")
|
|
|
|
|
<< QString::fromLatin1("arm-none-linux-gnueabi")
|
2011-03-10 14:44:49 +01:00
|
|
|
<< (QStringList() << QLatin1String("arm-linux-generic-elf-32bit"));
|
2011-02-01 18:36:00 +01:00
|
|
|
QTest::newRow("Linux 1")
|
|
|
|
|
<< QString::fromLatin1("i686-linux-gnu")
|
2011-03-10 14:44:49 +01:00
|
|
|
<< (QStringList() << QLatin1String("x86-linux-generic-elf-32bit"));
|
2011-02-01 18:36:00 +01:00
|
|
|
QTest::newRow("Linux 2")
|
|
|
|
|
<< QString::fromLatin1("i486-linux-gnu")
|
2011-03-10 14:44:49 +01:00
|
|
|
<< (QStringList() << QLatin1String("x86-linux-generic-elf-32bit"));
|
2011-02-01 18:36:00 +01:00
|
|
|
QTest::newRow("Linux 3")
|
|
|
|
|
<< QString::fromLatin1("x86_64-linux-gnu")
|
2011-03-10 14:44:49 +01:00
|
|
|
<< (QStringList() << QLatin1String("x86-linux-generic-elf-64bit")
|
|
|
|
|
<< QLatin1String("x86-linux-generic-elf-32bit"));
|
2011-04-06 10:04:57 +02:00
|
|
|
QTest::newRow("Linux 4")
|
|
|
|
|
<< QString::fromLatin1("mipsel-linux-uclibc")
|
|
|
|
|
<< (QStringList() << QLatin1String("mips-linux-generic-elf-32bit"));
|
2011-05-03 14:40:20 +02:00
|
|
|
QTest::newRow("Linux 5") // from QTCREATORBUG-4690
|
|
|
|
|
<< QString::fromLatin1("x86_64-redhat-linux6E")
|
|
|
|
|
<< (QStringList() << QLatin1String("x86-linux-generic-elf-64bit")
|
|
|
|
|
<< QLatin1String("x86-linux-generic-elf-32bit"));
|
|
|
|
|
QTest::newRow("Linux 6") // from QTCREATORBUG-4690
|
|
|
|
|
<< QString::fromLatin1("x86_64-redhat-linux")
|
|
|
|
|
<< (QStringList() << QLatin1String("x86-linux-generic-elf-64bit")
|
|
|
|
|
<< QLatin1String("x86-linux-generic-elf-32bit"));
|
2011-05-11 12:14:07 +02:00
|
|
|
QTest::newRow("Linux 7") // Meego
|
|
|
|
|
<< QString::fromLatin1("armv5tel-meego-linux-gnueabi")
|
|
|
|
|
<< (QStringList() << QLatin1String("arm-linux-meego-elf-32bit"));
|
2011-07-01 13:39:54 +02:00
|
|
|
QTest::newRow("Linux 8")
|
|
|
|
|
<< QString::fromLatin1("armv5tl-montavista-linux-gnueabi")
|
|
|
|
|
<< (QStringList() << QLatin1String("arm-linux-generic-elf-32bit"));
|
2011-08-31 15:24:24 +00:00
|
|
|
QTest::newRow("Linux 9")
|
|
|
|
|
<< QString::fromLatin1("arm-angstrom-linux-gnueabi")
|
|
|
|
|
<< (QStringList() << QLatin1String("arm-linux-generic-elf-32bit"));
|
2011-07-01 13:39:54 +02:00
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
QTest::newRow("Mingw 1")
|
|
|
|
|
<< QString::fromLatin1("i686-w64-mingw32")
|
2011-03-10 14:44:49 +01:00
|
|
|
<< (QStringList() << QLatin1String("x86-windows-msys-pe-64bit")
|
|
|
|
|
<< QLatin1String("x86-windows-msys-pe-32bit"));
|
2011-02-01 18:36:00 +01:00
|
|
|
QTest::newRow("Mingw 2")
|
|
|
|
|
<< QString::fromLatin1("mingw32")
|
2011-03-10 14:44:49 +01:00
|
|
|
<< (QStringList() << QLatin1String("x86-windows-msys-pe-32bit"));
|
2011-05-13 11:48:34 +02:00
|
|
|
QTest::newRow("Clang 1: windows")
|
|
|
|
|
<< QString::fromLatin1("x86_64-pc-win32")
|
|
|
|
|
<< (QStringList() << QLatin1String("x86-windows-msys-pe-64bit")
|
|
|
|
|
<< QLatin1String("x86-windows-msys-pe-32bit"));
|
|
|
|
|
QTest::newRow("Clang 1: linux")
|
|
|
|
|
<< QString::fromLatin1("x86_64-unknown-linux-gnu")
|
|
|
|
|
<< (QStringList() << QLatin1String("x86-linux-generic-elf-64bit")
|
|
|
|
|
<< QLatin1String("x86-linux-generic-elf-32bit"));
|
2011-02-01 18:36:00 +01:00
|
|
|
QTest::newRow("Mac 1")
|
|
|
|
|
<< QString::fromLatin1("i686-apple-darwin10")
|
2011-03-10 14:44:49 +01:00
|
|
|
<< (QStringList() << QLatin1String("x86-macos-generic-mach_o-64bit")
|
|
|
|
|
<< QLatin1String("x86-macos-generic-mach_o-32bit")
|
|
|
|
|
<< QLatin1String("ppc-macos-generic-mach_o-64bit")
|
|
|
|
|
<< QLatin1String("ppc-macos-generic-mach_o-32bit"));
|
2011-03-11 12:01:39 +01:00
|
|
|
QTest::newRow("Mac 2")
|
|
|
|
|
<< QString::fromLatin1("powerpc-apple-darwin10")
|
|
|
|
|
<< (QStringList() << QLatin1String("ppc-macos-generic-mach_o-64bit")
|
|
|
|
|
<< QLatin1String("ppc-macos-generic-mach_o-32bit")
|
|
|
|
|
<< QLatin1String("x86-macos-generic-mach_o-64bit")
|
|
|
|
|
<< QLatin1String("x86-macos-generic-mach_o-32bit"));
|
|
|
|
|
QTest::newRow("Mac 3")
|
|
|
|
|
<< QString::fromLatin1("i686-apple-darwin9")
|
|
|
|
|
<< (QStringList() << QLatin1String("x86-macos-generic-mach_o-32bit")
|
|
|
|
|
<< QLatin1String("x86-macos-generic-mach_o-64bit")
|
|
|
|
|
<< QLatin1String("ppc-macos-generic-mach_o-32bit")
|
|
|
|
|
<< QLatin1String("ppc-macos-generic-mach_o-64bit"));
|
2011-04-08 16:33:59 +02:00
|
|
|
QTest::newRow("Mac IOS")
|
|
|
|
|
<< QString::fromLatin1("arm-apple-darwin9")
|
|
|
|
|
<< (QStringList() << QLatin1String("arm-macos-generic-mach_o-32bit"));
|
2011-02-01 18:36:00 +01:00
|
|
|
QTest::newRow("Intel 1")
|
|
|
|
|
<< QString::fromLatin1("86_64 x86_64 GNU/Linux")
|
2011-03-10 14:44:49 +01:00
|
|
|
<< (QStringList() << QLatin1String("x86-linux-generic-elf-64bit")
|
|
|
|
|
<< QLatin1String("x86-linux-generic-elf-32bit"));
|
2011-02-22 12:09:27 +01:00
|
|
|
QTest::newRow("Symbian 1")
|
|
|
|
|
<< QString::fromLatin1("arm-none-symbianelf")
|
2011-03-10 14:44:49 +01:00
|
|
|
<< (QStringList() << QLatin1String("arm-symbian-device-elf-32bit"));
|
2011-05-31 10:06:32 +00:00
|
|
|
QTest::newRow("FreeBSD 1")
|
|
|
|
|
<< QString::fromLatin1("i386-portbld-freebsd9.0")
|
|
|
|
|
<< (QStringList() << QLatin1String("x86-bsd-freebsd-elf-32bit"));
|
|
|
|
|
QTest::newRow("FreeBSD 2")
|
|
|
|
|
<< QString::fromLatin1("i386-undermydesk-freebsd")
|
|
|
|
|
<< (QStringList() << QLatin1String("x86-bsd-freebsd-elf-32bit"));
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProjectExplorerPlugin::testGccAbiGuessing()
|
|
|
|
|
{
|
|
|
|
|
QFETCH(QString, input);
|
2011-03-10 14:44:49 +01:00
|
|
|
QFETCH(QStringList, abiList);
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2011-03-10 14:44:49 +01:00
|
|
|
QList<ProjectExplorer::Abi> al = guessGccAbi(input);
|
|
|
|
|
QCOMPARE(al.count(), abiList.count());
|
|
|
|
|
for (int i = 0; i < al.count(); ++i) {
|
|
|
|
|
QCOMPARE(al.at(i).toString(), abiList.at(i));
|
|
|
|
|
}
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace ProjectExplorer
|
|
|
|
|
|
|
|
|
|
#endif
|