2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-03-20 14:57:12 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2009-03-20 14:57:12 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-03-20 14:57:12 +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.
|
2009-03-20 14:57:12 +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.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2009-03-20 14:57:12 +01:00
|
|
|
|
2016-02-02 18:26:51 +01:00
|
|
|
#pragma once
|
2009-02-10 15:34:25 +01:00
|
|
|
|
2009-09-29 11:39:55 +02:00
|
|
|
#include "projectexplorer_export.h"
|
2016-01-18 11:56:54 +01:00
|
|
|
#include "projectexplorer_global.h"
|
2018-09-13 12:19:07 +02:00
|
|
|
|
2019-05-27 11:04:18 +02:00
|
|
|
#include "abi.h"
|
2018-09-13 12:19:07 +02:00
|
|
|
#include "headerpath.h"
|
2017-02-07 15:00:38 +01:00
|
|
|
#include "projectmacro.h"
|
2019-05-27 16:09:44 +02:00
|
|
|
#include "task.h"
|
2019-05-09 11:24:54 +02:00
|
|
|
#include "toolchaincache.h"
|
2016-01-18 11:56:54 +01:00
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
#include <coreplugin/id.h>
|
2011-11-25 13:19:58 +01:00
|
|
|
|
2019-01-09 18:31:20 +01:00
|
|
|
#include <utils/cpplanguage_details.h>
|
2015-11-03 14:01:25 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QObject>
|
2016-07-12 10:22:09 +02:00
|
|
|
#include <QSet>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QString>
|
|
|
|
|
#include <QVariantMap>
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2017-02-06 16:59:53 +01:00
|
|
|
#include <functional>
|
2018-07-16 13:59:39 +02:00
|
|
|
#include <memory>
|
2017-02-06 16:59:53 +01:00
|
|
|
|
2015-11-03 14:01:25 +01:00
|
|
|
namespace Utils { class Environment; }
|
2009-02-10 15:34:25 +01:00
|
|
|
|
|
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
|
2014-02-11 21:55:42 +02:00
|
|
|
namespace Internal { class ToolChainPrivate; }
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2016-12-16 00:43:14 +01:00
|
|
|
namespace Deprecated {
|
2017-03-01 11:19:15 +01:00
|
|
|
// Deprecated in 4.3:
|
2016-12-16 00:43:14 +01:00
|
|
|
namespace Toolchain {
|
|
|
|
|
enum Language {
|
|
|
|
|
None = 0,
|
|
|
|
|
C,
|
|
|
|
|
Cxx
|
|
|
|
|
};
|
|
|
|
|
QString languageId(Language l);
|
|
|
|
|
} // namespace Toolchain
|
|
|
|
|
} // namespace Deprecated
|
|
|
|
|
|
2011-02-28 16:50:14 +01:00
|
|
|
class Abi;
|
2009-12-09 13:54:46 +01:00
|
|
|
class IOutputParser;
|
2011-02-01 18:36:00 +01:00
|
|
|
class ToolChainConfigWidget;
|
|
|
|
|
class ToolChainFactory;
|
2013-03-21 12:27:18 +01:00
|
|
|
class Kit;
|
2009-02-10 15:34:25 +01:00
|
|
|
|
2018-03-07 17:34:09 +01:00
|
|
|
namespace Internal { class ToolChainSettingsAccessor; }
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
// --------------------------------------------------------------------------
|
2011-04-14 12:58:14 +02:00
|
|
|
// ToolChain (documentation inside)
|
2011-02-01 18:36:00 +01:00
|
|
|
// --------------------------------------------------------------------------
|
2009-02-10 15:34:25 +01:00
|
|
|
|
|
|
|
|
class PROJECTEXPLORER_EXPORT ToolChain
|
|
|
|
|
{
|
|
|
|
|
public:
|
2013-09-03 10:58:59 +02:00
|
|
|
enum Detection {
|
|
|
|
|
ManualDetection,
|
|
|
|
|
AutoDetection,
|
2019-04-08 17:36:39 +02:00
|
|
|
AutoDetectionFromSdk,
|
2019-05-08 19:03:15 +02:00
|
|
|
UninitializedDetection,
|
2013-09-03 10:58:59 +02:00
|
|
|
};
|
|
|
|
|
|
2017-01-11 16:12:32 +01:00
|
|
|
using Predicate = std::function<bool(const ToolChain *)>;
|
|
|
|
|
|
2009-02-10 15:34:25 +01:00
|
|
|
virtual ~ToolChain();
|
2010-01-29 21:33:57 +01:00
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
QString displayName() const;
|
2011-03-24 13:27:26 +01:00
|
|
|
void setDisplayName(const QString &name);
|
2009-06-18 15:16:18 +02:00
|
|
|
|
2013-09-03 10:58:59 +02:00
|
|
|
inline bool isAutoDetected() const { return detection() != ManualDetection; }
|
|
|
|
|
Detection detection() const;
|
|
|
|
|
|
2015-07-07 12:01:22 +02:00
|
|
|
QByteArray id() const;
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2019-05-27 14:22:15 +02:00
|
|
|
virtual QStringList suggestedMkspecList() const;
|
2012-09-05 09:21:15 +02:00
|
|
|
virtual Utils::FileName suggestedDebugger() const;
|
2009-02-10 15:34:25 +01:00
|
|
|
|
2015-07-09 11:34:37 +02:00
|
|
|
Core::Id typeId() const;
|
2012-01-30 11:55:21 +01:00
|
|
|
virtual QString typeDisplayName() const = 0;
|
2011-02-01 18:36:00 +01:00
|
|
|
virtual Abi targetAbi() const = 0;
|
2019-05-27 11:04:18 +02:00
|
|
|
virtual ProjectExplorer::Abis supportedAbis() const;
|
2016-03-04 15:33:16 +01:00
|
|
|
virtual QString originalTargetTriple() const { return QString(); }
|
2017-12-15 15:28:13 +01:00
|
|
|
virtual QStringList extraCodeModelFlags() const { return QStringList(); }
|
2009-12-09 13:54:46 +01:00
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
virtual bool isValid() const = 0;
|
2009-12-09 13:54:46 +01:00
|
|
|
|
2019-01-09 18:31:20 +01:00
|
|
|
virtual Utils::LanguageExtensions languageExtensions(const QStringList &cxxflags) const = 0;
|
2013-03-03 21:53:38 +04:00
|
|
|
virtual WarningFlags warningFlags(const QStringList &cflags) const = 0;
|
2019-01-07 12:15:40 +01:00
|
|
|
virtual QString sysRoot() const;
|
2017-02-06 16:59:53 +01:00
|
|
|
|
2018-09-27 10:18:44 +02:00
|
|
|
class MacroInspectionReport
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Macros macros;
|
2019-01-09 18:31:20 +01:00
|
|
|
Utils::LanguageVersion languageVersion;
|
2018-09-27 10:18:44 +02:00
|
|
|
};
|
|
|
|
|
|
2019-05-09 11:24:54 +02:00
|
|
|
using MacrosCache = std::shared_ptr<Cache<ToolChain::MacroInspectionReport, 64>>;
|
|
|
|
|
using HeaderPathsCache = std::shared_ptr<Cache<HeaderPaths>>;
|
|
|
|
|
|
2018-09-27 10:18:44 +02:00
|
|
|
// A MacroInspectionRunner is created in the ui thread and runs in another thread.
|
|
|
|
|
using MacroInspectionRunner = std::function<MacroInspectionReport(const QStringList &cxxflags)>;
|
|
|
|
|
virtual MacroInspectionRunner createMacroInspectionRunner() const = 0;
|
2017-02-07 15:00:38 +01:00
|
|
|
virtual Macros predefinedMacros(const QStringList &cxxflags) const = 0;
|
2017-02-06 16:59:53 +01:00
|
|
|
|
2018-09-17 11:29:32 +02:00
|
|
|
// A BuiltInHeaderPathsRunner is created in the ui thread and runs in another thread.
|
2019-04-25 16:06:39 +02:00
|
|
|
using BuiltInHeaderPathsRunner = std::function<HeaderPaths(
|
|
|
|
|
const QStringList &cxxflags, const QString &sysRoot, const QString &originalTargetTriple)>;
|
2018-09-17 11:29:32 +02:00
|
|
|
virtual BuiltInHeaderPathsRunner createBuiltInHeaderPathsRunner() const = 0;
|
|
|
|
|
virtual HeaderPaths builtInHeaderPaths(const QStringList &cxxflags,
|
2019-04-25 16:06:39 +02:00
|
|
|
const Utils::FileName &sysRoot) const = 0;
|
2011-02-01 18:36:00 +01:00
|
|
|
virtual void addToEnvironment(Utils::Environment &env) const = 0;
|
2019-05-15 10:45:36 +02:00
|
|
|
virtual Utils::FileName makeCommand(const Utils::Environment &env) const = 0;
|
2011-02-22 17:32:22 +01:00
|
|
|
|
2016-12-16 00:43:14 +01:00
|
|
|
Core::Id language() const;
|
2016-07-12 10:22:09 +02:00
|
|
|
|
2012-01-30 13:07:51 +01:00
|
|
|
virtual Utils::FileName compilerCommand() const = 0;
|
2011-02-01 18:36:00 +01:00
|
|
|
virtual IOutputParser *outputParser() const = 0;
|
2009-02-10 15:34:25 +01:00
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
virtual bool operator ==(const ToolChain &) const;
|
2010-04-09 18:43:05 +02:00
|
|
|
|
2018-07-11 08:25:07 +02:00
|
|
|
virtual std::unique_ptr<ToolChainConfigWidget> createConfigurationWidget() = 0;
|
2019-05-13 16:18:25 +02:00
|
|
|
ToolChain *clone() const;
|
2010-04-09 18:43:05 +02:00
|
|
|
|
2011-03-16 17:59:43 +01:00
|
|
|
// Used by the toolchainmanager to save user-generated tool chains.
|
2013-10-07 13:34:40 +02:00
|
|
|
// Make sure to call this function when deriving!
|
2011-02-01 18:36:00 +01:00
|
|
|
virtual QVariantMap toMap() const;
|
2019-05-27 16:09:44 +02:00
|
|
|
virtual Tasks validateKit(const Kit *k) const;
|
2016-02-02 18:26:51 +01:00
|
|
|
|
2019-03-06 07:34:56 +02:00
|
|
|
virtual bool isJobCountSupported() const { return true; }
|
|
|
|
|
|
2016-12-16 00:43:14 +01:00
|
|
|
void setLanguage(Core::Id language);
|
2019-05-08 19:03:15 +02:00
|
|
|
void setDetection(Detection d);
|
|
|
|
|
|
2019-01-09 18:31:20 +01:00
|
|
|
static Utils::LanguageVersion cxxLanguageVersion(const QByteArray &cplusplusMacroValue);
|
|
|
|
|
static Utils::LanguageVersion languageVersion(const Core::Id &language, const Macros ¯os);
|
2016-07-12 10:22:09 +02:00
|
|
|
|
2009-02-10 15:34:25 +01:00
|
|
|
protected:
|
2019-05-08 19:03:15 +02:00
|
|
|
explicit ToolChain(Core::Id typeId);
|
2010-03-04 15:23:02 +01:00
|
|
|
|
2019-05-09 11:24:54 +02:00
|
|
|
const MacrosCache &predefinedMacrosCache() const;
|
|
|
|
|
const HeaderPathsCache &headerPathsCache() const;
|
|
|
|
|
|
2017-10-30 10:12:32 +01:00
|
|
|
virtual void toolChainUpdated();
|
2011-03-24 13:27:26 +01:00
|
|
|
|
2013-10-07 13:34:40 +02:00
|
|
|
// Make sure to call this function when deriving!
|
2011-02-01 18:36:00 +01:00
|
|
|
virtual bool fromMap(const QVariantMap &data);
|
2009-12-09 13:54:46 +01:00
|
|
|
|
2009-02-10 15:34:25 +01:00
|
|
|
private:
|
2019-05-13 16:18:25 +02:00
|
|
|
ToolChain(const ToolChain &) = delete;
|
|
|
|
|
ToolChain &operator=(const ToolChain &) = delete;
|
|
|
|
|
|
2018-07-16 13:59:39 +02:00
|
|
|
const std::unique_ptr<Internal::ToolChainPrivate> d;
|
2010-03-04 15:23:02 +01:00
|
|
|
|
2018-03-07 17:34:09 +01:00
|
|
|
friend class Internal::ToolChainSettingsAccessor;
|
2011-02-01 18:36:00 +01:00
|
|
|
friend class ToolChainFactory;
|
2009-02-10 15:34:25 +01:00
|
|
|
};
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
class PROJECTEXPLORER_EXPORT ToolChainFactory : public QObject
|
2009-02-10 15:34:25 +01:00
|
|
|
{
|
2011-02-01 18:36:00 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
2009-02-10 15:34:25 +01:00
|
|
|
public:
|
2017-12-08 17:20:48 +01:00
|
|
|
ToolChainFactory();
|
2018-05-07 14:58:16 +02:00
|
|
|
~ToolChainFactory() override;
|
2017-12-08 17:20:48 +01:00
|
|
|
|
|
|
|
|
static const QList<ToolChainFactory *> allToolChainFactories();
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
QString displayName() const { return m_displayName; }
|
2019-05-08 14:56:26 +02:00
|
|
|
Core::Id supportedToolChainType() const;
|
2010-03-04 15:23:02 +01:00
|
|
|
|
2015-07-19 10:59:06 +03:00
|
|
|
virtual QList<ToolChain *> autoDetect(const QList<ToolChain *> &alreadyKnown);
|
2017-02-07 13:13:06 +01:00
|
|
|
virtual QList<ToolChain *> autoDetect(const Utils::FileName &compilerPath, const Core::Id &language);
|
2009-12-09 13:54:46 +01:00
|
|
|
|
2019-05-10 18:22:58 +02:00
|
|
|
virtual bool canCreate() const;
|
2019-05-08 17:45:02 +02:00
|
|
|
virtual ToolChain *create();
|
2009-12-09 13:54:46 +01:00
|
|
|
|
2019-05-13 14:25:59 +02:00
|
|
|
ToolChain *restore(const QVariantMap &data);
|
2009-02-10 15:34:25 +01:00
|
|
|
|
2015-07-07 12:01:22 +02:00
|
|
|
static QByteArray idFromMap(const QVariantMap &data);
|
2015-07-07 14:20:12 +02:00
|
|
|
static Core::Id typeIdFromMap(const QVariantMap &data);
|
2012-06-20 15:45:37 +02:00
|
|
|
static void autoDetectionToMap(QVariantMap &data, bool detected);
|
2013-08-09 17:49:30 +02:00
|
|
|
|
2019-05-08 15:36:57 +02:00
|
|
|
QSet<Core::Id> supportedLanguages() const;
|
2016-07-12 11:33:17 +02:00
|
|
|
|
2019-05-10 18:22:58 +02:00
|
|
|
void setUserCreatable(bool userCreatable);
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
protected:
|
|
|
|
|
void setDisplayName(const QString &name) { m_displayName = name; }
|
2019-05-08 14:56:26 +02:00
|
|
|
void setSupportedToolChainType(const Core::Id &supportedToolChainType);
|
2019-05-08 15:36:57 +02:00
|
|
|
void setSupportedLanguages(const QSet<Core::Id> &supportedLanguages);
|
|
|
|
|
void setSupportsAllLanguages(bool supportsAllLanguages);
|
2019-05-10 17:35:04 +02:00
|
|
|
void setToolchainConstructor(const std::function<ToolChain *()> &constructor);
|
2013-08-09 17:49:30 +02:00
|
|
|
|
2019-05-08 22:54:01 +03:00
|
|
|
class Candidate {
|
|
|
|
|
public:
|
|
|
|
|
Utils::FileName compilerPath;
|
|
|
|
|
QString compilerVersion;
|
|
|
|
|
|
|
|
|
|
bool operator==(const ToolChainFactory::Candidate &other) const {
|
|
|
|
|
return compilerPath == other.compilerPath
|
|
|
|
|
&& compilerVersion == other.compilerVersion;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
using Candidates = QVector<Candidate>;
|
|
|
|
|
|
2013-08-09 17:49:30 +02:00
|
|
|
private:
|
|
|
|
|
QString m_displayName;
|
2019-05-08 14:56:26 +02:00
|
|
|
Core::Id m_supportedToolChainType;
|
2019-05-08 15:36:57 +02:00
|
|
|
QSet<Core::Id> m_supportedLanguages;
|
|
|
|
|
bool m_supportsAllLanguages = false;
|
2019-05-10 18:22:58 +02:00
|
|
|
bool m_userCreatable = false;
|
2019-05-10 17:35:04 +02:00
|
|
|
std::function<ToolChain *()> m_toolchainConstructor;
|
2011-02-01 18:36:00 +01:00
|
|
|
};
|
2009-02-10 15:34:25 +01:00
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
} // namespace ProjectExplorer
|