forked from qt-creator/qt-creator
Motivation:
a) It was ridiculous that when users wanted to manually
add a new toolchain, they had to do the entire setup twice.
b) It was equally weird that users had to take care to choose
matching toolchains when setting up a kit, or indeed that it was
even possible to mix random toolchains in the first place.
User-visible changes:
- The "C" and "C++" categories in the toolchain settings page have
been merged into a single "C/C++" category.
- When adding a new toolchain, the "C" and "C++" sub-menus are gone.
Instead, the toolchain config widget offers two path choosers if
the respective toolchain type supports C and C++ compilers.
- By default, the C++ compiler file path is derived from the C
compiler file path automatically, so the user usually has
to enter only the former.
- In the kit settings page, the "C" and "C++" toolchain combo boxes
have been replaced by a single "C/C++" combo box, relieving the user
of the responsibility to choose two matching toolchains.
Implementation:
The notion that a Toolchain object corresponds to a single compiler is so
deeply engrained in the code that it cannot realistically be changed in
the short term. We therefore introduce the concept of a "toolchain
bundle" as an additional layer that groups matching C and C++ toolchains
together. This way, most code dealing with toolchains stays unchanged,
and only the presentation layer (i.e. the toolchain and kit settings
pages) needed to be rewritten. Once set up in a bundle, toolchains stay
implicitly linked together so the matching only needs to be done once.
In follow-up patches, we will make use of toolchain bundles in all the
places where kits are auto-created, eliminating the risk of mixing
incompatible toolchains in a kit.
Change-Id: Ie6c5add9963e7c1096268dd77acd624671b2674f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
78 lines
1.9 KiB
C++
78 lines
1.9 KiB
C++
// Copyright (C) 2016 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
|
|
#pragma once
|
|
|
|
#include "projectexplorer_export.h"
|
|
|
|
#include "toolchain.h"
|
|
|
|
#include <QScrollArea>
|
|
|
|
#include <utility>
|
|
|
|
namespace Utils { class PathChooser; }
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
class QCheckBox;
|
|
class QFormLayout;
|
|
class QLineEdit;
|
|
class QLabel;
|
|
QT_END_NAMESPACE
|
|
|
|
namespace ProjectExplorer {
|
|
|
|
// --------------------------------------------------------------------------
|
|
// ToolChainConfigWidget
|
|
// --------------------------------------------------------------------------
|
|
|
|
class PROJECTEXPLORER_EXPORT ToolchainConfigWidget : public QScrollArea
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit ToolchainConfigWidget(const ToolchainBundle &bundle);
|
|
|
|
ToolchainBundle bundle() const { return m_bundle; }
|
|
|
|
void apply();
|
|
void discard();
|
|
bool isDirty() const;
|
|
void makeReadOnly();
|
|
|
|
signals:
|
|
void compilerCommandChanged(Utils::Id language);
|
|
void dirty();
|
|
|
|
protected:
|
|
void setErrorMessage(const QString &);
|
|
void clearErrorMessage();
|
|
|
|
virtual void applyImpl() = 0;
|
|
virtual void discardImpl() = 0;
|
|
virtual bool isDirtyImpl() const = 0;
|
|
virtual void makeReadOnlyImpl() = 0;
|
|
|
|
void addErrorLabel();
|
|
static QStringList splitString(const QString &s);
|
|
Utils::FilePath compilerCommand(Utils::Id language);
|
|
bool hasAnyCompiler() const;
|
|
void setCommandVersionArguments(const QStringList &args);
|
|
void deriveCxxCompilerCommand();
|
|
|
|
QFormLayout *m_mainLayout;
|
|
|
|
private:
|
|
using ToolchainChooser = std::pair<const Toolchain *, Utils::PathChooser *>;
|
|
ToolchainChooser compilerPathChooser(Utils::Id language);
|
|
void setupCompilerPathChoosers();
|
|
|
|
ToolchainBundle m_bundle;
|
|
QLineEdit *m_nameLineEdit = nullptr;
|
|
QLabel *m_errorLabel = nullptr;
|
|
QCheckBox *m_deriveCxxCompilerCheckBox = nullptr;
|
|
QList<ToolchainChooser> m_commands;
|
|
};
|
|
|
|
} // namespace ProjectExplorer
|