2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-02-01 18:36:00 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-02-01 18:36:00 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-02-01 18:36:00 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2011-02-01 18:36:00 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2011-02-01 18:36:00 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
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
|
|
|
|
2014-07-07 19:02:26 +02:00
|
|
|
#include <utils/algorithm.h>
|
2011-02-01 18:36:00 +01:00
|
|
|
#include <utils/environment.h>
|
2012-08-23 15:53:58 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2011-02-01 18:36:00 +01:00
|
|
|
#include <utils/synchronousprocess.h>
|
2011-02-28 16:50:14 +01:00
|
|
|
#include <utils/pathchooser.h>
|
2013-07-25 15:18:23 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2013-04-22 23:03:45 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
2016-04-29 16:52:58 +02:00
|
|
|
#include <utils/synchronousprocess.h>
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QBuffer>
|
|
|
|
|
#include <QCoreApplication>
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QScopedPointer>
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2013-04-22 23:03:45 +02:00
|
|
|
#include <QLineEdit>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QFormLayout>
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2012-08-21 13:29:16 +02:00
|
|
|
using namespace Utils;
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
using namespace Internal;
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// Helpers:
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
2012-02-01 14:39:11 +01:00
|
|
|
static const char compilerCommandKeyC[] = "ProjectExplorer.GccToolChain.Path";
|
2013-04-22 23:03:45 +02:00
|
|
|
static const char compilerPlatformCodeGenFlagsKeyC[] = "ProjectExplorer.GccToolChain.PlatformCodeGenFlags";
|
|
|
|
|
static const char compilerPlatformLinkerFlagsKeyC[] = "ProjectExplorer.GccToolChain.PlatformLinkerFlags";
|
2011-03-10 14:44:49 +01:00
|
|
|
static const char targetAbiKeyC[] = "ProjectExplorer.GccToolChain.TargetAbi";
|
2016-03-04 15:33:16 +01:00
|
|
|
static const char originalTargetTripleKeyC[] = "ProjectExplorer.GccToolChain.OriginalTargetTriple";
|
2011-06-21 13:26:22 +02:00
|
|
|
static const char supportedAbisKeyC[] = "ProjectExplorer.GccToolChain.SupportedAbis";
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2012-08-21 13:29:16 +02:00
|
|
|
static QByteArray runGcc(const 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();
|
|
|
|
|
|
2016-04-29 16:52:58 +02:00
|
|
|
SynchronousProcess cpp;
|
2011-07-29 08:53:00 +00:00
|
|
|
QStringList environment(env);
|
2016-04-07 13:06:01 +02:00
|
|
|
Utils::Environment::setupEnglishOutput(&environment);
|
2011-07-29 08:53:00 +00:00
|
|
|
|
|
|
|
|
cpp.setEnvironment(environment);
|
2016-04-29 16:52:58 +02:00
|
|
|
cpp.setTimeoutS(10);
|
2016-06-10 13:33:40 +03:00
|
|
|
SynchronousProcessResponse response = cpp.runBlocking(gcc.toString(), arguments);
|
2016-04-29 16:52:58 +02:00
|
|
|
if (response.result != SynchronousProcessResponse::Finished ||
|
|
|
|
|
response.exitCode != 0) {
|
|
|
|
|
qWarning() << response.exitMessage(gcc.toString(), 10);
|
2013-09-02 17:23:59 +02:00
|
|
|
return QByteArray();
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-29 16:52:58 +02:00
|
|
|
return response.allOutput().toUtf8();
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 12:00:18 +01:00
|
|
|
static const QStringList gccPredefinedMacrosOptions()
|
|
|
|
|
{
|
|
|
|
|
return QStringList() << QLatin1String("-xc++") << QLatin1String("-E") << QLatin1String("-dM");
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-21 13:29:16 +02:00
|
|
|
static QByteArray gccPredefinedMacros(const FileName &gcc, const QStringList &args, const QStringList &env)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2013-09-09 15:47:46 +02:00
|
|
|
QStringList arguments = args;
|
2012-02-16 15:09:56 +01:00
|
|
|
arguments << QLatin1String("-");
|
2011-02-01 18:36:00 +01:00
|
|
|
|
|
|
|
|
QByteArray predefinedMacros = runGcc(gcc, arguments, env);
|
2013-07-25 15:18:23 +02:00
|
|
|
// Sanity check in case we get an error message instead of real output:
|
2013-10-29 11:54:51 +01:00
|
|
|
QTC_CHECK(predefinedMacros.isNull() || predefinedMacros.startsWith("#define "));
|
2015-02-03 23:59:04 +02:00
|
|
|
if (HostOsInfo::isMacHost()) {
|
2012-08-23 15:53:58 +02:00
|
|
|
// 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);
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (idx != -1)
|
2012-08-23 15:53:58 +02:00
|
|
|
predefinedMacros.replace(idx, blocksDefine.length(), blocksUndefine);
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2012-08-23 15:53:58 +02:00
|
|
|
// 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");
|
|
|
|
|
}
|
2011-02-01 18:36:00 +01:00
|
|
|
return predefinedMacros;
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-07 00:31:11 +04:00
|
|
|
const int GccToolChain::PREDEFINED_MACROS_CACHE_SIZE = 16;
|
|
|
|
|
|
2013-09-09 15:47:46 +02:00
|
|
|
QList<HeaderPath> GccToolChain::gccHeaderPaths(const FileName &gcc, const QStringList &arguments,
|
|
|
|
|
const QStringList &env)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
|
|
|
|
QList<HeaderPath> systemHeaderPaths;
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-20 12:23:45 +01:00
|
|
|
static QList<Abi> guessGccAbi(const QString &m, const QByteArray ¯os)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2012-08-21 13:29:16 +02:00
|
|
|
QList<Abi> abiList;
|
2011-03-10 14:44:49 +01:00
|
|
|
|
2013-08-23 11:45:39 +02:00
|
|
|
Abi guessed = Abi::abiFromTargetTriplet(m);
|
|
|
|
|
if (guessed.isNull())
|
2011-03-10 14:44:49 +01:00
|
|
|
return abiList;
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2013-08-23 11:45:39 +02:00
|
|
|
Abi::Architecture arch = guessed.architecture();
|
|
|
|
|
Abi::OS os = guessed.os();
|
|
|
|
|
Abi::OSFlavor flavor = guessed.osFlavor();
|
|
|
|
|
Abi::BinaryFormat format = guessed.binaryFormat();
|
|
|
|
|
int width = guessed.wordWidth();
|
2011-03-10 14:44:49 +01:00
|
|
|
|
2013-11-04 13:07:20 +01:00
|
|
|
if (macros.contains("#define __SIZEOF_SIZE_T__ 8"))
|
|
|
|
|
width = 64;
|
|
|
|
|
else if (macros.contains("#define __SIZEOF_SIZE_T__ 4"))
|
|
|
|
|
width = 32;
|
|
|
|
|
|
2016-07-25 18:39:16 -07:00
|
|
|
if (os == Abi::DarwinOS) {
|
2011-03-10 14:44:49 +01:00
|
|
|
// Apple does PPC and x86!
|
2012-08-21 13:29:16 +02:00
|
|
|
abiList << Abi(arch, os, flavor, format, width);
|
|
|
|
|
abiList << Abi(arch, os, flavor, format, width == 64 ? 32 : 64);
|
2013-03-15 16:36:48 +01:00
|
|
|
} else if (arch == Abi::X86Architecture && (width == 0 || width == 64)) {
|
2013-11-04 13:07:20 +01:00
|
|
|
abiList << Abi(arch, os, flavor, format, 64);
|
2012-08-21 13:29:16 +02:00
|
|
|
abiList << Abi(arch, os, flavor, format, 32);
|
2011-03-10 14:44:49 +01:00
|
|
|
} else {
|
2012-08-21 13:29:16 +02:00
|
|
|
abiList << Abi(arch, os, flavor, format, width);
|
2011-03-10 14:44:49 +01:00
|
|
|
}
|
|
|
|
|
return abiList;
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2016-03-04 15:33:16 +01:00
|
|
|
|
|
|
|
|
static GccToolChain::DetectedAbisResult guessGccAbi(const FileName &path, const QStringList &env,
|
|
|
|
|
const QByteArray ¯os,
|
|
|
|
|
const QStringList &extraArgs = QStringList())
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2012-02-09 13:45:08 +01:00
|
|
|
if (path.isEmpty())
|
2016-03-04 15:33:16 +01:00
|
|
|
return GccToolChain::DetectedAbisResult();
|
2012-02-09 13:45:08 +01:00
|
|
|
|
2013-04-22 23:03:45 +02:00
|
|
|
QStringList arguments = extraArgs;
|
|
|
|
|
arguments << QLatin1String("-dumpmachine");
|
2011-02-01 18:36:00 +01:00
|
|
|
QString machine = QString::fromLocal8Bit(runGcc(path, arguments, env)).trimmed();
|
2013-07-25 14:36:28 +02:00
|
|
|
if (machine.isEmpty())
|
2016-03-04 15:33:16 +01:00
|
|
|
return GccToolChain::DetectedAbisResult(); // no need to continue if running failed once...
|
|
|
|
|
return GccToolChain::DetectedAbisResult(guessGccAbi(machine, macros), machine);
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2012-08-21 13:29:16 +02:00
|
|
|
static QString gccVersion(const 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
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
2013-09-03 10:58:59 +02:00
|
|
|
GccToolChain::GccToolChain(Detection d) :
|
2015-07-07 15:37:50 +02:00
|
|
|
ToolChain(Constants::GCC_TOOLCHAIN_TYPEID, d)
|
2011-02-01 18:36:00 +01:00
|
|
|
{ }
|
|
|
|
|
|
2015-07-09 11:34:37 +02:00
|
|
|
GccToolChain::GccToolChain(Core::Id typeId, Detection d) :
|
|
|
|
|
ToolChain(typeId, d)
|
2011-02-01 18:36:00 +01:00
|
|
|
{ }
|
|
|
|
|
|
2014-07-21 14:23:09 +02:00
|
|
|
void GccToolChain::setCompilerCommand(const FileName &path)
|
|
|
|
|
{
|
|
|
|
|
if (path == m_compilerCommand)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_compilerCommand = path;
|
2016-07-06 14:13:25 +02:00
|
|
|
toolChainUpdated();
|
2014-07-21 14:23:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GccToolChain::setSupportedAbis(const QList<Abi> &m_abis)
|
|
|
|
|
{
|
2016-07-06 14:13:25 +02:00
|
|
|
if (m_supportedAbis == m_abis)
|
|
|
|
|
return;
|
|
|
|
|
|
2014-07-21 14:23:09 +02:00
|
|
|
m_supportedAbis = m_abis;
|
2016-07-06 14:13:25 +02:00
|
|
|
toolChainUpdated();
|
2014-07-21 14:23:09 +02:00
|
|
|
}
|
|
|
|
|
|
2016-03-04 15:33:16 +01:00
|
|
|
void GccToolChain::setOriginalTargetTriple(const QString &targetTriple)
|
|
|
|
|
{
|
2016-07-06 14:13:25 +02:00
|
|
|
if (m_originalTargetTriple == targetTriple)
|
|
|
|
|
return;
|
|
|
|
|
|
2016-03-04 15:33:16 +01:00
|
|
|
m_originalTargetTriple = targetTriple;
|
2016-07-06 14:13:25 +02:00
|
|
|
toolChainUpdated();
|
2016-03-04 15:33:16 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 12:03:31 +01:00
|
|
|
void GccToolChain::setMacroCache(const QStringList &allCxxflags, const QByteArray ¯os) const
|
|
|
|
|
{
|
|
|
|
|
if (macros.isNull())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
CacheItem runResults;
|
|
|
|
|
QByteArray data = macros;
|
|
|
|
|
runResults.first = allCxxflags;
|
|
|
|
|
if (macros.isNull())
|
|
|
|
|
data = QByteArray("");
|
|
|
|
|
runResults.second = data;
|
|
|
|
|
|
|
|
|
|
m_predefinedMacros.push_back(runResults);
|
|
|
|
|
if (m_predefinedMacros.size() > PREDEFINED_MACROS_CACHE_SIZE)
|
|
|
|
|
m_predefinedMacros.pop_front();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QByteArray GccToolChain::macroCache(const QStringList &allCxxflags) const
|
|
|
|
|
{
|
|
|
|
|
for (GccCache::iterator it = m_predefinedMacros.begin(); it != m_predefinedMacros.end(); ++it) {
|
|
|
|
|
if (it->first == allCxxflags) {
|
|
|
|
|
// Increase cached item priority
|
|
|
|
|
CacheItem pair = *it;
|
|
|
|
|
m_predefinedMacros.erase(it);
|
|
|
|
|
m_predefinedMacros.push_back(pair);
|
|
|
|
|
|
|
|
|
|
return pair.second;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return QByteArray();
|
|
|
|
|
}
|
|
|
|
|
|
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();
|
2013-01-08 11:19:27 +01:00
|
|
|
return QCoreApplication::translate("ProjectExplorer::GccToolChain",
|
|
|
|
|
"%1 (%2 %3 in %4)").arg(typeDisplayName(),
|
|
|
|
|
Abi::toString(m_targetAbi.architecture()),
|
|
|
|
|
Abi::toString(m_targetAbi.wordWidth()),
|
|
|
|
|
compilerCommand().parentDir().toUserOutput());
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2013-04-28 13:11:48 +04:00
|
|
|
ToolChain::CompilerFlags GccToolChain::defaultCompilerFlags() const
|
|
|
|
|
{
|
|
|
|
|
return CompilerFlags(GnuExtensions);
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-30 11:55:21 +01:00
|
|
|
QString GccToolChain::typeDisplayName() const
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2013-08-09 17:49:30 +02:00
|
|
|
return GccToolChainFactory::tr("GCC");
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Abi GccToolChain::targetAbi() const
|
|
|
|
|
{
|
|
|
|
|
return m_targetAbi;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-04 15:33:16 +01:00
|
|
|
QString GccToolChain::originalTargetTriple() const
|
|
|
|
|
{
|
2016-03-31 08:48:59 +02:00
|
|
|
if (m_originalTargetTriple.isEmpty())
|
|
|
|
|
m_originalTargetTriple = detectSupportedAbis().originalTargetTriple;
|
2016-03-04 15:33:16 +01:00
|
|
|
return m_originalTargetTriple;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
{
|
2013-01-31 16:02:29 +01:00
|
|
|
if (m_compilerCommand.isNull())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
QFileInfo fi = compilerCommand().toFileInfo();
|
|
|
|
|
return fi.isExecutable();
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2012-12-07 00:31:11 +04:00
|
|
|
/**
|
|
|
|
|
* @brief Asks compiler for set of predefined macros
|
|
|
|
|
* @param cxxflags - compiler flags collected from project settings
|
|
|
|
|
* @return defines list, one per line, e.g. "#define __GXX_WEAK__ 1"
|
|
|
|
|
*
|
|
|
|
|
* @note changing compiler flags sometimes changes macros set, e.g. -fopenmp
|
|
|
|
|
* adds _OPENMP macro, for full list of macro search by word "when" on this page:
|
|
|
|
|
* http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
|
|
|
|
|
*/
|
2012-02-16 15:09:56 +01:00
|
|
|
QByteArray GccToolChain::predefinedMacros(const QStringList &cxxflags) const
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2013-04-22 23:03:45 +02:00
|
|
|
QStringList allCxxflags = m_platformCodeGenFlags + cxxflags; // add only cxxflags is empty?
|
2012-12-07 00:31:11 +04:00
|
|
|
|
|
|
|
|
// Using a clean environment breaks ccache/distcc/etc.
|
|
|
|
|
Environment env = Environment::systemEnvironment();
|
|
|
|
|
addToEnvironment(env);
|
2013-09-09 15:47:46 +02:00
|
|
|
QStringList arguments = gccPredefinedMacrosOptions();
|
2013-11-04 12:38:39 +01:00
|
|
|
for (int iArg = 0; iArg < allCxxflags.length(); ++iArg) {
|
|
|
|
|
const QString &a = allCxxflags.at(iArg);
|
2016-11-24 14:26:51 +01:00
|
|
|
if (a.startsWith("--gcc-toolchain=")) {
|
|
|
|
|
arguments << a;
|
|
|
|
|
} else if (a == QLatin1String("-arch")) {
|
2014-03-24 13:40:27 +01:00
|
|
|
if (++iArg < allCxxflags.length() && !arguments.contains(a))
|
|
|
|
|
arguments << a << allCxxflags.at(iArg);
|
2015-07-28 12:22:23 +02:00
|
|
|
} else if (a == QLatin1String("--sysroot") || a == QLatin1String("-isysroot")
|
|
|
|
|
|| a == QLatin1String("-D") ||a == QLatin1String("-U")) {
|
2013-11-04 12:38:39 +01:00
|
|
|
if (++iArg < allCxxflags.length())
|
|
|
|
|
arguments << a << allCxxflags.at(iArg);
|
|
|
|
|
} else if (a == QLatin1String("-m128bit-long-double") || a == QLatin1String("-m32")
|
2013-09-09 15:47:46 +02:00
|
|
|
|| a == QLatin1String("-m3dnow") || a == QLatin1String("-m3dnowa")
|
|
|
|
|
|| a == QLatin1String("-m64") || a == QLatin1String("-m96bit-long-double")
|
|
|
|
|
|| a == QLatin1String("-mabm") || a == QLatin1String("-maes")
|
|
|
|
|
|| a.startsWith(QLatin1String("-march=")) || a == QLatin1String("-mavx")
|
|
|
|
|
|| a.startsWith(QLatin1String("-masm=")) || a == QLatin1String("-mcx16")
|
|
|
|
|
|| a == QLatin1String("-mfma") || a == QLatin1String("-mfma4")
|
|
|
|
|
|| a == QLatin1String("-mlwp") || a == QLatin1String("-mpclmul")
|
|
|
|
|
|| a == QLatin1String("-mpopcnt") || a == QLatin1String("-msse")
|
|
|
|
|
|| a == QLatin1String("-msse2") || a == QLatin1String("-msse2avx")
|
|
|
|
|
|| a == QLatin1String("-msse3") || a == QLatin1String("-msse4")
|
|
|
|
|
|| a == QLatin1String("-msse4.1") || a == QLatin1String("-msse4.2")
|
|
|
|
|
|| a == QLatin1String("-msse4a") || a == QLatin1String("-mssse3")
|
|
|
|
|
|| a.startsWith(QLatin1String("-mtune=")) || a == QLatin1String("-mxop")
|
|
|
|
|
|| a == QLatin1String("-Os") || a == QLatin1String("-O0") || a == QLatin1String("-O1")
|
|
|
|
|
|| a == QLatin1String("-O2") || a == QLatin1String("-O3")
|
|
|
|
|
|| a == QLatin1String("-ffinite-math-only") || a == QLatin1String("-fshort-double")
|
|
|
|
|
|| a == QLatin1String("-fshort-wchar") || a == QLatin1String("-fsignaling-nans")
|
|
|
|
|
|| a == QLatin1String("-fno-inline") || a == QLatin1String("-fno-exceptions")
|
|
|
|
|
|| a == QLatin1String("-fstack-protector") || a == QLatin1String("-fstack-protector-all")
|
|
|
|
|
|| a == QLatin1String("-fsanitize=address") || a == QLatin1String("-fno-rtti")
|
|
|
|
|
|| a.startsWith(QLatin1String("-std=")) || a.startsWith(QLatin1String("-stdlib="))
|
|
|
|
|
|| a.startsWith(QLatin1String("-specs="))
|
|
|
|
|
|| a == QLatin1String("-ansi") || a == QLatin1String("-undef")
|
|
|
|
|
|| a.startsWith(QLatin1String("-D")) || a.startsWith(QLatin1String("-U"))
|
2014-01-07 12:58:24 +01:00
|
|
|
|| a == QLatin1String("-fopenmp") || a == QLatin1String("-Wno-deprecated")
|
|
|
|
|
|| a == QLatin1String("-fPIC") || a == QLatin1String("-fpic")
|
|
|
|
|
|| a == QLatin1String("-fPIE") || a == QLatin1String("-fpie"))
|
2013-09-09 15:47:46 +02:00
|
|
|
arguments << a;
|
|
|
|
|
}
|
2016-07-21 15:31:07 +02:00
|
|
|
|
|
|
|
|
QByteArray macros = macroCache(arguments);
|
|
|
|
|
if (!macros.isNull())
|
|
|
|
|
return macros;
|
|
|
|
|
|
2013-10-29 12:03:31 +01:00
|
|
|
macros = gccPredefinedMacros(m_compilerCommand, reinterpretOptions(arguments),
|
|
|
|
|
env.toStringList());
|
2013-09-09 15:47:46 +02:00
|
|
|
|
2016-07-21 15:31:07 +02:00
|
|
|
setMacroCache(arguments, macros);
|
2013-10-29 12:03:31 +01:00
|
|
|
return macros;
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2013-04-28 13:11:48 +04:00
|
|
|
/**
|
|
|
|
|
* @brief Parses gcc flags -std=*, -fopenmp, -fms-extensions, -ansi.
|
|
|
|
|
* @see http://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html
|
|
|
|
|
*/
|
2012-08-21 13:29:16 +02:00
|
|
|
ToolChain::CompilerFlags GccToolChain::compilerFlags(const QStringList &cxxflags) const
|
2012-02-16 15:09:56 +01:00
|
|
|
{
|
2013-04-28 13:11:48 +04:00
|
|
|
CompilerFlags flags = defaultCompilerFlags();
|
|
|
|
|
|
|
|
|
|
const QStringList allCxxflags = m_platformCodeGenFlags + cxxflags; // add only cxxflags is empty?
|
|
|
|
|
foreach (const QString &flag, allCxxflags) {
|
|
|
|
|
if (flag.startsWith(QLatin1String("-std="))) {
|
2014-08-28 17:33:47 +02:00
|
|
|
const QByteArray std = flag.mid(5).toLatin1();
|
2013-04-28 13:11:48 +04:00
|
|
|
if (std == "c++98" || std == "c++03") {
|
2014-10-23 18:08:07 +02:00
|
|
|
flags &= ~CompilerFlags(StandardCxx11 | StandardCxx14 | StandardCxx17 | GnuExtensions);
|
2015-04-14 14:50:14 +02:00
|
|
|
flags |= StandardCxx98;
|
2013-04-28 13:11:48 +04:00
|
|
|
} else if (std == "gnu++98" || std == "gnu++03") {
|
2014-10-23 18:08:07 +02:00
|
|
|
flags &= ~CompilerFlags(StandardCxx11 | StandardCxx14 | StandardCxx17);
|
2013-04-28 13:11:48 +04:00
|
|
|
flags |= GnuExtensions;
|
2014-08-21 16:26:06 +02:00
|
|
|
} else if (std == "c++0x" || std == "c++11") {
|
2013-04-28 13:11:48 +04:00
|
|
|
flags |= StandardCxx11;
|
2014-10-23 18:08:07 +02:00
|
|
|
flags &= ~CompilerFlags(StandardCxx14 | StandardCxx17 | GnuExtensions);
|
2014-08-21 16:26:06 +02:00
|
|
|
} else if (std == "c++14" || std == "c++1y") {
|
|
|
|
|
flags |= StandardCxx14;
|
2014-10-23 18:08:07 +02:00
|
|
|
flags &= ~CompilerFlags(StandardCxx11 | StandardCxx17 | GnuExtensions);
|
2014-08-21 16:26:06 +02:00
|
|
|
} else if (std == "c++17" || std == "c++1z") {
|
|
|
|
|
flags |= StandardCxx17;
|
2014-10-23 18:08:07 +02:00
|
|
|
flags &= ~CompilerFlags(StandardCxx11 | StandardCxx14 | GnuExtensions);
|
2016-05-27 14:38:22 +02:00
|
|
|
} else if (std == "gnu++0x" || std == "gnu++11") {
|
2013-04-28 13:11:48 +04:00
|
|
|
flags |= CompilerFlags(StandardCxx11 | GnuExtensions);
|
2014-10-23 18:08:07 +02:00
|
|
|
flags &= ~CompilerFlags(StandardCxx14 | StandardCxx17);
|
2016-05-27 14:38:22 +02:00
|
|
|
} else if (std== "gnu++14" || std == "gnu++1y") {
|
|
|
|
|
flags |= CompilerFlags(StandardCxx14 | GnuExtensions);
|
|
|
|
|
flags &= ~CompilerFlags(StandardCxx11 | StandardCxx17);
|
|
|
|
|
} else if (std== "gnu++17" || std == "gnu++1z") {
|
|
|
|
|
flags |= CompilerFlags(StandardCxx17 | GnuExtensions);
|
|
|
|
|
flags &= ~CompilerFlags(StandardCxx11 | StandardCxx14);
|
2013-04-28 13:11:48 +04:00
|
|
|
} else if (std == "c89" || std == "c90"
|
2013-05-02 08:57:02 +02:00
|
|
|
|| std == "iso9899:1990" || std == "iso9899:199409") {
|
2013-04-28 13:11:48 +04:00
|
|
|
flags &= ~CompilerFlags(StandardC99 | StandardC11);
|
|
|
|
|
} else if (std == "gnu89" || std == "gnu90") {
|
|
|
|
|
flags &= ~CompilerFlags(StandardC99 | StandardC11);
|
|
|
|
|
flags |= GnuExtensions;
|
|
|
|
|
} else if (std == "c99" || std == "c9x"
|
|
|
|
|
|| std == "iso9899:1999" || std == "iso9899:199x") {
|
|
|
|
|
flags |= StandardC99;
|
|
|
|
|
flags &= ~StandardC11;
|
|
|
|
|
} else if (std == "gnu99" || std == "gnu9x") {
|
|
|
|
|
flags |= CompilerFlags(StandardC99 | GnuExtensions);
|
|
|
|
|
flags &= ~StandardC11;
|
|
|
|
|
} else if (std == "c11" || std == "c1x" || std == "iso9899:2011") {
|
|
|
|
|
flags |= CompilerFlags(StandardC99 | StandardC11);
|
|
|
|
|
} else if (std == "gnu11" || std == "gnu1x") {
|
|
|
|
|
flags |= CompilerFlags(StandardC99 | StandardC11 | GnuExtensions);
|
|
|
|
|
}
|
|
|
|
|
} else if (flag == QLatin1String("-fopenmp")) {
|
|
|
|
|
flags |= OpenMP;
|
|
|
|
|
} else if (flag == QLatin1String("-fms-extensions")) {
|
|
|
|
|
flags |= MicrosoftExtensions;
|
|
|
|
|
} else if (flag == QLatin1String("-ansi")) {
|
|
|
|
|
flags &= ~CompilerFlags(StandardCxx11 | GnuExtensions
|
|
|
|
|
| StandardC99 | StandardC11);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return flags;
|
2012-02-16 15:09:56 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-18 11:56:54 +01:00
|
|
|
WarningFlags GccToolChain::warningFlags(const QStringList &cflags) const
|
2013-03-03 21:53:38 +04:00
|
|
|
{
|
|
|
|
|
// based on 'LC_ALL="en" gcc -Q --help=warnings | grep enabled'
|
2016-01-18 11:56:54 +01:00
|
|
|
WarningFlags flags(WarningFlags::Deprecated | WarningFlags::IgnoredQualfiers
|
|
|
|
|
| WarningFlags::SignedComparison | WarningFlags::UninitializedVars);
|
|
|
|
|
WarningFlags groupWall(WarningFlags::All | WarningFlags::UnknownPragma | WarningFlags::UnusedFunctions
|
|
|
|
|
| WarningFlags::UnusedLocals | WarningFlags::UnusedResult | WarningFlags::UnusedValue
|
|
|
|
|
| WarningFlags::SignedComparison | WarningFlags::UninitializedVars);
|
|
|
|
|
WarningFlags groupWextra(WarningFlags::Extra | WarningFlags::IgnoredQualfiers | WarningFlags::UnusedParams);
|
2013-03-03 21:53:38 +04:00
|
|
|
|
|
|
|
|
foreach (const QString &flag, cflags) {
|
|
|
|
|
if (flag == QLatin1String("--all-warnings"))
|
|
|
|
|
flags |= groupWall;
|
|
|
|
|
else if (flag == QLatin1String("--extra-warnings"))
|
|
|
|
|
flags |= groupWextra;
|
|
|
|
|
|
|
|
|
|
WarningFlagAdder add(flag, flags);
|
|
|
|
|
if (add.triggered())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// supported by clang too
|
2016-01-18 11:56:54 +01:00
|
|
|
add("error", WarningFlags::AsErrors);
|
2013-03-03 21:53:38 +04:00
|
|
|
add("all", groupWall);
|
|
|
|
|
add("extra", groupWextra);
|
2016-01-18 11:56:54 +01:00
|
|
|
add("deprecated", WarningFlags::Deprecated);
|
|
|
|
|
add("effc++", WarningFlags::EffectiveCxx);
|
|
|
|
|
add("ignored-qualifiers", WarningFlags::IgnoredQualfiers);
|
|
|
|
|
add("non-virtual-dtor", WarningFlags::NonVirtualDestructor);
|
|
|
|
|
add("overloaded-virtual", WarningFlags::OverloadedVirtual);
|
|
|
|
|
add("shadow", WarningFlags::HiddenLocals);
|
|
|
|
|
add("sign-compare", WarningFlags::SignedComparison);
|
|
|
|
|
add("unknown-pragmas", WarningFlags::UnknownPragma);
|
|
|
|
|
add("unused", WarningFlags::UnusedFunctions | WarningFlags::UnusedLocals | WarningFlags::UnusedParams
|
|
|
|
|
| WarningFlags::UnusedResult | WarningFlags::UnusedValue);
|
|
|
|
|
add("unused-function", WarningFlags::UnusedFunctions);
|
|
|
|
|
add("unused-variable", WarningFlags::UnusedLocals);
|
|
|
|
|
add("unused-parameter", WarningFlags::UnusedParams);
|
|
|
|
|
add("unused-result", WarningFlags::UnusedResult);
|
|
|
|
|
add("unused-value", WarningFlags::UnusedValue);
|
|
|
|
|
add("uninitialized", WarningFlags::UninitializedVars);
|
2013-03-03 21:53:38 +04:00
|
|
|
}
|
|
|
|
|
return flags;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:59:04 +02:00
|
|
|
QList<HeaderPath> GccToolChain::systemHeaderPaths(const QStringList &cxxflags, const FileName &sysRoot) const
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
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.
|
2012-08-21 13:29:16 +02:00
|
|
|
Environment env = Environment::systemEnvironment();
|
2011-02-01 18:36:00 +01:00
|
|
|
addToEnvironment(env);
|
2013-09-09 15:47:46 +02:00
|
|
|
// Prepare arguments
|
|
|
|
|
QStringList arguments;
|
|
|
|
|
if (!sysRoot.isEmpty())
|
|
|
|
|
arguments.append(QString::fromLatin1("--sysroot=%1").arg(sysRoot.toString()));
|
|
|
|
|
|
|
|
|
|
QStringList flags;
|
|
|
|
|
flags << m_platformCodeGenFlags << cxxflags;
|
|
|
|
|
foreach (const QString &a, flags) {
|
2016-11-24 14:26:51 +01:00
|
|
|
if (a.startsWith(QLatin1String("-stdlib=")) || a.startsWith("--gcctoolchain="))
|
2013-09-09 15:47:46 +02:00
|
|
|
arguments << a;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 11:56:41 +01:00
|
|
|
arguments << QLatin1String("-xc++")
|
|
|
|
|
<< QLatin1String("-E")
|
|
|
|
|
<< QLatin1String("-v")
|
|
|
|
|
<< QLatin1String("-");
|
2013-09-09 15:47:46 +02:00
|
|
|
|
|
|
|
|
m_headerPaths = gccHeaderPaths(m_compilerCommand, reinterpretOptions(arguments), 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
|
|
|
}
|
|
|
|
|
|
2013-09-02 17:19:57 +02:00
|
|
|
void GccToolChain::addCommandPathToEnvironment(const FileName &command, Environment &env)
|
|
|
|
|
{
|
|
|
|
|
if (!command.isEmpty())
|
|
|
|
|
env.prependOrSetPath(command.parentDir().toString());
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-21 13:29:16 +02:00
|
|
|
void GccToolChain::addToEnvironment(Environment &env) const
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2013-09-02 17:19:57 +02:00
|
|
|
addCommandPathToEnvironment(m_compilerCommand, env);
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2015-11-03 14:01:25 +01:00
|
|
|
FileNameList 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:-(
|
2015-11-03 14:01:25 +01:00
|
|
|
return FileNameList();
|
2012-02-02 11:56:09 +01:00
|
|
|
|
2016-07-25 18:39:16 -07:00
|
|
|
if (abi.os() == Abi::DarwinOS) {
|
2011-09-06 15:19:05 +00:00
|
|
|
QString v = version();
|
2016-07-25 18:39:16 -07:00
|
|
|
// prefer versioned g++ on macOS. This is required to enable building for older macOS versions
|
2012-02-01 14:39:11 +01:00
|
|
|
if (v.startsWith(QLatin1String("4.0")) && m_compilerCommand.endsWith(QLatin1String("-4.0")))
|
2015-11-03 14:01:25 +01:00
|
|
|
return FileNameList() << FileName::fromLatin1("macx-g++40");
|
2012-02-01 14:39:11 +01:00
|
|
|
if (v.startsWith(QLatin1String("4.2")) && m_compilerCommand.endsWith(QLatin1String("-4.2")))
|
2015-11-03 14:01:25 +01:00
|
|
|
return FileNameList() << FileName::fromLatin1("macx-g++42");
|
|
|
|
|
return FileNameList() << FileName::fromLatin1("macx-g++");
|
2011-09-06 15:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (abi.os() == Abi::LinuxOS) {
|
|
|
|
|
if (abi.osFlavor() != Abi::GenericLinuxFlavor)
|
2015-11-03 14:01:25 +01:00
|
|
|
return FileNameList(); // 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.
|
2015-11-03 14:01:25 +01:00
|
|
|
return FileNameList() << FileName::fromLatin1("linux-g++")
|
|
|
|
|
<< FileName::fromString(QLatin1String("linux-g++-") + QString::number(m_targetAbi.wordWidth()));
|
2012-08-08 14:19:29 +02:00
|
|
|
}
|
2015-11-03 14:01:25 +01:00
|
|
|
return FileNameList() << 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)
|
2015-11-03 14:01:25 +01:00
|
|
|
return FileNameList() << FileName::fromLatin1("freebsd-g++");
|
2012-02-02 11:56:09 +01:00
|
|
|
|
2015-11-03 14:01:25 +01:00
|
|
|
return FileNameList();
|
2011-04-07 13:12:55 +02:00
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:59:04 +02:00
|
|
|
QString GccToolChain::makeCommand(const Environment &environment) const
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2012-09-11 15:59:17 +02:00
|
|
|
QString make = QLatin1String("make");
|
2014-07-15 23:32:11 +03:00
|
|
|
FileName tmp = environment.searchInPath(make);
|
|
|
|
|
return tmp.isEmpty() ? make : tmp.toString();
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IOutputParser *GccToolChain::outputParser() const
|
|
|
|
|
{
|
|
|
|
|
return new GccParser;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-21 14:23:09 +02:00
|
|
|
void GccToolChain::resetToolChain(const FileName &path)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2016-09-12 12:06:50 +02:00
|
|
|
bool resetDisplayName = (displayName() == defaultDisplayName());
|
2011-04-14 14:51:28 +02:00
|
|
|
|
2014-07-21 14:23:09 +02:00
|
|
|
setCompilerCommand(path);
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2011-04-14 14:51:28 +02:00
|
|
|
Abi currentAbi = m_targetAbi;
|
2016-03-04 15:33:16 +01:00
|
|
|
const DetectedAbisResult detectedAbis = detectSupportedAbis();
|
|
|
|
|
m_supportedAbis = detectedAbis.supportedAbis;
|
|
|
|
|
m_originalTargetTriple = detectedAbis.originalTargetTriple;
|
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-08-21 13:29:16 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2013-04-22 23:03:45 +02:00
|
|
|
void GccToolChain::setPlatformCodeGenFlags(const QStringList &flags)
|
|
|
|
|
{
|
|
|
|
|
if (flags != m_platformCodeGenFlags) {
|
|
|
|
|
m_platformCodeGenFlags = flags;
|
|
|
|
|
toolChainUpdated();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
2013-09-10 17:16:10 +02:00
|
|
|
Code gen flags that have to be passed to the compiler.
|
2013-04-22 23:03:45 +02:00
|
|
|
*/
|
|
|
|
|
QStringList GccToolChain::platformCodeGenFlags() const
|
|
|
|
|
{
|
|
|
|
|
return m_platformCodeGenFlags;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GccToolChain::setPlatformLinkerFlags(const QStringList &flags)
|
|
|
|
|
{
|
|
|
|
|
if (flags != m_platformLinkerFlags) {
|
|
|
|
|
m_platformLinkerFlags = flags;
|
|
|
|
|
toolChainUpdated();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
2013-09-10 17:16:10 +02:00
|
|
|
Flags that have to be passed to the linker.
|
2013-04-22 23:03:45 +02:00
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
For example: \c{-arch armv7}
|
2013-04-22 23:03:45 +02:00
|
|
|
*/
|
|
|
|
|
QStringList GccToolChain::platformLinkerFlags() const
|
|
|
|
|
{
|
|
|
|
|
return m_platformLinkerFlags;
|
|
|
|
|
}
|
|
|
|
|
|
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());
|
2013-04-22 23:03:45 +02:00
|
|
|
data.insert(QLatin1String(compilerPlatformCodeGenFlagsKeyC), m_platformCodeGenFlags);
|
|
|
|
|
data.insert(QLatin1String(compilerPlatformLinkerFlagsKeyC), m_platformLinkerFlags);
|
2011-03-10 14:44:49 +01:00
|
|
|
data.insert(QLatin1String(targetAbiKeyC), m_targetAbi.toString());
|
2016-03-04 15:33:16 +01:00
|
|
|
data.insert(QLatin1String(originalTargetTripleKeyC), m_originalTargetTriple);
|
2014-07-07 19:02:26 +02:00
|
|
|
QStringList abiList = Utils::transform(m_supportedAbis, &Abi::toString);
|
2011-06-21 13:26:22 +02:00
|
|
|
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-08-21 13:29:16 +02:00
|
|
|
m_compilerCommand = FileName::fromString(data.value(QLatin1String(compilerCommandKeyC)).toString());
|
2013-04-22 23:03:45 +02:00
|
|
|
m_platformCodeGenFlags = data.value(QLatin1String(compilerPlatformCodeGenFlagsKeyC)).toStringList();
|
|
|
|
|
m_platformLinkerFlags = data.value(QLatin1String(compilerPlatformLinkerFlagsKeyC)).toStringList();
|
2011-03-10 14:44:49 +01:00
|
|
|
m_targetAbi = Abi(data.value(QLatin1String(targetAbiKeyC)).toString());
|
2016-03-04 15:33:16 +01:00
|
|
|
m_originalTargetTriple = data.value(QLatin1String(originalTargetTripleKeyC)).toString();
|
2016-09-12 12:06:50 +02:00
|
|
|
const QStringList abiList = data.value(QLatin1String(supportedAbisKeyC)).toStringList();
|
2011-06-21 13:26:22 +02:00
|
|
|
m_supportedAbis.clear();
|
2016-09-12 12:06:50 +02:00
|
|
|
for (const QString &a : abiList) {
|
2012-08-21 13:29:16 +02:00
|
|
|
Abi abi(a);
|
2011-06-21 13:26:22 +02:00
|
|
|
if (!abi.isValid())
|
|
|
|
|
continue;
|
|
|
|
|
m_supportedAbis.append(abi);
|
|
|
|
|
}
|
2016-09-12 12:06:50 +02:00
|
|
|
|
|
|
|
|
if (!m_targetAbi.isValid())
|
|
|
|
|
resetToolChain(m_compilerCommand);
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool GccToolChain::operator ==(const ToolChain &other) const
|
|
|
|
|
{
|
|
|
|
|
if (!ToolChain::operator ==(other))
|
|
|
|
|
return false;
|
|
|
|
|
|
2016-04-13 15:52:14 +02:00
|
|
|
auto gccTc = static_cast<const GccToolChain *>(&other);
|
2013-04-22 23:03:45 +02:00
|
|
|
return m_compilerCommand == gccTc->m_compilerCommand && m_targetAbi == gccTc->m_targetAbi
|
|
|
|
|
&& m_platformCodeGenFlags == gccTc->m_platformCodeGenFlags
|
|
|
|
|
&& m_platformLinkerFlags == gccTc->m_platformLinkerFlags;
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChainConfigWidget *GccToolChain::configurationWidget()
|
|
|
|
|
{
|
2013-08-09 17:49:30 +02:00
|
|
|
return new GccToolChainConfigWidget(this);
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2011-03-10 14:44:49 +01:00
|
|
|
void GccToolChain::updateSupportedAbis() const
|
|
|
|
|
{
|
2016-03-04 15:33:16 +01:00
|
|
|
if (m_supportedAbis.isEmpty()) {
|
|
|
|
|
const DetectedAbisResult detected = detectSupportedAbis();
|
|
|
|
|
m_supportedAbis = detected.supportedAbis;
|
|
|
|
|
m_originalTargetTriple = detected.originalTargetTriple;
|
|
|
|
|
}
|
2011-05-17 16:02:05 +02:00
|
|
|
}
|
|
|
|
|
|
2016-03-04 15:33:16 +01:00
|
|
|
GccToolChain::DetectedAbisResult GccToolChain::detectSupportedAbis() const
|
2011-05-17 16:02:05 +02:00
|
|
|
{
|
2012-08-21 13:29:16 +02:00
|
|
|
Environment env = Environment::systemEnvironment();
|
2011-05-17 16:02:05 +02:00
|
|
|
addToEnvironment(env);
|
2013-10-29 12:07:16 +01:00
|
|
|
QByteArray macros = predefinedMacros(QStringList());
|
|
|
|
|
return guessGccAbi(m_compilerCommand, env.toStringList(), macros, platformCodeGenFlags());
|
2011-03-10 14:44:49 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-06 15:19:05 +00:00
|
|
|
QString GccToolChain::detectVersion() const
|
|
|
|
|
{
|
2012-08-21 13:29:16 +02:00
|
|
|
Environment env = Environment::systemEnvironment();
|
2011-09-06 15:19:05 +00:00
|
|
|
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
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
GccToolChainFactory::GccToolChainFactory()
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2013-08-09 17:49:30 +02:00
|
|
|
setDisplayName(tr("GCC"));
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2016-07-12 11:33:17 +02:00
|
|
|
QSet<ToolChain::Language> GccToolChainFactory::supportedLanguages() const
|
|
|
|
|
{
|
2016-07-12 15:08:53 +02:00
|
|
|
return { ToolChain::Language::Cxx, ToolChain::Language::C };
|
2016-07-12 11:33:17 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
bool GccToolChainFactory::canCreate()
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-12 15:08:53 +02:00
|
|
|
ToolChain *GccToolChainFactory::create(ToolChain::Language l)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2016-07-12 12:20:06 +02:00
|
|
|
ToolChain *tc = createToolChain(false);
|
2016-07-12 15:08:53 +02:00
|
|
|
tc->setLanguage(l);
|
2016-07-12 12:20:06 +02:00
|
|
|
return tc;
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2015-07-19 10:59:06 +03:00
|
|
|
QList<ToolChain *> GccToolChainFactory::autoDetect(const QList<ToolChain *> &alreadyKnown)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
QList<ToolChain *> tcs;
|
2015-02-03 23:59:04 +02:00
|
|
|
if (HostOsInfo::isMacHost()) {
|
2012-08-23 15:53:58 +02:00
|
|
|
// Old mac compilers needed to support macx-gccXY mkspecs:
|
2015-10-30 13:30:08 +01:00
|
|
|
tcs.append(autoDetectToolchains(QLatin1String("g++-4.0"), Abi::hostAbi(),
|
2016-07-13 09:47:07 +02:00
|
|
|
ToolChain::Language::Cxx, Constants::GCC_TOOLCHAIN_TYPEID,
|
|
|
|
|
alreadyKnown));
|
2015-10-30 13:30:08 +01:00
|
|
|
tcs.append(autoDetectToolchains(QLatin1String("g++-4.2"), Abi::hostAbi(),
|
2016-07-13 09:47:07 +02:00
|
|
|
ToolChain::Language::Cxx, Constants::GCC_TOOLCHAIN_TYPEID,
|
|
|
|
|
alreadyKnown));
|
|
|
|
|
tcs.append(autoDetectToolchains(QLatin1String("gcc-4.0"), Abi::hostAbi(),
|
|
|
|
|
ToolChain::Language::C, Constants::GCC_TOOLCHAIN_TYPEID,
|
|
|
|
|
alreadyKnown));
|
|
|
|
|
tcs.append(autoDetectToolchains(QLatin1String("gcc-4.2"), Abi::hostAbi(),
|
|
|
|
|
ToolChain::Language::C, Constants::GCC_TOOLCHAIN_TYPEID,
|
|
|
|
|
alreadyKnown));
|
2012-08-23 15:53:58 +02:00
|
|
|
}
|
2016-07-13 09:47:07 +02:00
|
|
|
tcs.append(autoDetectToolchains(QLatin1String("g++"), Abi::hostAbi(), ToolChain::Language::Cxx,
|
|
|
|
|
Constants::GCC_TOOLCHAIN_TYPEID,alreadyKnown));
|
|
|
|
|
tcs.append(autoDetectToolchains(QLatin1String("gcc"), Abi::hostAbi(), ToolChain::Language::C,
|
2015-10-30 13:30:08 +01:00
|
|
|
Constants::GCC_TOOLCHAIN_TYPEID,alreadyKnown));
|
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
|
2013-08-09 17:49:30 +02:00
|
|
|
bool GccToolChainFactory::canRestore(const QVariantMap &data)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2015-07-07 15:37:50 +02:00
|
|
|
return typeIdFromMap(data) == Constants::GCC_TOOLCHAIN_TYPEID;
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
ToolChain *GccToolChainFactory::restore(const QVariantMap &data)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2015-07-08 12:33:55 +02:00
|
|
|
GccToolChain *tc = createToolChain(false);
|
|
|
|
|
if (tc->fromMap(data))
|
2011-02-01 18:36:00 +01:00
|
|
|
return tc;
|
|
|
|
|
|
|
|
|
|
delete tc;
|
2016-04-13 15:52:14 +02:00
|
|
|
return nullptr;
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
GccToolChain *GccToolChainFactory::createToolChain(bool autoDetect)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2013-09-03 10:58:59 +02:00
|
|
|
return new GccToolChain(autoDetect ? ToolChain::AutoDetection : ToolChain::ManualDetection);
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
QList<ToolChain *> GccToolChainFactory::autoDetectToolchains(const QString &compiler,
|
2015-07-19 10:59:06 +03:00
|
|
|
const Abi &requiredAbi,
|
2016-07-13 09:47:07 +02:00
|
|
|
ToolChain::Language l,
|
2015-10-30 13:30:08 +01:00
|
|
|
const Core::Id requiredTypeId,
|
2015-07-19 10:59:06 +03:00
|
|
|
const QList<ToolChain *> &alreadyKnown)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
|
|
|
|
QList<ToolChain *> result;
|
|
|
|
|
|
2013-09-02 17:19:57 +02:00
|
|
|
Environment systemEnvironment = Environment::systemEnvironment();
|
2014-07-15 23:32:11 +03:00
|
|
|
const FileName compilerPath = 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
|
|
|
|
2015-10-30 13:30:08 +01:00
|
|
|
result = Utils::filtered(alreadyKnown, [requiredTypeId, compilerPath](ToolChain *tc) {
|
|
|
|
|
return tc->typeId() == requiredTypeId
|
|
|
|
|
&& tc->compilerCommand() == compilerPath;
|
|
|
|
|
});
|
2015-10-15 16:01:40 +02:00
|
|
|
if (!result.isEmpty())
|
2015-07-19 10:59:06 +03:00
|
|
|
return result;
|
|
|
|
|
|
2013-09-02 17:19:57 +02:00
|
|
|
GccToolChain::addCommandPathToEnvironment(compilerPath, systemEnvironment);
|
2013-10-29 12:07:16 +01:00
|
|
|
QByteArray macros
|
|
|
|
|
= gccPredefinedMacros(compilerPath, gccPredefinedMacrosOptions(), systemEnvironment.toStringList());
|
2016-03-04 15:33:16 +01:00
|
|
|
const GccToolChain::DetectedAbisResult detectedAbis = guessGccAbi(compilerPath,
|
|
|
|
|
systemEnvironment.toStringList(),
|
|
|
|
|
macros);
|
|
|
|
|
QList<Abi> abiList = detectedAbis.supportedAbis;
|
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
|
|
|
|
2015-10-14 11:13:07 +02:00
|
|
|
tc->setMacroCache(QStringList(), macros);
|
2012-01-30 13:07:51 +01:00
|
|
|
tc->setCompilerCommand(compilerPath);
|
2014-07-21 14:23:09 +02:00
|
|
|
tc->setSupportedAbis(abiList);
|
2011-03-10 14:44:49 +01:00
|
|
|
tc->setTargetAbi(abi);
|
2016-03-04 15:33:16 +01:00
|
|
|
tc->setOriginalTargetTriple(detectedAbis.originalTargetTriple);
|
2011-03-14 11:00:38 +01:00
|
|
|
tc->setDisplayName(tc->defaultDisplayName()); // reset displayname
|
2016-07-13 09:47:07 +02:00
|
|
|
tc->setLanguage(l);
|
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
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
GccToolChainConfigWidget::GccToolChainConfigWidget(GccToolChain *tc) :
|
2011-02-22 12:25:19 +01:00
|
|
|
ToolChainConfigWidget(tc),
|
2012-08-21 13:29:16 +02:00
|
|
|
m_compilerCommand(new PathChooser),
|
2016-04-13 15:52:14 +02:00
|
|
|
m_abiWidget(new AbiWidget)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
|
|
|
|
Q_ASSERT(tc);
|
|
|
|
|
|
2011-02-22 17:32:22 +01:00
|
|
|
const QStringList gnuVersionArgs = QStringList(QLatin1String("--version"));
|
2012-08-21 13:29:16 +02:00
|
|
|
m_compilerCommand->setExpectedKind(PathChooser::ExistingCommand);
|
2012-02-01 14:39:11 +01:00
|
|
|
m_compilerCommand->setCommandVersionArguments(gnuVersionArgs);
|
2013-11-25 14:35:35 +01:00
|
|
|
m_compilerCommand->setHistoryCompleter(QLatin1String("PE.Gcc.Command.History"));
|
2012-08-16 15:59:10 +02:00
|
|
|
m_mainLayout->addRow(tr("&Compiler path:"), m_compilerCommand);
|
2013-04-22 23:03:45 +02:00
|
|
|
m_platformCodeGenFlagsLineEdit = new QLineEdit(this);
|
|
|
|
|
m_platformCodeGenFlagsLineEdit->setText(QtcProcess::joinArgs(tc->platformCodeGenFlags()));
|
|
|
|
|
m_mainLayout->addRow(tr("Platform codegen flags:"), m_platformCodeGenFlagsLineEdit);
|
|
|
|
|
m_platformLinkerFlagsLineEdit = new QLineEdit(this);
|
|
|
|
|
m_platformLinkerFlagsLineEdit->setText(QtcProcess::joinArgs(tc->platformLinkerFlags()));
|
|
|
|
|
m_mainLayout->addRow(tr("Platform linker flags:"), m_platformLinkerFlagsLineEdit);
|
2012-08-16 15:59:10 +02:00
|
|
|
m_mainLayout->addRow(tr("&ABI:"), m_abiWidget);
|
2013-04-22 23:03:45 +02:00
|
|
|
|
2011-06-08 15:39:14 +00:00
|
|
|
m_abiWidget->setEnabled(false);
|
2012-08-16 15:59:10 +02:00
|
|
|
addErrorLabel();
|
2011-04-13 15:50:14 +02:00
|
|
|
|
2011-02-23 11:36:59 +01:00
|
|
|
setFromToolchain();
|
2011-06-21 13:26:22 +02:00
|
|
|
|
2016-01-29 16:38:37 +02:00
|
|
|
connect(m_compilerCommand, &PathChooser::rawPathChanged,
|
|
|
|
|
this, &GccToolChainConfigWidget::handleCompilerCommandChange);
|
|
|
|
|
connect(m_platformCodeGenFlagsLineEdit, &QLineEdit::editingFinished,
|
|
|
|
|
this, &GccToolChainConfigWidget::handlePlatformCodeGenFlagsChange);
|
|
|
|
|
connect(m_platformLinkerFlagsLineEdit, &QLineEdit::editingFinished,
|
|
|
|
|
this, &GccToolChainConfigWidget::handlePlatformLinkerFlagsChange);
|
|
|
|
|
connect(m_abiWidget, &AbiWidget::abiChanged, this, &ToolChainConfigWidget::dirty);
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
void GccToolChainConfigWidget::applyImpl()
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
|
|
|
|
if (toolChain()->isAutoDetected())
|
|
|
|
|
return;
|
|
|
|
|
|
2016-04-13 15:52:14 +02:00
|
|
|
auto tc = static_cast<GccToolChain *>(toolChain());
|
2011-02-01 18:36:00 +01:00
|
|
|
Q_ASSERT(tc);
|
|
|
|
|
QString displayName = tc->displayName();
|
2012-02-01 14:39:11 +01:00
|
|
|
tc->setCompilerCommand(m_compilerCommand->fileName());
|
2014-07-21 14:23:09 +02:00
|
|
|
tc->setSupportedAbis(m_abiWidget->supportedAbis());
|
2011-05-24 14:06:51 +00:00
|
|
|
tc->setTargetAbi(m_abiWidget->currentAbi());
|
2016-03-04 15:33:16 +01:00
|
|
|
tc->setOriginalTargetTriple(tc->detectSupportedAbis().originalTargetTriple);
|
2011-02-01 18:36:00 +01:00
|
|
|
tc->setDisplayName(displayName); // reset display name
|
2013-04-22 23:03:45 +02:00
|
|
|
tc->setPlatformCodeGenFlags(splitString(m_platformCodeGenFlagsLineEdit->text()));
|
|
|
|
|
tc->setPlatformLinkerFlags(splitString(m_platformLinkerFlagsLineEdit->text()));
|
2013-10-29 12:07:16 +01:00
|
|
|
tc->setMacroCache(tc->platformCodeGenFlags(), m_macros);
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
void 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);
|
2016-04-13 15:52:14 +02:00
|
|
|
auto tc = static_cast<GccToolChain *>(toolChain());
|
2012-02-01 14:39:11 +01:00
|
|
|
m_compilerCommand->setFileName(tc->compilerCommand());
|
2013-04-22 23:03:45 +02:00
|
|
|
m_platformCodeGenFlagsLineEdit->setText(QtcProcess::joinArgs(tc->platformCodeGenFlags()));
|
|
|
|
|
m_platformLinkerFlagsLineEdit->setText(QtcProcess::joinArgs(tc->platformLinkerFlags()));
|
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
|
|
|
}
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
bool GccToolChainConfigWidget::isDirtyImpl() const
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2016-04-13 15:52:14 +02:00
|
|
|
auto tc = static_cast<GccToolChain *>(toolChain());
|
2011-02-01 18:36:00 +01:00
|
|
|
Q_ASSERT(tc);
|
2012-02-01 14:39:11 +01:00
|
|
|
return m_compilerCommand->fileName() != tc->compilerCommand()
|
2013-04-22 23:03:45 +02:00
|
|
|
|| m_platformCodeGenFlagsLineEdit->text() != QtcProcess::joinArgs(tc->platformCodeGenFlags())
|
|
|
|
|
|| m_platformLinkerFlagsLineEdit->text() != QtcProcess::joinArgs(tc->platformLinkerFlags())
|
2012-04-24 15:49:09 +02:00
|
|
|
|| m_abiWidget->currentAbi() != tc->targetAbi();
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
void GccToolChainConfigWidget::makeReadOnlyImpl()
|
2011-03-29 17:51:40 +02:00
|
|
|
{
|
2014-07-03 08:39:01 +03:00
|
|
|
m_compilerCommand->setReadOnly(true);
|
2011-05-24 14:06:51 +00:00
|
|
|
m_abiWidget->setEnabled(false);
|
2013-07-15 16:31:27 +02:00
|
|
|
m_platformCodeGenFlagsLineEdit->setEnabled(false);
|
|
|
|
|
m_platformLinkerFlagsLineEdit->setEnabled(false);
|
2011-06-27 17:24:54 +02:00
|
|
|
m_isReadOnly = true;
|
2011-03-29 17:51:40 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
QStringList GccToolChainConfigWidget::splitString(const QString &s)
|
2013-04-22 23:03:45 +02:00
|
|
|
{
|
|
|
|
|
QtcProcess::SplitError splitError;
|
2014-02-05 10:43:21 +01:00
|
|
|
const OsType osType = HostOsInfo::hostOs();
|
|
|
|
|
QStringList res = QtcProcess::splitArgs(s, osType, false, &splitError);
|
2013-04-22 23:03:45 +02:00
|
|
|
if (splitError != QtcProcess::SplitOk){
|
2014-02-05 10:43:21 +01:00
|
|
|
res = QtcProcess::splitArgs(s + QLatin1Char('\\'), osType, false, &splitError);
|
2013-04-22 23:03:45 +02:00
|
|
|
if (splitError != QtcProcess::SplitOk){
|
2014-02-05 10:43:21 +01:00
|
|
|
res = QtcProcess::splitArgs(s + QLatin1Char('"'), osType, false, &splitError);
|
2013-04-22 23:03:45 +02:00
|
|
|
if (splitError != QtcProcess::SplitOk)
|
2014-02-05 10:43:21 +01:00
|
|
|
res = QtcProcess::splitArgs(s + QLatin1Char('\''), osType, false, &splitError);
|
2013-04-22 23:03:45 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
void GccToolChainConfigWidget::handleCompilerCommandChange()
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2013-11-04 14:46:45 +01:00
|
|
|
bool haveCompiler = false;
|
|
|
|
|
Abi currentAbi = m_abiWidget->currentAbi();
|
|
|
|
|
bool customAbi = m_abiWidget->isCustomAbi();
|
2012-08-21 13:29:16 +02:00
|
|
|
FileName path = m_compilerCommand->fileName();
|
2011-03-10 14:44:49 +01:00
|
|
|
QList<Abi> abiList;
|
2013-11-04 14:46:45 +01:00
|
|
|
|
2011-06-08 15:39:14 +00:00
|
|
|
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();
|
|
|
|
|
}
|
2013-09-02 17:19:57 +02:00
|
|
|
if (haveCompiler) {
|
|
|
|
|
Environment env = Environment::systemEnvironment();
|
|
|
|
|
GccToolChain::addCommandPathToEnvironment(path, env);
|
2013-10-29 12:07:16 +01:00
|
|
|
QStringList args = gccPredefinedMacrosOptions() + splitString(m_platformCodeGenFlagsLineEdit->text());
|
|
|
|
|
m_macros = gccPredefinedMacros(path, args, env.toStringList());
|
|
|
|
|
abiList = guessGccAbi(path, env.toStringList(), m_macros,
|
2016-03-04 15:33:16 +01:00
|
|
|
splitString(m_platformCodeGenFlagsLineEdit->text())).supportedAbis;
|
2013-09-02 17:19:57 +02:00
|
|
|
}
|
2011-06-08 15:39:14 +00:00
|
|
|
m_abiWidget->setEnabled(haveCompiler);
|
2013-11-04 14:46:45 +01:00
|
|
|
|
|
|
|
|
// Find a good ABI for the new compiler:
|
|
|
|
|
Abi newAbi;
|
|
|
|
|
if (customAbi)
|
|
|
|
|
newAbi = currentAbi;
|
|
|
|
|
else if (abiList.contains(currentAbi))
|
|
|
|
|
newAbi = currentAbi;
|
|
|
|
|
|
|
|
|
|
m_abiWidget->setAbis(abiList, newAbi);
|
2012-02-21 12:00:45 +01:00
|
|
|
emit dirty();
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
void GccToolChainConfigWidget::handlePlatformCodeGenFlagsChange()
|
2013-04-22 23:03:45 +02:00
|
|
|
{
|
|
|
|
|
QString str1 = m_platformCodeGenFlagsLineEdit->text();
|
|
|
|
|
QString str2 = QtcProcess::joinArgs(splitString(str1));
|
|
|
|
|
if (str1 != str2)
|
|
|
|
|
m_platformCodeGenFlagsLineEdit->setText(str2);
|
|
|
|
|
else
|
|
|
|
|
handleCompilerCommandChange();
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
void GccToolChainConfigWidget::handlePlatformLinkerFlagsChange()
|
2013-04-22 23:03:45 +02:00
|
|
|
{
|
|
|
|
|
QString str1 = m_platformLinkerFlagsLineEdit->text();
|
|
|
|
|
QString str2 = QtcProcess::joinArgs(splitString(str1));
|
|
|
|
|
if (str1 != str2)
|
|
|
|
|
m_platformLinkerFlagsLineEdit->setText(str2);
|
|
|
|
|
else
|
|
|
|
|
emit dirty();
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-13 11:48:34 +02:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// ClangToolChain
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
2013-09-03 10:58:59 +02:00
|
|
|
ClangToolChain::ClangToolChain(Detection d) :
|
2015-07-07 15:37:50 +02:00
|
|
|
GccToolChain(Constants::CLANG_TOOLCHAIN_TYPEID, d)
|
2011-05-13 11:48:34 +02:00
|
|
|
{ }
|
|
|
|
|
|
2012-01-30 11:55:21 +01:00
|
|
|
QString ClangToolChain::typeDisplayName() const
|
2011-05-13 11:48:34 +02:00
|
|
|
{
|
2013-08-09 17:49:30 +02:00
|
|
|
return ClangToolChainFactory::tr("Clang");
|
2011-05-13 11:48:34 +02:00
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:59:04 +02:00
|
|
|
QString ClangToolChain::makeCommand(const Environment &environment) const
|
2011-05-13 11:48:34 +02:00
|
|
|
{
|
2012-09-11 15:59:17 +02:00
|
|
|
QStringList makes;
|
2015-02-03 23:59:04 +02:00
|
|
|
if (HostOsInfo::isWindowsHost()) {
|
2012-09-12 17:27:37 +02:00
|
|
|
makes << QLatin1String("mingw32-make.exe");
|
|
|
|
|
makes << QLatin1String("make.exe");
|
|
|
|
|
} else {
|
|
|
|
|
makes << QLatin1String("make");
|
|
|
|
|
}
|
2012-09-11 15:59:17 +02:00
|
|
|
|
2014-07-15 23:32:11 +03:00
|
|
|
FileName tmp;
|
2012-09-11 15:59:17 +02:00
|
|
|
foreach (const QString &make, makes) {
|
|
|
|
|
tmp = environment.searchInPath(make);
|
|
|
|
|
if (!tmp.isEmpty())
|
2014-07-15 23:32:11 +03:00
|
|
|
return tmp.toString();
|
2012-09-11 15:59:17 +02:00
|
|
|
}
|
|
|
|
|
return makes.first();
|
2011-05-13 11:48:34 +02:00
|
|
|
}
|
|
|
|
|
|
2013-04-28 13:11:48 +04:00
|
|
|
/**
|
|
|
|
|
* @brief Similar to \a GccToolchain::compilerFlags, but recognizes
|
|
|
|
|
* "-fborland-extensions".
|
|
|
|
|
*/
|
|
|
|
|
ToolChain::CompilerFlags ClangToolChain::compilerFlags(const QStringList &cxxflags) const
|
|
|
|
|
{
|
|
|
|
|
CompilerFlags flags = GccToolChain::compilerFlags(cxxflags);
|
|
|
|
|
if (cxxflags.contains(QLatin1String("-fborland-extensions")))
|
|
|
|
|
flags |= BorlandExtensions;
|
|
|
|
|
return flags;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-18 11:56:54 +01:00
|
|
|
WarningFlags ClangToolChain::warningFlags(const QStringList &cflags) const
|
2013-03-03 21:53:38 +04:00
|
|
|
{
|
2013-09-03 18:48:02 +02:00
|
|
|
WarningFlags flags = GccToolChain::warningFlags(cflags);
|
2013-03-03 21:53:38 +04:00
|
|
|
foreach (const QString &flag, cflags) {
|
|
|
|
|
if (flag == QLatin1String("-Wdocumentation"))
|
2016-01-18 11:56:54 +01:00
|
|
|
flags |= WarningFlags::Documentation;
|
2013-03-03 21:53:38 +04:00
|
|
|
if (flag == QLatin1String("-Wno-documentation"))
|
2016-01-18 11:56:54 +01:00
|
|
|
flags &= ~WarningFlags::Documentation;
|
2013-03-03 21:53:38 +04:00
|
|
|
}
|
|
|
|
|
return flags;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-03 14:01:25 +01:00
|
|
|
FileNameList ClangToolChain::suggestedMkspecList() const
|
2011-05-13 11:48:34 +02:00
|
|
|
{
|
2011-09-06 15:19:05 +00:00
|
|
|
Abi abi = targetAbi();
|
2016-07-25 18:39:16 -07:00
|
|
|
if (abi.os() == Abi::DarwinOS)
|
2015-11-03 14:01:25 +01:00
|
|
|
return FileNameList()
|
2014-02-07 15:46:36 +01:00
|
|
|
<< FileName::fromLatin1("macx-clang")
|
|
|
|
|
<< FileName::fromLatin1("macx-clang-32")
|
|
|
|
|
<< FileName::fromLatin1("unsupported/macx-clang")
|
|
|
|
|
<< FileName::fromLatin1("macx-ios-clang");
|
2011-09-06 15:19:05 +00:00
|
|
|
else if (abi.os() == Abi::LinuxOS)
|
2015-11-03 14:01:25 +01:00
|
|
|
return FileNameList()
|
2014-02-07 15:46:36 +01:00
|
|
|
<< FileName::fromLatin1("linux-clang")
|
|
|
|
|
<< FileName::fromLatin1("unsupported/linux-clang");
|
2015-11-03 14:01:25 +01:00
|
|
|
return FileNameList(); // Note: Not supported by Qt yet, so default to the mkspec the Qt was build with
|
2011-05-18 18:38:58 +02:00
|
|
|
}
|
|
|
|
|
|
2013-06-24 17:09:24 +02:00
|
|
|
void ClangToolChain::addToEnvironment(Environment &env) const
|
|
|
|
|
{
|
|
|
|
|
GccToolChain::addToEnvironment(env);
|
|
|
|
|
// Clang takes PWD as basis for debug info, if set.
|
|
|
|
|
// When running Qt Creator from a shell, PWD is initially set to an "arbitrary" value.
|
|
|
|
|
// Since the tools are not called through a shell, PWD is never changed to the actual cwd,
|
|
|
|
|
// so we better make sure PWD is empty to begin with
|
|
|
|
|
env.unset(QLatin1String("PWD"));
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-28 13:11:48 +04:00
|
|
|
ToolChain::CompilerFlags ClangToolChain::defaultCompilerFlags() const
|
|
|
|
|
{
|
2014-10-23 18:08:07 +02:00
|
|
|
return CompilerFlags(GnuExtensions | StandardCxx11);
|
2013-04-28 13:11:48 +04:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
ClangToolChainFactory::ClangToolChainFactory()
|
2011-05-13 11:48:34 +02:00
|
|
|
{
|
2013-08-09 17:49:30 +02:00
|
|
|
setDisplayName(tr("Clang"));
|
2011-05-13 11:48:34 +02:00
|
|
|
}
|
|
|
|
|
|
2016-07-12 11:33:17 +02:00
|
|
|
QSet<ToolChain::Language> ClangToolChainFactory::supportedLanguages() const
|
|
|
|
|
{
|
2016-07-12 15:08:53 +02:00
|
|
|
return { ProjectExplorer::ToolChain::Language::Cxx, ProjectExplorer::ToolChain::Language::C };
|
2016-07-12 11:33:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-07-19 10:59:06 +03:00
|
|
|
QList<ToolChain *> ClangToolChainFactory::autoDetect(const QList<ToolChain *> &alreadyKnown)
|
2011-05-13 11:48:34 +02:00
|
|
|
{
|
2016-07-13 09:47:07 +02:00
|
|
|
QList<ToolChain *> result
|
|
|
|
|
= autoDetectToolchains(QLatin1String("clang++"), Abi::hostAbi(),
|
|
|
|
|
ToolChain::Language::Cxx, Constants::CLANG_TOOLCHAIN_TYPEID,
|
|
|
|
|
alreadyKnown);
|
|
|
|
|
result += autoDetectToolchains(QLatin1String("clang"), Abi::hostAbi(),
|
|
|
|
|
ToolChain::Language::C, Constants::CLANG_TOOLCHAIN_TYPEID,
|
|
|
|
|
alreadyKnown);
|
|
|
|
|
return result;
|
2011-05-13 11:48:34 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
bool ClangToolChainFactory::canRestore(const QVariantMap &data)
|
2011-05-13 11:48:34 +02:00
|
|
|
{
|
2015-07-07 15:37:50 +02:00
|
|
|
return typeIdFromMap(data) == Constants::CLANG_TOOLCHAIN_TYPEID;
|
2011-05-13 11:48:34 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
GccToolChain *ClangToolChainFactory::createToolChain(bool autoDetect)
|
2011-05-13 11:48:34 +02:00
|
|
|
{
|
2013-09-03 10:58:59 +02:00
|
|
|
return new ClangToolChain(autoDetect ? ToolChain::AutoDetection : ToolChain::ManualDetection);
|
2011-05-13 11:48:34 +02:00
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// MingwToolChain
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
2013-09-03 10:58:59 +02:00
|
|
|
MingwToolChain::MingwToolChain(Detection d) :
|
2015-07-07 15:37:50 +02:00
|
|
|
GccToolChain(Constants::MINGW_TOOLCHAIN_TYPEID, d)
|
2011-02-01 18:36:00 +01:00
|
|
|
{ }
|
|
|
|
|
|
2012-01-30 11:55:21 +01:00
|
|
|
QString MingwToolChain::typeDisplayName() const
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2013-08-09 17:49:30 +02:00
|
|
|
return MingwToolChainFactory::tr("MinGW");
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2015-11-03 14:01:25 +01:00
|
|
|
FileNameList MingwToolChain::suggestedMkspecList() const
|
2011-04-07 13:12:55 +02:00
|
|
|
{
|
2015-02-03 23:59:04 +02:00
|
|
|
if (HostOsInfo::isWindowsHost())
|
2015-11-03 14:01:25 +01:00
|
|
|
return FileNameList() << FileName::fromLatin1("win32-g++");
|
2015-02-03 23:59:04 +02:00
|
|
|
if (HostOsInfo::isLinuxHost()) {
|
2012-11-21 22:40:31 +02:00
|
|
|
if (version().startsWith(QLatin1String("4.6.")))
|
2015-11-03 14:01:25 +01:00
|
|
|
return FileNameList()
|
2014-02-07 15:46:36 +01:00
|
|
|
<< FileName::fromLatin1("win32-g++-4.6-cross")
|
|
|
|
|
<< FileName::fromLatin1("unsupported/win32-g++-4.6-cross");
|
2012-08-23 15:53:58 +02:00
|
|
|
else
|
2015-11-03 14:01:25 +01:00
|
|
|
return FileNameList()
|
2014-02-07 15:46:36 +01:00
|
|
|
<< FileName::fromLatin1("win32-g++-cross")
|
|
|
|
|
<< FileName::fromLatin1("unsupported/win32-g++-cross");
|
2012-08-23 15:53:58 +02:00
|
|
|
}
|
2015-11-03 14:01:25 +01:00
|
|
|
return FileNameList();
|
2011-04-07 13:12:55 +02:00
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:59:04 +02:00
|
|
|
QString MingwToolChain::makeCommand(const Environment &environment) const
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2012-09-11 15:59:17 +02:00
|
|
|
QStringList makes;
|
2015-02-03 23:59:04 +02:00
|
|
|
if (HostOsInfo::isWindowsHost()) {
|
2012-09-11 15:59:17 +02:00
|
|
|
makes << QLatin1String("mingw32-make.exe");
|
|
|
|
|
makes << QLatin1String("make.exe");
|
2012-09-12 17:27:37 +02:00
|
|
|
} else {
|
2012-09-11 15:59:17 +02:00
|
|
|
makes << QLatin1String("make");
|
2012-09-12 17:27:37 +02:00
|
|
|
}
|
2012-09-11 15:59:17 +02:00
|
|
|
|
2014-07-15 23:32:11 +03:00
|
|
|
FileName tmp;
|
2012-09-11 15:59:17 +02:00
|
|
|
foreach (const QString &make, makes) {
|
|
|
|
|
tmp = environment.searchInPath(make);
|
|
|
|
|
if (!tmp.isEmpty())
|
2014-07-15 23:32:11 +03:00
|
|
|
return tmp.toString();
|
2012-09-11 15:59:17 +02:00
|
|
|
}
|
|
|
|
|
return makes.first();
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain *MingwToolChain::clone() const
|
|
|
|
|
{
|
|
|
|
|
return new MingwToolChain(*this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// MingwToolChainFactory
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
MingwToolChainFactory::MingwToolChainFactory()
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2013-08-09 17:49:30 +02:00
|
|
|
setDisplayName(tr("MinGW"));
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2016-07-12 11:33:17 +02:00
|
|
|
QSet<ToolChain::Language> MingwToolChainFactory::supportedLanguages() const
|
|
|
|
|
{
|
2016-07-13 09:47:07 +02:00
|
|
|
return { ProjectExplorer::ToolChain::Language::Cxx, ProjectExplorer::ToolChain::Language::C };
|
2016-07-12 11:33:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-07-19 10:59:06 +03:00
|
|
|
QList<ToolChain *> MingwToolChainFactory::autoDetect(const QList<ToolChain *> &alreadyKnown)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2015-10-14 16:38:23 +03:00
|
|
|
Abi ha = Abi::hostAbi();
|
|
|
|
|
ha = Abi(ha.architecture(), Abi::WindowsOS, Abi::WindowsMSysFlavor, Abi::PEFormat, ha.wordWidth());
|
2016-07-13 09:47:07 +02:00
|
|
|
QList<ToolChain *> result
|
|
|
|
|
= autoDetectToolchains(QLatin1String("g++"), ha, ToolChain::Language::Cxx,
|
|
|
|
|
Constants::MINGW_TOOLCHAIN_TYPEID, alreadyKnown);
|
|
|
|
|
result += autoDetectToolchains(QLatin1String("gcc"), ha, ToolChain::Language::C,
|
|
|
|
|
Constants::MINGW_TOOLCHAIN_TYPEID, alreadyKnown);
|
|
|
|
|
return result;
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
bool MingwToolChainFactory::canRestore(const QVariantMap &data)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2015-07-07 15:37:50 +02:00
|
|
|
return typeIdFromMap(data) == Constants::MINGW_TOOLCHAIN_TYPEID;
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
GccToolChain *MingwToolChainFactory::createToolChain(bool autoDetect)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2013-09-03 10:58:59 +02:00
|
|
|
return new MingwToolChain(autoDetect ? ToolChain::AutoDetection : ToolChain::ManualDetection);
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// LinuxIccToolChain
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
2013-09-03 10:58:59 +02:00
|
|
|
LinuxIccToolChain::LinuxIccToolChain(Detection d) :
|
2015-07-07 15:37:50 +02:00
|
|
|
GccToolChain(Constants::LINUXICC_TOOLCHAIN_TYPEID, d)
|
2011-02-01 18:36:00 +01:00
|
|
|
{ }
|
|
|
|
|
|
2012-01-30 11:55:21 +01:00
|
|
|
QString LinuxIccToolChain::typeDisplayName() const
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2013-08-09 17:49:30 +02:00
|
|
|
return LinuxIccToolChainFactory::tr("Linux ICC");
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2013-04-28 13:11:48 +04:00
|
|
|
/**
|
|
|
|
|
* Similar to \a GccToolchain::compilerFlags, but uses "-openmp" instead of
|
|
|
|
|
* "-fopenmp" and "-fms-dialect[=ver]" instead of "-fms-extensions".
|
|
|
|
|
* @see UNIX manual for "icc"
|
|
|
|
|
*/
|
|
|
|
|
ToolChain::CompilerFlags LinuxIccToolChain::compilerFlags(const QStringList &cxxflags) const
|
|
|
|
|
{
|
|
|
|
|
QStringList copy = cxxflags;
|
|
|
|
|
copy.removeAll(QLatin1String("-fopenmp"));
|
|
|
|
|
copy.removeAll(QLatin1String("-fms-extensions"));
|
|
|
|
|
|
|
|
|
|
CompilerFlags flags = GccToolChain::compilerFlags(cxxflags);
|
|
|
|
|
if (cxxflags.contains(QLatin1String("-openmp")))
|
|
|
|
|
flags |= OpenMP;
|
|
|
|
|
if (cxxflags.contains(QLatin1String("-fms-dialect"))
|
|
|
|
|
|| cxxflags.contains(QLatin1String("-fms-dialect=8"))
|
|
|
|
|
|| cxxflags.contains(QLatin1String("-fms-dialect=9"))
|
|
|
|
|
|| cxxflags.contains(QLatin1String("-fms-dialect=10")))
|
|
|
|
|
flags |= MicrosoftExtensions;
|
|
|
|
|
return flags;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
IOutputParser *LinuxIccToolChain::outputParser() const
|
|
|
|
|
{
|
|
|
|
|
return new LinuxIccParser;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-03 14:01:25 +01:00
|
|
|
FileNameList LinuxIccToolChain::suggestedMkspecList() const
|
2011-04-07 13:12:55 +02:00
|
|
|
{
|
2015-11-03 14:01:25 +01:00
|
|
|
return FileNameList()
|
2012-08-21 13:29:16 +02:00
|
|
|
<< 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
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
LinuxIccToolChainFactory::LinuxIccToolChainFactory()
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2013-08-09 17:49:30 +02:00
|
|
|
setDisplayName(tr("Linux ICC"));
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2016-07-12 11:33:17 +02:00
|
|
|
QSet<ToolChain::Language> LinuxIccToolChainFactory::supportedLanguages() const
|
|
|
|
|
{
|
|
|
|
|
return { ProjectExplorer::ToolChain::Language::Cxx };
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-19 10:59:06 +03:00
|
|
|
QList<ToolChain *> LinuxIccToolChainFactory::autoDetect(const QList<ToolChain *> &alreadyKnown)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2016-07-13 09:47:07 +02:00
|
|
|
return autoDetectToolchains(QLatin1String("icpc"), Abi::hostAbi(), ToolChain::Language::Cxx,
|
2015-10-30 13:30:08 +01:00
|
|
|
Constants::LINUXICC_TOOLCHAIN_TYPEID, alreadyKnown);
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
bool LinuxIccToolChainFactory::canRestore(const QVariantMap &data)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2015-07-07 15:37:50 +02:00
|
|
|
return typeIdFromMap(data) == Constants::LINUXICC_TOOLCHAIN_TYPEID;
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
GccToolChain *LinuxIccToolChainFactory::createToolChain(bool autoDetect)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2013-09-03 10:58:59 +02:00
|
|
|
return new LinuxIccToolChain(autoDetect ? ToolChain::AutoDetection : ToolChain::ManualDetection);
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-18 11:56:54 +01:00
|
|
|
GccToolChain::WarningFlagAdder::WarningFlagAdder(const QString &flag, WarningFlags &flags) :
|
2016-04-13 15:52:14 +02:00
|
|
|
m_flags(flags)
|
2013-03-03 21:53:38 +04:00
|
|
|
{
|
|
|
|
|
if (!flag.startsWith(QLatin1String("-W"))) {
|
|
|
|
|
m_triggered = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_doesEnable = !flag.startsWith(QLatin1String("-Wno-"));
|
|
|
|
|
if (m_doesEnable)
|
|
|
|
|
m_flagUtf8 = flag.mid(2).toUtf8();
|
|
|
|
|
else
|
|
|
|
|
m_flagUtf8 = flag.mid(5).toUtf8();
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-18 11:56:54 +01:00
|
|
|
void GccToolChain::WarningFlagAdder::operator ()(const char name[], WarningFlags flagsSet)
|
2013-03-03 21:53:38 +04:00
|
|
|
{
|
|
|
|
|
if (m_triggered)
|
|
|
|
|
return;
|
|
|
|
|
if (0 == strcmp(m_flagUtf8.data(), name))
|
|
|
|
|
{
|
|
|
|
|
m_triggered = true;
|
|
|
|
|
if (m_doesEnable)
|
|
|
|
|
m_flags |= flagsSet;
|
|
|
|
|
else
|
|
|
|
|
m_flags &= ~flagsSet;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool GccToolChain::WarningFlagAdder::triggered() const
|
|
|
|
|
{
|
|
|
|
|
return m_triggered;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
} // 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");
|
2013-02-20 12:23:45 +01:00
|
|
|
QTest::addColumn<QByteArray>("macros");
|
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")
|
2013-02-20 12:23:45 +01:00
|
|
|
<< QByteArray("")
|
2011-03-10 14:44:49 +01:00
|
|
|
<< (QStringList());
|
2011-02-01 18:36:00 +01:00
|
|
|
QTest::newRow("empty input")
|
|
|
|
|
<< QString::fromLatin1("")
|
2013-02-20 12:23:45 +01:00
|
|
|
<< QByteArray("")
|
|
|
|
|
<< (QStringList());
|
|
|
|
|
QTest::newRow("empty input (with macros)")
|
|
|
|
|
<< QString::fromLatin1("")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 8\n#define __Something\n")
|
2011-03-10 14:44:49 +01:00
|
|
|
<< (QStringList());
|
2013-11-04 13:07:20 +01:00
|
|
|
QTest::newRow("broken input -- 64bit")
|
|
|
|
|
<< QString::fromLatin1("arm-none-foo-gnueabi")
|
|
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 8\n#define __Something\n")
|
|
|
|
|
<< (QStringList() << QLatin1String("arm-unknown-unknown-unknown-64bit"));
|
|
|
|
|
QTest::newRow("broken input -- 32bit")
|
2011-02-01 18:36:00 +01:00
|
|
|
<< QString::fromLatin1("arm-none-foo-gnueabi")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 4\n#define __Something\n")
|
2011-05-18 18:38:58 +02:00
|
|
|
<< (QStringList() << QLatin1String("arm-unknown-unknown-unknown-32bit"));
|
2013-11-04 13:07:20 +01:00
|
|
|
QTest::newRow("totally broken input -- 32bit")
|
2011-03-10 14:44:49 +01:00
|
|
|
<< QString::fromLatin1("foo-bar-foo")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 4\n#define __Something\n")
|
2011-03-10 14:44:49 +01:00
|
|
|
<< (QStringList());
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2013-02-20 12:23:45 +01:00
|
|
|
QTest::newRow("Linux 1 (32bit intel)")
|
2011-02-01 18:36:00 +01:00
|
|
|
<< QString::fromLatin1("i686-linux-gnu")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
|
2011-03-10 14:44:49 +01:00
|
|
|
<< (QStringList() << QLatin1String("x86-linux-generic-elf-32bit"));
|
2013-02-20 12:23:45 +01:00
|
|
|
QTest::newRow("Linux 2 (32bit intel)")
|
2011-02-01 18:36:00 +01:00
|
|
|
<< QString::fromLatin1("i486-linux-gnu")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
|
2011-03-10 14:44:49 +01:00
|
|
|
<< (QStringList() << QLatin1String("x86-linux-generic-elf-32bit"));
|
2013-02-20 12:23:45 +01:00
|
|
|
QTest::newRow("Linux 3 (64bit intel)")
|
2011-02-01 18:36:00 +01:00
|
|
|
<< QString::fromLatin1("x86_64-linux-gnu")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 8\n")
|
2011-03-10 14:44:49 +01:00
|
|
|
<< (QStringList() << QLatin1String("x86-linux-generic-elf-64bit")
|
|
|
|
|
<< QLatin1String("x86-linux-generic-elf-32bit"));
|
2013-02-20 12:23:45 +01:00
|
|
|
QTest::newRow("Linux 3 (64bit intel -- non 64bit)")
|
|
|
|
|
<< QString::fromLatin1("x86_64-linux-gnu")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
|
2013-02-20 12:23:45 +01:00
|
|
|
<< (QStringList() << QLatin1String("x86-linux-generic-elf-32bit"));
|
|
|
|
|
QTest::newRow("Linux 4 (32bit mips)")
|
2011-04-06 10:04:57 +02:00
|
|
|
<< QString::fromLatin1("mipsel-linux-uclibc")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 4")
|
2011-04-06 10:04:57 +02:00
|
|
|
<< (QStringList() << QLatin1String("mips-linux-generic-elf-32bit"));
|
2013-02-20 12:23:45 +01:00
|
|
|
QTest::newRow("Linux 5 (QTCREATORBUG-4690)") // from QTCREATORBUG-4690
|
2011-05-03 14:40:20 +02:00
|
|
|
<< QString::fromLatin1("x86_64-redhat-linux6E")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 8\n")
|
2011-05-03 14:40:20 +02:00
|
|
|
<< (QStringList() << QLatin1String("x86-linux-generic-elf-64bit")
|
|
|
|
|
<< QLatin1String("x86-linux-generic-elf-32bit"));
|
2013-02-20 12:23:45 +01:00
|
|
|
QTest::newRow("Linux 6 (QTCREATORBUG-4690)") // from QTCREATORBUG-4690
|
2011-05-03 14:40:20 +02:00
|
|
|
<< QString::fromLatin1("x86_64-redhat-linux")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 8\n")
|
2011-05-03 14:40:20 +02:00
|
|
|
<< (QStringList() << QLatin1String("x86-linux-generic-elf-64bit")
|
|
|
|
|
<< QLatin1String("x86-linux-generic-elf-32bit"));
|
2013-02-20 12:23:45 +01:00
|
|
|
QTest::newRow("Linux 7 (arm)")
|
2011-07-01 13:39:54 +02:00
|
|
|
<< QString::fromLatin1("armv5tl-montavista-linux-gnueabi")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
|
2011-07-01 13:39:54 +02:00
|
|
|
<< (QStringList() << QLatin1String("arm-linux-generic-elf-32bit"));
|
2013-02-20 12:23:45 +01:00
|
|
|
QTest::newRow("Linux 8 (arm)")
|
2011-08-31 15:24:24 +00:00
|
|
|
<< QString::fromLatin1("arm-angstrom-linux-gnueabi")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
|
2011-08-31 15:24:24 +00:00
|
|
|
<< (QStringList() << QLatin1String("arm-linux-generic-elf-32bit"));
|
2013-03-15 16:36:48 +01:00
|
|
|
QTest::newRow("Linux 9 (ppc)")
|
|
|
|
|
<< QString::fromLatin1("powerpc-nsg-linux")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
|
2013-03-15 16:36:48 +01:00
|
|
|
<< (QStringList() << QLatin1String("ppc-linux-generic-elf-32bit"));
|
|
|
|
|
QTest::newRow("Linux 10 (ppc 64bit)")
|
|
|
|
|
<< QString::fromLatin1("powerpc64-suse-linux")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 8\n")
|
2013-03-15 16:36:48 +01:00
|
|
|
<< (QStringList() << QLatin1String("ppc-linux-generic-elf-64bit"));
|
2011-07-01 13:39:54 +02:00
|
|
|
|
2013-02-20 12:23:45 +01:00
|
|
|
QTest::newRow("Mingw 1 (32bit)")
|
|
|
|
|
<< QString::fromLatin1("i686-w64-mingw32")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 4\r\n")
|
2013-02-20 12:23:45 +01:00
|
|
|
<< (QStringList() << QLatin1String("x86-windows-msys-pe-32bit"));
|
|
|
|
|
QTest::newRow("Mingw 2 (64bit)")
|
2011-02-01 18:36:00 +01:00
|
|
|
<< QString::fromLatin1("i686-w64-mingw32")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 8\r\n")
|
2011-03-10 14:44:49 +01:00
|
|
|
<< (QStringList() << QLatin1String("x86-windows-msys-pe-64bit")
|
|
|
|
|
<< QLatin1String("x86-windows-msys-pe-32bit"));
|
2013-02-20 12:23:45 +01:00
|
|
|
QTest::newRow("Mingw 3 (32 bit)")
|
2011-02-01 18:36:00 +01:00
|
|
|
<< QString::fromLatin1("mingw32")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 4\r\n")
|
2011-03-10 14:44:49 +01:00
|
|
|
<< (QStringList() << QLatin1String("x86-windows-msys-pe-32bit"));
|
2013-02-20 12:23:45 +01:00
|
|
|
QTest::newRow("Cross Mingw 1 (64bit)")
|
2012-02-01 17:09:59 +01:00
|
|
|
<< QString::fromLatin1("amd64-mingw32msvc")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 8\r\n")
|
2012-02-01 17:09:59 +01:00
|
|
|
<< (QStringList() << QLatin1String("x86-windows-msys-pe-64bit")
|
|
|
|
|
<< QLatin1String("x86-windows-msys-pe-32bit"));
|
2013-02-20 12:23:45 +01:00
|
|
|
QTest::newRow("Cross Mingw 2 (32bit)")
|
2012-02-01 17:09:59 +01:00
|
|
|
<< QString::fromLatin1("i586-mingw32msvc")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 4\r\n")
|
2012-02-01 17:09:59 +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")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 8\r\n")
|
2011-05-13 11:48:34 +02:00
|
|
|
<< (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")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 8\n")
|
2011-05-13 11:48:34 +02:00
|
|
|
<< (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")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 8\n")
|
2016-07-25 18:39:16 -07:00
|
|
|
<< (QStringList() << QLatin1String("x86-darwin-generic-mach_o-64bit")
|
|
|
|
|
<< QLatin1String("x86-darwin-generic-mach_o-32bit"));
|
2011-03-11 12:01:39 +01:00
|
|
|
QTest::newRow("Mac 2")
|
|
|
|
|
<< QString::fromLatin1("powerpc-apple-darwin10")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 8\n")
|
2016-07-25 18:39:16 -07:00
|
|
|
<< (QStringList() << QLatin1String("ppc-darwin-generic-mach_o-64bit")
|
|
|
|
|
<< QLatin1String("ppc-darwin-generic-mach_o-32bit"));
|
2011-03-11 12:01:39 +01:00
|
|
|
QTest::newRow("Mac 3")
|
|
|
|
|
<< QString::fromLatin1("i686-apple-darwin9")
|
2013-11-04 15:18:26 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
|
2016-07-25 18:39:16 -07:00
|
|
|
<< (QStringList() << QLatin1String("x86-darwin-generic-mach_o-32bit")
|
|
|
|
|
<< QLatin1String("x86-darwin-generic-mach_o-64bit"));
|
2011-04-08 16:33:59 +02:00
|
|
|
QTest::newRow("Mac IOS")
|
|
|
|
|
<< QString::fromLatin1("arm-apple-darwin9")
|
2013-11-04 15:18:26 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
|
2016-07-25 18:39:16 -07:00
|
|
|
<< (QStringList() << QLatin1String("arm-darwin-generic-mach_o-32bit")
|
|
|
|
|
<< QLatin1String("arm-darwin-generic-mach_o-64bit"));
|
2011-02-01 18:36:00 +01:00
|
|
|
QTest::newRow("Intel 1")
|
|
|
|
|
<< QString::fromLatin1("86_64 x86_64 GNU/Linux")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 8\n")
|
2011-03-10 14:44:49 +01:00
|
|
|
<< (QStringList() << QLatin1String("x86-linux-generic-elf-64bit")
|
|
|
|
|
<< QLatin1String("x86-linux-generic-elf-32bit"));
|
2011-05-31 10:06:32 +00:00
|
|
|
QTest::newRow("FreeBSD 1")
|
|
|
|
|
<< QString::fromLatin1("i386-portbld-freebsd9.0")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
|
2011-05-31 10:06:32 +00:00
|
|
|
<< (QStringList() << QLatin1String("x86-bsd-freebsd-elf-32bit"));
|
|
|
|
|
QTest::newRow("FreeBSD 2")
|
|
|
|
|
<< QString::fromLatin1("i386-undermydesk-freebsd")
|
2013-11-04 13:07:20 +01:00
|
|
|
<< QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
|
2011-05-31 10:06:32 +00:00
|
|
|
<< (QStringList() << QLatin1String("x86-bsd-freebsd-elf-32bit"));
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProjectExplorerPlugin::testGccAbiGuessing()
|
|
|
|
|
{
|
|
|
|
|
QFETCH(QString, input);
|
2013-02-20 12:23:45 +01:00
|
|
|
QFETCH(QByteArray, macros);
|
2011-03-10 14:44:49 +01:00
|
|
|
QFETCH(QStringList, abiList);
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2013-02-20 12:23:45 +01:00
|
|
|
QList<Abi> al = guessGccAbi(input, macros);
|
2011-03-10 14:44:49 +01:00
|
|
|
QCOMPARE(al.count(), abiList.count());
|
2013-03-15 16:36:48 +01:00
|
|
|
for (int i = 0; i < al.count(); ++i)
|
2011-03-10 14:44:49 +01:00
|
|
|
QCOMPARE(al.at(i).toString(), abiList.at(i));
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace ProjectExplorer
|
|
|
|
|
|
|
|
|
|
#endif
|