qmakestep.h 7.66 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
    // used in DebuggerRunConfigurationAspect
    Q_PROPERTY(bool linkQmlDebuggingLibrary READ linkQmlDebuggingLibrary WRITE setLinkQmlDebuggingLibrary NOTIFY linkQmlDebuggingLibraryChanged)

con's avatar
con committed
130
public:
Tobias Hunger's avatar
Tobias Hunger committed
131
    explicit QMakeStep(ProjectExplorer::BuildStepList *parent);
132 133
    virtual ~QMakeStep();

134
    QmakeBuildConfiguration *qmakeBuildConfiguration() const;
135
    virtual bool init();
con's avatar
con committed
136 137 138 139 140
    virtual void run(QFutureInterface<bool> &);
    virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
    virtual bool immutable() const;
    void setForced(bool b);
    bool forced();
141

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

158
    QVariantMap toMap() const;
159

160
signals:
161
    void userArgumentsChanged();
162
    void linkQmlDebuggingLibraryChanged();
163
    void useQtQuickCompilerChanged();
164
    void separateDebugInfoChanged();
165

con's avatar
con committed
166
protected:
Tobias Hunger's avatar
Tobias Hunger committed
167
    QMakeStep(ProjectExplorer::BuildStepList *parent, QMakeStep *source);
168
    QMakeStep(ProjectExplorer::BuildStepList *parent, Core::Id id);
169 170
    virtual bool fromMap(const QVariantMap &map);

con's avatar
con committed
171
    virtual void processStartupFailed();
172
    virtual bool processSucceeded(int exitCode, QProcess::ExitStatus status);
con's avatar
con committed
173 174

private:
175 176
    void ctor();

con's avatar
con committed
177
    // last values
178 179
    bool m_forced = false;
    bool m_needToRunQMake = false; // set in init(), read in run()
180
    QString m_userArgs;
181
    bool m_linkQmlDebuggingLibrary = false;
182 183 184
    bool m_useQtQuickCompiler = false;
    bool m_scriptTemplate = false;
    bool m_separateDebugInfo = false;
con's avatar
con committed
185 186 187 188 189 190 191 192
};


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

    // slots for dealing with user changes in our UI
    void qmakeArgumentsLineEdited();
    void buildConfigurationSelected();
209
    void linkQmlDebuggingLibraryChecked(bool checked);
210
    void useQtQuickCompilerChecked(bool checked);
211
    void separateDebugInfoChecked(bool checked);
212
    void askForRebuild();
213

214 215 216
private slots:
    void recompileMessageBoxFinished(int button);

con's avatar
con committed
217
private:
218
    void updateSummaryLabel();
219
    void updateQmlDebuggingOption();
220
    void updateQtQuickCompilerOption();
221
    void updateEffectiveQMakeCall();
222 223 224

    void setSummaryText(const QString &);

225 226
    Internal::Ui::QMakeStep *m_ui = nullptr;
    QMakeStep *m_step = nullptr;
dt's avatar
dt committed
227
    QString m_summaryText;
228
    QString m_additionalSummaryText;
229
    bool m_ignoreChange = false;
con's avatar
con committed
230 231
};

232
} // namespace QmakeProjectManager
con's avatar
con committed
233 234

#endif // QMAKESTEP_H