qmakestep.h 7.76 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
Eike Ziller's avatar
Eike Ziller committed
3 4
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
con's avatar
con committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
con's avatar
con committed
7
**
hjk's avatar
hjk committed
8 9 10 11
** 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
Eike Ziller's avatar
Eike Ziller committed
12 13
** a written agreement between you and The Qt Company.  For licensing terms and
** conditions see http://www.qt.io/terms-conditions.  For further information
Eike Ziller's avatar
Eike Ziller committed
14
** use the contact form at http://www.qt.io/contact-us.
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
** Alternatively, this file may be used under the terms of the GNU Lesser
Eike Ziller's avatar
Eike Ziller committed
18 19 20 21 22 23
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file.  Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
hjk's avatar
hjk committed
24
**
Eike Ziller's avatar
Eike Ziller committed
25 26
** In addition, as a special exception, The Qt Company gives you certain additional
** rights.  These rights are described in The Qt Company LGPL Exception
con's avatar
con committed
27 28
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
29
****************************************************************************/
hjk's avatar
hjk committed
30

con's avatar
con committed
31 32 33
#ifndef QMAKESTEP_H
#define QMAKESTEP_H

34
#include "qmakeprojectmanager_global.h"
35 36
#include <projectexplorer/abstractprocessstep.h>

37
#include <QStringList>
38

Robert Loehning's avatar
Robert Loehning committed
39 40
#include <tuple>

41 42
namespace Utils { class FileName; }

dt's avatar
dt committed
43
namespace ProjectExplorer {
44
class Abi;
dt's avatar
dt committed
45 46 47
class BuildStep;
class IBuildStepFactory;
class Project;
48
class Kit;
dt's avatar
dt committed
49
}
con's avatar
con committed
50

51 52
namespace QtSupport { class BaseQtVersion; }

53
namespace QmakeProjectManager {
54
class QmakeBuildConfiguration;
55
class QmakeProject;
dt's avatar
dt committed
56

dt's avatar
dt committed
57
namespace Internal {
dt's avatar
dt committed
58

hjk's avatar
hjk committed
59 60
namespace Ui { class QMakeStep; }

dt's avatar
dt committed
61 62 63
class QMakeStepFactory : public ProjectExplorer::IBuildStepFactory
{
    Q_OBJECT
64

dt's avatar
dt committed
65
public:
66
    explicit QMakeStepFactory(QObject *parent = 0);
dt's avatar
dt committed
67
    virtual ~QMakeStepFactory();
68 69
    bool canCreate(ProjectExplorer::BuildStepList *parent, Core::Id id) const;
    ProjectExplorer::BuildStep *create(ProjectExplorer::BuildStepList *parent, Core::Id id);
Tobias Hunger's avatar
Tobias Hunger committed
70 71 72 73
    bool canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *bs) const;
    ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *bs);
    bool canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const;
    ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map);
74
    QList<Core::Id> availableCreationIds(ProjectExplorer::BuildStepList *parent) const;
75
    QString displayNameForId(Core::Id id) const;
dt's avatar
dt committed
76 77
};

dt's avatar
dt committed
78 79
} // namespace Internal

80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
class QMAKEPROJECTMANAGER_EXPORT QMakeStepConfig
{
public:
    enum TargetArchConfig {
        NoArch, X86, X86_64, PPC, PPC64
    };

    enum OsType {
        NoOsType, IphoneSimulator, IphoneOS
    };

    static TargetArchConfig targetArchFor(const ProjectExplorer::Abi &targetAbi, const QtSupport::BaseQtVersion *version);
    static OsType osTypeFor(const ProjectExplorer::Abi &targetAbi, const QtSupport::BaseQtVersion *version);

    QStringList toArguments() const;

    // Actual data
97 98 99 100 101
    TargetArchConfig archConfig = NoArch;
    OsType osType = NoOsType;
    bool linkQmlDebuggingQQ2 = false;
    bool useQtQuickCompiler = false;
    bool separateDebugInfo = false;
102 103 104 105
};


inline bool operator ==(const QMakeStepConfig &a, const QMakeStepConfig &b) {
106 107
    return std::tie(a.archConfig, a.osType, a.linkQmlDebuggingQQ2)
               == std::tie(b.archConfig, b.osType, b.linkQmlDebuggingQQ2)
Daniel Teske's avatar
Daniel Teske committed
108 109
            && std::tie(a.useQtQuickCompiler, a.separateDebugInfo)
               == std::tie(b.useQtQuickCompiler, b.separateDebugInfo);
110 111 112 113 114 115 116 117
}

inline bool operator !=(const QMakeStepConfig &a, const QMakeStepConfig &b) {
    return !(a == b);
}

inline QDebug operator<<(QDebug dbg, const QMakeStepConfig &c)
{
118
   dbg << c.archConfig << c.osType << c.linkQmlDebuggingQQ2 << c.useQtQuickCompiler << c.separateDebugInfo;
119 120
   return dbg;
}
con's avatar
con committed
121

