1 /****************************************************************************
2 **
3 ** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of Qt Creator.
7 **
8 ** Commercial License Usage
9 ** Licensees holding valid commercial Qt licenses may use this file in
10 ** accordance with the commercial license agreement provided with the
11 ** Software or, alternatively, in accordance with the terms contained in
12 ** a written agreement between you and The Qt Company. For licensing terms
13 ** and conditions see https://www.qt.io/terms-conditions. For further
14 ** information use the contact form at https://www.qt.io/contact-us.
15 **
16 ** GNU General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU
18 ** General Public License version 3 as published by the Free Software
19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
20 ** included in the packaging of this file. Please review the following
21 ** information to ensure the GNU General Public License requirements will
22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
23 **
24 ****************************************************************************/
25 
26 #pragma once
27 
28 #include <projectexplorer/abi.h>
29 #include <projectexplorer/toolchain.h>
30 #include <projectexplorer/toolchainconfigwidget.h>
31 
32 QT_BEGIN_NAMESPACE
33 class QLineEdit;
34 class QPlainTextEdit;
35 class QPushButton;
36 class QTextEdit;
37 QT_END_NAMESPACE
38 
39 namespace Utils {
40 class FilePath;
41 class PathChooser;
42 }
43 
44 namespace ProjectExplorer { class AbiWidget; }
45 
46 namespace BareMetal {
47 namespace Internal {
48 
49 // IarToolChain
50 
51 class IarToolChain final : public ProjectExplorer::ToolChain
52 {
53     Q_DECLARE_TR_FUNCTIONS(IarToolChain)
54 
55 public:
56     MacroInspectionRunner createMacroInspectionRunner() const final;
57 
58     Utils::LanguageExtensions languageExtensions(const QStringList &cxxflags) const final;
59     Utils::WarningFlags warningFlags(const QStringList &cxxflags) const final;
60 
61     BuiltInHeaderPathsRunner createBuiltInHeaderPathsRunner(const Utils::Environment &) const final;
62     void addToEnvironment(Utils::Environment &env) const final;
63     QList<Utils::OutputLineParser *> createOutputParsers() const final;
64 
65     QVariantMap toMap() const final;
66     bool fromMap(const QVariantMap &data) final;
67 
68     std::unique_ptr<ProjectExplorer::ToolChainConfigWidget> createConfigurationWidget() final;
69 
70     bool operator ==(const ToolChain &other) const final;
71 
72     void setExtraCodeModelFlags(const QStringList &flags);
73     QStringList extraCodeModelFlags() const final;
74 
75     Utils::FilePath makeCommand(const Utils::Environment &env) const final;
76 
77 private:
78     IarToolChain();
79 
80     QStringList m_extraCodeModelFlags;
81 
82     friend class IarToolChainFactory;
83     friend class IarToolChainConfigWidget;
84 };
85 
86 // IarToolChainFactory
87 
88 class IarToolChainFactory final : public ProjectExplorer::ToolChainFactory
89 {
90 public:
91     IarToolChainFactory();
92 
93     QList<ProjectExplorer::ToolChain *> autoDetect(
94             const QList<ProjectExplorer::ToolChain *> &alreadyKnown,
95             const ProjectExplorer::IDevice::Ptr &device) final;
96 
97 private:
98     QList<ProjectExplorer::ToolChain *> autoDetectToolchains(const Candidates &candidates,
99             const QList<ProjectExplorer::ToolChain *> &alreadyKnown) const;
100     QList<ProjectExplorer::ToolChain *> autoDetectToolchain(
101             const Candidate &candidate, Utils::Id languageId) const;
102 };
103 
104 // IarToolChainConfigWidget
105 
106 class IarToolChainConfigWidget final : public ProjectExplorer::ToolChainConfigWidget
107 {
108     Q_OBJECT
109 
110 public:
111     explicit IarToolChainConfigWidget(IarToolChain *tc);
112 
113 private:
114     void applyImpl() final;
discardImpl()115     void discardImpl() final { setFromToolchain(); }
116     bool isDirtyImpl() const final;
117     void makeReadOnlyImpl() final;
118 
119     void setFromToolchain();
120     void handleCompilerCommandChange();
121     void handlePlatformCodeGenFlagsChange();
122 
123     Utils::PathChooser *m_compilerCommand = nullptr;
124     ProjectExplorer::AbiWidget *m_abiWidget = nullptr;
125     QLineEdit *m_platformCodeGenFlagsLineEdit = nullptr;
126     ProjectExplorer::Macros m_macros;
127 };
128 
129 } // namespace Internal
130 } // namespace BareMetal
131