2011-02-01 18:36:00 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2011-02-01 18:36:00 +01:00
|
|
|
**
|
2012-07-19 12:26:56 +02:00
|
|
|
** Contact: http://www.qt-project.org/
|
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
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#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
|
|
|
|
2012-06-28 20:54:37 +02:00
|
|
|
#include <utils/detailswidget.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
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QBuffer>
|
|
|
|
|
#include <QCoreApplication>
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QProcess>
|
|
|
|
|
#include <QScopedPointer>
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QFormLayout>
|
|
|
|
|
#include <QLabel>
|
2011-02-01 18:36:00 +01:00
|
|
|
|
|
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// Helpers:
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
2012-02-01 14:39:11 +01:00
|
|
|
static const char compilerCommandKeyC[] = "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-01 18:36:00 +01:00
|
|
|
|
2012-06-20 15:38:40 +02:00
|
|
|
static const char LEGACY_MAEMO_ID[] = "Qt4ProjectManager.ToolChain.Maemo:";
|
|
|
|
|
|
2012-01-30 13:07:51 +01:00
|
|
|
static QByteArray runGcc(const Utils::FileName &gcc, const QStringList &arguments, const QStringList &env)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2012-01-30 13:07:51 +01:00
|
|
|
if (gcc.isEmpty() || !gcc.toFileInfo().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);
|
2012-01-30 13:07:51 +01:00
|
|
|
cpp.start(gcc.toString(), arguments);
|
2011-02-01 18:36:00 +01:00
|
|
|
if (!cpp.waitForStarted()) {
|
2012-01-30 13:07:51 +01:00
|
|
|
qWarning("%s: Cannot start '%s': %s", Q_FUNC_INFO, qPrintable(gcc.toUserOutput()),
|
2011-02-01 18:36:00 +01:00
|
|
|
qPrintable(cpp.errorString()));
|
|
|
|
|
return QByteArray();
|
|
|
|
|
}
|
|
|
|
|
cpp.closeWriteChannel();
|
|
|
|
|
if (!cpp.waitForFinished()) {
|
|
|
|
|
Utils::SynchronousProcess::stopProcess(cpp);
|
2012-01-30 13:07:51 +01:00
|
|
|
qWarning("%s: Timeout running '%s'.", Q_FUNC_INFO, qPrintable(gcc.toUserOutput()));
|
2011-02-01 18:36:00 +01:00
|
|
|
return QByteArray();
|
|
|
|
|
}
|
|
|
|
|
if (cpp.exitStatus() != QProcess::NormalExit) {
|
2012-01-30 13:07:51 +01:00
|
|
|
qWarning("%s: '%s' crashed.", Q_FUNC_INFO, qPrintable(gcc.toUserOutput()));
|
2011-02-01 18:36:00 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2012-02-16 15:09:56 +01:00
|
|
|
static QByteArray gccPredefinedMacros(const Utils::FileName &gcc, const QStringList &args, const QStringList &env)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
|
|
|
|
QStringList arguments;
|
|
|
|
|
arguments << QLatin1String("-xc++")
|
|
|
|
|
<< QLatin1String("-E")
|
2012-02-16 15:09:56 +01:00
|
|
|
<< 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.startsWith(QLatin1String("-std=")) || a.startsWith(QLatin1String("-specs="))
|
|
|
|
|
|| a == QLatin1String("-ansi")
|
|
|
|
|
|| a.startsWith(QLatin1String("-D")) || a.startsWith(QLatin1String("-U"))
|
|
|
|
|
|| a == QLatin1String("-undef"))
|
|
|
|
|
arguments << a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
arguments << QLatin1String("-");
|
2011-02-01 18:36:00 +01:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-04 12:06:07 +02:00
|
|
|
QList<HeaderPath> GccToolChain::gccHeaderPaths(const Utils::FileName &gcc, const QStringList &env, const QString &sysrootPath)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
|
|
|
|
QList<HeaderPath> systemHeaderPaths;
|
|
|
|
|
QStringList arguments;
|
2012-04-04 12:06:07 +02:00
|
|
|
if (!sysrootPath.isEmpty())
|
|
|
|
|
arguments.append(QString::fromLatin1("--sysroot=%1").arg(sysrootPath));
|
2011-02-01 18:36:00 +01:00
|
|
|
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;
|
2012-02-01 17:09:59 +01:00
|
|
|
} else if (p == QLatin1String("x86_64") || p == QLatin1String("amd64")) {
|
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-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;
|
2012-02-01 17:09:59 +01:00
|
|
|
} else if (p == QLatin1String("mingw32") || p == QLatin1String("win32") || p == QLatin1String("mingw32msvc")) {
|
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
|
|
|
}
|
|
|
|
|
|
2012-01-30 13:07:51 +01:00
|
|
|
static QList<ProjectExplorer::Abi> guessGccAbi(const Utils::FileName &path, const QStringList &env)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2012-02-09 13:45:08 +01:00
|
|
|
if (path.isEmpty())
|
|
|
|
|
return QList<ProjectExplorer::Abi>();
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
QStringList arguments(QLatin1String("-dumpmachine"));
|
|
|
|
|
QString machine = QString::fromLocal8Bit(runGcc(path, arguments, env)).trimmed();
|
|
|
|
|
return guessGccAbi(machine);
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-30 13:07:51 +01:00
|
|
|
static QString gccVersion(const Utils::FileName &path, const QStringList &env)
|
2011-09-06 15:19:05 +00:00
|
|
|
{
|
|
|
|
|
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),
|
2012-02-16 15:09:56 +01:00
|
|
|
m_predefinedMacros(tc.predefinedMacros(QStringList())),
|
2012-02-01 14:39:11 +01:00
|
|
|
m_compilerCommand(tc.compilerCommand()),
|
2012-01-30 18:07:24 +01:00
|
|
|
m_targetAbi(tc.m_targetAbi),
|
|
|
|
|
m_supportedAbis(tc.m_supportedAbis),
|
2012-04-04 12:06:07 +02:00
|
|
|
m_headerPaths(tc.m_headerPaths),
|
2012-01-30 18:07:24 +01:00
|
|
|
m_version(tc.m_version)
|
|
|
|
|
{ }
|
2011-02-01 18:36:00 +01:00
|
|
|
|
|
|
|
|
QString GccToolChain::defaultDisplayName() const
|
|
|
|
|
{
|
|
|
|
|
if (!m_targetAbi.isValid())
|
2012-01-30 11:55:21 +01:00
|
|
|
return typeDisplayName();
|
|
|
|
|
return QString::fromLatin1("%1 (%2 %3)").arg(typeDisplayName(),
|
2011-02-01 18:36:00 +01:00
|
|
|
ProjectExplorer::Abi::toString(m_targetAbi.architecture()),
|
|
|
|
|
ProjectExplorer::Abi::toString(m_targetAbi.wordWidth()));
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-30 11:55:21 +01:00
|
|
|
QString GccToolChain::type() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String("gcc");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString GccToolChain::typeDisplayName() const
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
|
|
|
|
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-05-24 14:06:51 +00:00
|
|
|
m_targetAbi = abi;
|
|
|
|
|
toolChainUpdated();
|
2011-03-10 14:44:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<Abi> GccToolChain::supportedAbis() const
|
|
|
|
|
{
|
|
|
|
|
return m_supportedAbis;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
bool GccToolChain::isValid() const
|
|
|
|
|
{
|
2012-02-01 14:39:11 +01:00
|
|
|
return !m_compilerCommand.isNull();
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-16 15:09:56 +01:00
|
|
|
QByteArray GccToolChain::predefinedMacros(const QStringList &cxxflags) const
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
|
|
|
|
if (m_predefinedMacros.isEmpty()) {
|
|
|
|
|
// Using a clean environment breaks ccache/distcc/etc.
|
|
|
|
|
Utils::Environment env = Utils::Environment::systemEnvironment();
|
|
|
|
|
addToEnvironment(env);
|
2012-02-16 15:09:56 +01:00
|
|
|
m_predefinedMacros = gccPredefinedMacros(m_compilerCommand, cxxflags, env.toStringList());
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
return m_predefinedMacros;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-16 15:09:56 +01:00
|
|
|
ProjectExplorer::ToolChain::CompilerFlags GccToolChain::compilerFlags(const QStringList &cxxflags) const
|
|
|
|
|
{
|
|
|
|
|
if (cxxflags.contains("-std=c++0x") || cxxflags.contains("-std=gnu++0x"))
|
|
|
|
|
return STD_CXX11;
|
|
|
|
|
return NO_FLAGS;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
QList<HeaderPath> GccToolChain::systemHeaderPaths() const
|
|
|
|
|
{
|
2012-04-04 12:06:07 +02:00
|
|
|
if (m_headerPaths.isEmpty()) {
|
2011-02-01 18:36:00 +01:00
|
|
|
// Using a clean environment breaks ccache/distcc/etc.
|
|
|
|
|
Utils::Environment env = Utils::Environment::systemEnvironment();
|
|
|
|
|
addToEnvironment(env);
|
2012-04-04 12:06:07 +02:00
|
|
|
m_headerPaths = gccHeaderPaths(m_compilerCommand, env.toStringList());
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
2012-04-04 12:06:07 +02:00
|
|
|
return m_headerPaths;
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GccToolChain::addToEnvironment(Utils::Environment &env) const
|
|
|
|
|
{
|
2012-02-01 16:13:38 +01:00
|
|
|
if (!m_compilerCommand.isEmpty()) {
|
|
|
|
|
Utils::FileName path = m_compilerCommand.parentDir();
|
|
|
|
|
env.prependOrSetPath(path.toString());
|
|
|
|
|
}
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-07 18:05:09 +01:00
|
|
|
QList<Utils::FileName> GccToolChain::suggestedMkspecList() const
|
2011-04-07 13:12:55 +02:00
|
|
|
{
|
|
|
|
|
Abi abi = targetAbi();
|
2012-02-02 11:56:09 +01:00
|
|
|
Abi host = Abi::hostAbi();
|
|
|
|
|
|
|
|
|
|
// Cross compile: Leave the mkspec alone!
|
|
|
|
|
if (abi.architecture() != host.architecture()
|
|
|
|
|
|| abi.os() != host.os()
|
|
|
|
|
|| abi.osFlavor() != host.osFlavor()) // Note: This can fail:-(
|
2012-02-07 18:05:09 +01:00
|
|
|
return QList<Utils::FileName>();
|
2012-02-02 11:56:09 +01:00
|
|
|
|
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
|
2012-02-01 14:39:11 +01:00
|
|
|
if (v.startsWith(QLatin1String("4.0")) && m_compilerCommand.endsWith(QLatin1String("-4.0")))
|
2012-02-07 18:05:09 +01:00
|
|
|
return QList<Utils::FileName>() << Utils::FileName::fromString(QLatin1String("macx-g++40"));
|
2012-02-01 14:39:11 +01:00
|
|
|
if (v.startsWith(QLatin1String("4.2")) && m_compilerCommand.endsWith(QLatin1String("-4.2")))
|
2012-02-07 18:05:09 +01:00
|
|
|
return QList<Utils::FileName>() << Utils::FileName::fromString(QLatin1String("macx-g++42"));
|
|
|
|
|
return QList<Utils::FileName>() << Utils::FileName::fromString(QLatin1String("macx-g++"));
|
2011-09-06 15:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (abi.os() == Abi::LinuxOS) {
|
|
|
|
|
if (abi.osFlavor() != Abi::GenericLinuxFlavor)
|
2012-02-07 18:05:09 +01:00
|
|
|
return QList<Utils::FileName>(); // most likely not a desktop, so leave the mkspec alone.
|
2012-08-08 14:19:29 +02:00
|
|
|
if (abi.wordWidth() == host.wordWidth()) {
|
|
|
|
|
// no need to explicitly set the word width, but provide that mkspec anyway to make sure
|
|
|
|
|
// that the correct compiler is picked if a mkspec with a wordwidth is given.
|
|
|
|
|
return QList<Utils::FileName>() << Utils::FileName::fromString(QLatin1String("linux-g++"))
|
|
|
|
|
<< Utils::FileName::fromString(QLatin1String("linux-g++-") + QString::number(m_targetAbi.wordWidth()));
|
|
|
|
|
}
|
2012-02-07 18:05:09 +01:00
|
|
|
return QList<Utils::FileName>() << Utils::FileName::fromString(QLatin1String("linux-g++-") + QString::number(m_targetAbi.wordWidth()));
|
2011-09-06 15:19:05 +00:00
|
|
|
}
|
2012-02-02 11:56:09 +01:00
|
|
|
|
2011-05-31 10:06:32 +00:00
|
|
|
if (abi.os() == Abi::BsdOS && abi.osFlavor() == Abi::FreeBsdFlavor)
|
2012-02-07 18:05:09 +01:00
|
|
|
return QList<Utils::FileName>() << Utils::FileName::fromString(QLatin1String("freebsd-g++"));
|
2012-02-02 11:56:09 +01:00
|
|
|
|
2012-02-07 18:05:09 +01:00
|
|
|
return QList<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;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-30 13:07:51 +01:00
|
|
|
void GccToolChain::setCompilerCommand(const Utils::FileName &path)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2012-02-01 14:39:11 +01:00
|
|
|
if (path == m_compilerCommand)
|
2011-02-01 18:36:00 +01:00
|
|
|
return;
|
|
|
|
|
|
2011-04-14 14:51:28 +02:00
|
|
|
bool resetDisplayName = displayName() == defaultDisplayName();
|
|
|
|
|
|
2012-02-01 14:39:11 +01:00
|
|
|
m_compilerCommand = path;
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2011-04-14 14:51:28 +02:00
|
|
|
Abi currentAbi = m_targetAbi;
|
2012-02-09 13:45:08 +01:00
|
|
|
m_supportedAbis = detectSupportedAbis();
|
2011-04-14 14:51:28 +02:00
|
|
|
|
2011-03-10 14:44:49 +01:00
|
|
|
m_targetAbi = Abi();
|
2012-01-30 18:07:24 +01:00
|
|
|
if (!m_supportedAbis.isEmpty()) {
|
|
|
|
|
if (m_supportedAbis.contains(currentAbi))
|
|
|
|
|
m_targetAbi = currentAbi;
|
|
|
|
|
else
|
|
|
|
|
m_targetAbi = m_supportedAbis.at(0);
|
2011-03-10 14:44:49 +01:00
|
|
|
}
|
2012-01-30 18:07:24 +01:00
|
|
|
|
|
|
|
|
if (resetDisplayName)
|
|
|
|
|
setDisplayName(defaultDisplayName()); // calls toolChainUpdated()!
|
|
|
|
|
else
|
|
|
|
|
toolChainUpdated();
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2012-01-30 13:07:51 +01:00
|
|
|
Utils::FileName GccToolChain::compilerCommand() const
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2012-02-01 14:39:11 +01:00
|
|
|
return m_compilerCommand;
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain *GccToolChain::clone() const
|
|
|
|
|
{
|
|
|
|
|
return new GccToolChain(*this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap GccToolChain::toMap() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap data = ToolChain::toMap();
|
2012-02-01 14:39:11 +01:00
|
|
|
data.insert(QLatin1String(compilerCommandKeyC), m_compilerCommand.toString());
|
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-01 18:36:00 +01:00
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool GccToolChain::fromMap(const QVariantMap &data)
|
|
|
|
|
{
|
|
|
|
|
if (!ToolChain::fromMap(data))
|
|
|
|
|
return false;
|
|
|
|
|
|
2012-02-01 14:39:11 +01:00
|
|
|
m_compilerCommand = Utils::FileName::fromString(data.value(QLatin1String(compilerCommandKeyC)).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-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);
|
2012-04-24 15:49:09 +02:00
|
|
|
return m_compilerCommand == gccTc->m_compilerCommand && m_targetAbi == gccTc->m_targetAbi;
|
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);
|
2012-02-01 14:39:11 +01:00
|
|
|
return guessGccAbi(m_compilerCommand, 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);
|
2012-02-01 14:39:11 +01:00
|
|
|
return gccVersion(m_compilerCommand, env.toStringList());
|
2011-09-06 15:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
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()
|
|
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
QList<ToolChain *> tcs;
|
2011-02-23 11:36:59 +01:00
|
|
|
#ifdef Q_OS_MAC
|
2011-10-31 09:52:18 +00:00
|
|
|
// Old mac compilers needed to support macx-gccXY mkspecs:
|
2012-04-24 15:49:09 +02:00
|
|
|
tcs.append(autoDetectToolchains(QLatin1String("g++-4.0"), Abi::hostAbi()));
|
|
|
|
|
tcs.append(autoDetectToolchains(QLatin1String("g++-4.2"), Abi::hostAbi()));
|
|
|
|
|
#endif
|
|
|
|
|
tcs.append(autoDetectToolchains(QLatin1String("g++"), Abi::hostAbi()));
|
2011-10-31 09:52:18 +00:00
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2012-06-20 15:38:40 +02:00
|
|
|
const QString id = idFromMap(data);
|
|
|
|
|
return id.startsWith(QLatin1String(Constants::GCC_TOOLCHAIN_ID) + QLatin1Char(':'))
|
|
|
|
|
|| id.startsWith(QLatin1String(LEGACY_MAEMO_ID));
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain *Internal::GccToolChainFactory::restore(const QVariantMap &data)
|
|
|
|
|
{
|
|
|
|
|
GccToolChain *tc = new GccToolChain(false);
|
2012-06-20 15:38:40 +02:00
|
|
|
// Updating from 2.5:
|
|
|
|
|
QVariantMap updated = data;
|
|
|
|
|
QString id = idFromMap(updated);
|
|
|
|
|
if (id.startsWith(LEGACY_MAEMO_ID)) {
|
|
|
|
|
id = QString::fromLatin1(Constants::GCC_TOOLCHAIN_ID).append(id.mid(id.indexOf(QLatin1Char(':'))));
|
|
|
|
|
idToMap(updated, id);
|
|
|
|
|
autoDetectionToMap(updated, false);
|
|
|
|
|
}
|
|
|
|
|
if (tc->fromMap(updated))
|
2011-02-01 18:36:00 +01:00
|
|
|
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 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();
|
2012-01-30 13:07:51 +01:00
|
|
|
const Utils::FileName compilerPath = Utils::FileName::fromString(systemEnvironment.searchInPath(compiler));
|
2011-02-23 11:36:59 +01:00
|
|
|
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
|
|
|
|
|
|
|
|
foreach (const Abi &abi, abiList) {
|
|
|
|
|
QScopedPointer<GccToolChain> tc(createToolChain(true));
|
|
|
|
|
if (tc.isNull())
|
|
|
|
|
return result;
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2012-01-30 13:07:51 +01:00
|
|
|
tc->setCompilerCommand(compilerPath);
|
2011-03-10 14:44:49 +01:00
|
|
|
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),
|
2012-02-01 14:39:11 +01:00
|
|
|
m_compilerCommand(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);
|
|
|
|
|
|
2012-06-28 20:54:37 +02:00
|
|
|
Utils::DetailsWidget *details = new Utils::DetailsWidget(this);
|
|
|
|
|
details->setState(Utils::DetailsWidget::NoSummary);
|
|
|
|
|
QVBoxLayout *box = new QVBoxLayout(this);
|
|
|
|
|
box->setMargin(0);
|
|
|
|
|
box->addWidget(details);
|
|
|
|
|
|
|
|
|
|
QWidget *widget = new QWidget(details);
|
|
|
|
|
details->setWidget(widget);
|
|
|
|
|
|
|
|
|
|
QFormLayout *layout = new QFormLayout(widget);
|
2011-03-10 14:44:49 +01:00
|
|
|
|
2011-02-22 17:32:22 +01:00
|
|
|
const QStringList gnuVersionArgs = QStringList(QLatin1String("--version"));
|
2012-02-01 14:39:11 +01:00
|
|
|
m_compilerCommand->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
|
|
|
|
m_compilerCommand->setCommandVersionArguments(gnuVersionArgs);
|
|
|
|
|
layout->addRow(tr("&Compiler path:"), m_compilerCommand);
|
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
|
|
|
addErrorLabel(layout);
|
|
|
|
|
|
2011-02-23 11:36:59 +01:00
|
|
|
setFromToolchain();
|
2011-06-21 13:26:22 +02:00
|
|
|
|
2012-02-01 14:39:11 +01:00
|
|
|
connect(m_compilerCommand, SIGNAL(changed(QString)), this, SLOT(handleCompilerCommandChange()));
|
2012-04-24 15:49:09 +02:00
|
|
|
connect(m_abiWidget, SIGNAL(abiChanged()), this, SIGNAL(dirty()));
|
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();
|
2012-02-01 14:39:11 +01:00
|
|
|
tc->setCompilerCommand(m_compilerCommand->fileName());
|
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-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());
|
2012-02-01 14:39:11 +01:00
|
|
|
m_compilerCommand->setFileName(tc->compilerCommand());
|
2011-06-08 15:39:14 +00:00
|
|
|
m_abiWidget->setAbis(tc->supportedAbis(), tc->targetAbi());
|
2012-02-01 14:39:11 +01:00
|
|
|
if (!m_isReadOnly && !m_compilerCommand->path().isEmpty())
|
2011-06-27 17:24:54 +02:00
|
|
|
m_abiWidget->setEnabled(true);
|
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);
|
2012-02-01 14:39:11 +01:00
|
|
|
return m_compilerCommand->fileName() != tc->compilerCommand()
|
2012-04-24 15:49:09 +02: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()
|
|
|
|
|
{
|
2012-02-01 14:39:11 +01:00
|
|
|
m_compilerCommand->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();
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-01 14:39:11 +01:00
|
|
|
void Internal::GccToolChainConfigWidget::handleCompilerCommandChange()
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2012-02-01 14:39:11 +01:00
|
|
|
Utils::FileName path = m_compilerCommand->fileName();
|
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()) {
|
2012-01-30 13:07:51 +01:00
|
|
|
QFileInfo fi(path.toFileInfo());
|
2011-06-08 15:39:14 +00:00
|
|
|
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());
|
2012-02-21 12:00:45 +01:00
|
|
|
emit dirty();
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{ }
|
|
|
|
|
|
2012-01-30 11:55:21 +01:00
|
|
|
QString ClangToolChain::type() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String("clang");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ClangToolChain::typeDisplayName() const
|
2011-05-13 11:48:34 +02:00
|
|
|
{
|
|
|
|
|
return Internal::ClangToolChainFactory::tr("Clang");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ClangToolChain::makeCommand() const
|
|
|
|
|
{
|
|
|
|
|
#if defined(Q_OS_WIN)
|
|
|
|
|
return QLatin1String("mingw32-make.exe");
|
|
|
|
|
#else
|
|
|
|
|
return QLatin1String("make");
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-07 18:05:09 +01:00
|
|
|
QList<Utils::FileName> ClangToolChain::suggestedMkspecList() 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-02-07 18:05:09 +01:00
|
|
|
return QList<Utils::FileName>()
|
|
|
|
|
<< Utils::FileName::fromString(QLatin1String("macx-clang"))
|
|
|
|
|
<< Utils::FileName::fromString(QLatin1String("unsupported/macx-clang"));
|
2011-09-06 15:19:05 +00:00
|
|
|
else if (abi.os() == Abi::LinuxOS)
|
2012-02-07 18:05:09 +01:00
|
|
|
return QList<Utils::FileName>()
|
|
|
|
|
<< Utils::FileName::fromString(QLatin1String("linux-clang"))
|
|
|
|
|
<< Utils::FileName::fromString(QLatin1String("unsupported/linux-clang"));
|
|
|
|
|
return QList<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();
|
2012-04-24 15:49:09 +02:00
|
|
|
return autoDetectToolchains(QLatin1String("clang++"), ha);
|
2011-05-13 11:48:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{ }
|
|
|
|
|
|
2012-01-30 11:55:21 +01:00
|
|
|
QString MingwToolChain::type() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String("mingw");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString MingwToolChain::typeDisplayName() const
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
|
|
|
|
return Internal::MingwToolChainFactory::tr("MinGW");
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-07 18:05:09 +01:00
|
|
|
QList<Utils::FileName> MingwToolChain::suggestedMkspecList() const
|
2011-04-07 13:12:55 +02:00
|
|
|
{
|
2012-02-01 17:44:52 +01:00
|
|
|
#if defined(Q_OS_WIN)
|
2012-02-07 18:05:09 +01:00
|
|
|
return QList<Utils::FileName>() << Utils::FileName::fromString(QLatin1String("win32-g++"));
|
2012-02-01 17:44:52 +01:00
|
|
|
#elif defined(Q_OS_LINUX)
|
|
|
|
|
if (version().startsWith("4.6."))
|
2012-02-07 18:05:09 +01:00
|
|
|
return QList<Utils::FileName>()
|
|
|
|
|
<< Utils::FileName::fromString(QLatin1String("win32-g++-4.6-cross"))
|
|
|
|
|
<< Utils::FileName::fromString(QLatin1String("unsupported/win32-g++-4.6-cross"));
|
2012-02-01 17:44:52 +01:00
|
|
|
else
|
2012-02-07 18:05:09 +01:00
|
|
|
return QList<Utils::FileName>()
|
|
|
|
|
<< Utils::FileName::fromString(QLatin1String("win32-g++-cross"))
|
|
|
|
|
<< Utils::FileName::fromString(QLatin1String("unsupported/win32-g++-cross"));
|
2012-02-03 11:45:46 +01:00
|
|
|
#else
|
2012-02-10 09:43:17 +01:00
|
|
|
return QList<Utils::FileName>();
|
2012-02-01 17:44:52 +01:00
|
|
|
#endif
|
2011-04-07 13:12:55 +02:00
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
QString MingwToolChain::makeCommand() const
|
|
|
|
|
{
|
2012-02-01 17:09:59 +01:00
|
|
|
#ifdef Q_OS_WIN
|
2011-02-01 18:36:00 +01:00
|
|
|
return QLatin1String("mingw32-make.exe");
|
2012-02-01 17:09:59 +01:00
|
|
|
#else
|
|
|
|
|
return QLatin1String("make");
|
|
|
|
|
#endif
|
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-03-17 14:37:54 +01:00
|
|
|
Abi ha = Abi::hostAbi();
|
2012-04-24 15:49:09 +02:00
|
|
|
return autoDetectToolchains(QLatin1String("g++"),
|
2011-03-17 14:37:54 +01:00
|
|
|
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)
|
|
|
|
|
{ }
|
|
|
|
|
|
2012-01-30 11:55:21 +01:00
|
|
|
QString LinuxIccToolChain::type() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String("icc");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString LinuxIccToolChain::typeDisplayName() const
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
|
|
|
|
return Internal::LinuxIccToolChainFactory::tr("Linux ICC");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IOutputParser *LinuxIccToolChain::outputParser() const
|
|
|
|
|
{
|
|
|
|
|
return new LinuxIccParser;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-07 18:05:09 +01:00
|
|
|
QList<Utils::FileName> LinuxIccToolChain::suggestedMkspecList() const
|
2011-04-07 13:12:55 +02:00
|
|
|
{
|
2012-02-07 18:05:09 +01:00
|
|
|
return QList<Utils::FileName>()
|
|
|
|
|
<< 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()
|
|
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
return autoDetectToolchains(QLatin1String("icpc"), 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>
|
2012-02-15 10:42:41 +01:00
|
|
|
# include <QUrl>
|
2011-02-01 18:36:00 +01:00
|
|
|
|
|
|
|
|
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"));
|
2012-07-31 12:21:33 +02:00
|
|
|
QTest::newRow("Linux 7")
|
2011-07-01 13:39:54 +02:00
|
|
|
<< QString::fromLatin1("armv5tl-montavista-linux-gnueabi")
|
|
|
|
|
<< (QStringList() << QLatin1String("arm-linux-generic-elf-32bit"));
|
2012-07-31 12:21:33 +02:00
|
|
|
QTest::newRow("Linux 8")
|
2011-08-31 15:24:24 +00:00
|
|
|
<< 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"));
|
2012-02-01 17:09:59 +01:00
|
|
|
QTest::newRow("Cross Mingw 1")
|
|
|
|
|
<< QString::fromLatin1("amd64-mingw32msvc")
|
|
|
|
|
<< (QStringList() << QLatin1String("x86-windows-msys-pe-64bit")
|
|
|
|
|
<< QLatin1String("x86-windows-msys-pe-32bit"));
|
|
|
|
|
QTest::newRow("Cross Mingw 2")
|
|
|
|
|
<< QString::fromLatin1("i586-mingw32msvc")
|
|
|
|
|
<< (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
|