122
class QMAKEPROJECTMANAGER_EXPORT QMakeStep : public ProjectExplorer::AbstractProcessStep
con's avatar
con committed
123 124
{
    Q_OBJECT
125 126
    friend class Internal::QMakeStepFactory;

127 128 129 130 131 132
    enum QmlLibraryLink {
        DoNotLink = 0,
        DoLink,
        DebugLink
    };

133 134 135
    // used in DebuggerRunConfigurationAspect
    Q_PROPERTY(bool linkQmlDebuggingLibrary READ linkQmlDebuggingLibrary WRITE setLinkQmlDebuggingLibrary NOTIFY linkQmlDebuggingLibraryChanged)

con's avatar
con committed
136
public:
Tobias Hunger's avatar
Tobias Hunger committed
137
    explicit QMakeStep(ProjectExplorer::BuildStepList *parent);
138 139
    virtual ~QMakeStep();

140
    QmakeBuildConfiguration *qmakeBuildConfiguration() const;
141
    virtual bool init();
con's avatar
con committed
142 143 144 145 146
    virtual void run(QFutureInterface<bool> &);
    virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
    virtual bool immutable() const;
    void setForced(bool b);
    bool forced();
147

148
    // the complete argument line
149
    QString allArguments(bool shorted = false);
150
    QMakeStepConfig deducedArguments();
151
    // arguments passed to the pro file parser
152
    QStringList parserArguments();
153
    // arguments set by the user
154
    QString userArguments();
155
    Utils::FileName mkspec();
156
    void setUserArguments(const QString &arguments);
157 158
    bool linkQmlDebuggingLibrary() const;
    void setLinkQmlDebuggingLibrary(bool enable);
159 160
    bool useQtQuickCompiler() const;
    void setUseQtQuickCompiler(bool enable);
161 162
    bool separateDebugInfo() const;
    void setSeparateDebugInfo(bool enable);
163

164
    QVariantMap toMap() const;
165

166
signals:
167
    void userArgumentsChanged();
168
    void linkQmlDebuggingLibraryChanged();
169
    void useQtQuickCompilerChanged();
170
    void separateDebugInfoChanged();
171

con's avatar
con committed
172
protected:
Tobias Hunger's avatar
Tobias Hunger committed
173
    QMakeStep(ProjectExplorer::BuildStepList *parent, QMakeStep *source);
174
    QMakeStep(ProjectExplorer::BuildStepList *parent, Core::Id id);
175 176
    virtual bool fromMap(const QVariantMap &map);

con's avatar
con committed
177
    virtual void processStartupFailed();
178
    virtual bool processSucceeded(int exitCode, QProcess::ExitStatus status);
con's avatar
con committed
179 180

private:
181 182
    void ctor();

con's avatar
con committed
183
    // last values
184 185
    bool m_forced = false;
    bool m_needToRunQMake = false; // set in init(), read in run()
186
    QString m_userArgs;
187 188 189 190
    QmlLibraryLink m_linkQmlDebuggingLibrary = DebugLink;
    bool m_useQtQuickCompiler = false;
    bool m_scriptTemplate = false;
    bool m_separateDebugInfo = false;
con's avatar
con committed
191 192 193 194 195 196 197 198
};


class QMakeStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget
{
    Q_OBJECT
public:
    QMakeStepConfigWidget(QMakeStep *step);
199
    ~QMakeStepConfigWidget();
dt's avatar
dt committed
200
    QString summaryText() const;
201
    QString additionalSummaryText() const;
202
    QString displayName() const;
con's avatar
con committed
203
private slots:
204
    // slots for handling buildconfiguration/step signals
205
    void qtVersionChanged();
206 207
    void qmakeBuildConfigChanged();
    void userArgumentsChanged();
208
    void linkQmlDebuggingLibraryChanged();
209
    void useQtQuickCompilerChanged();
210
    void separateDebugInfoChanged();
211 212 213 214

    // slots for dealing with user changes in our UI
    void qmakeArgumentsLineEdited();
    void buildConfigurationSelected();
215
    void linkQmlDebuggingLibraryChecked(bool checked);
216
    void useQtQuickCompilerChecked(bool checked);
217
    void separateDebugInfoChecked(bool checked);
218
    void askForRebuild();
219

220 221 222
private slots:
    void recompileMessageBoxFinished(int button);

con's avatar
con committed
223
private:
224
    void updateSummaryLabel();
225
    void updateQmlDebuggingOption();
226
    void updateQtQuickCompilerOption();
227
    void updateEffectiveQMakeCall();
228 229 230

    void setSummaryText(const QString &);

231 232
    Internal::Ui::QMakeStep *m_ui = nullptr;
    QMakeStep *m_step = nullptr;
dt's avatar
dt committed
233
    QString m_summaryText;
234
    QString m_additionalSummaryText;
235
    bool m_ignoreChange = false;
con's avatar
con committed
236 237
};

238
} // namespace QmakeProjectManager
con's avatar
con committed
239 240

#endif // QMAKESTEP_H