qt4buildconfiguration.h 7.23 KB
Newer Older
dt's avatar
dt committed
1
2
3
4
/**************************************************************************
**
** This file is part of Qt Creator
**
con's avatar
con committed
5
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
dt's avatar
dt committed
6
**
hjk's avatar
hjk committed
7
** Contact: Nokia Corporation (info@qt.nokia.com)
dt's avatar
dt committed
8
9
10
11
**
**
** GNU Lesser General Public License Usage
**
hjk's avatar
hjk committed
12
13
14
15
16
17
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
dt's avatar
dt committed
18
**
con's avatar
con committed
19
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
con's avatar
con committed
21
22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
23
24
25
26
27
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
con's avatar
con committed
28
29
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
dt's avatar
dt committed
30
31
32
33
34
35
**
**************************************************************************/

#ifndef QT4BUILDCONFIGURATION_H
#define QT4BUILDCONFIGURATION_H

36
#include "qt4projectmanager_global.h"
37
38
#include "qtversionmanager.h"

dt's avatar
dt committed
39
#include <projectexplorer/buildconfiguration.h>
40
41
42
43

namespace ProjectExplorer {
class ToolChain;
}
dt's avatar
dt committed
44
45

namespace Qt4ProjectManager {
46

47
48
class QMakeStep;
class MakeStep;
49
class Qt4BaseTarget;
50

dt's avatar
dt committed
51
namespace Internal {
52
class Qt4ProFileNode;
53
class Qt4BuildConfigurationFactory;
54
}
55

56
class QT4PROJECTMANAGER_EXPORT Qt4BuildConfiguration : public ProjectExplorer::BuildConfiguration
dt's avatar
dt committed
57
{
58
    Q_OBJECT
59
    friend class Internal::Qt4BuildConfigurationFactory;
60

dt's avatar
dt committed
61
public:
62
    explicit Qt4BuildConfiguration(Qt4BaseTarget *target);
63
    virtual ~Qt4BuildConfiguration();
64

65
    Qt4BaseTarget *qt4Target() const;
dt's avatar
dt committed
66

67
    virtual Utils::Environment baseEnvironment() const;
68
69

    virtual QString buildDirectory() const;
70
71
    bool shadowBuild() const;
    QString shadowBuildDirectory() const;
72
    void setShadowBuildAndDirectory(bool shadowBuild, const QString &buildDirectory);
73

74
75
76
    void setSubNodeBuild(Qt4ProjectManager::Internal::Qt4ProFileNode *node);
    Qt4ProjectManager::Internal::Qt4ProFileNode *subNodeBuild() const;

Tobias Hunger's avatar
Tobias Hunger committed
77
    // returns the qtVersion
78
    QtVersion *qtVersion() const;
Tobias Hunger's avatar
Tobias Hunger committed
79
    void setQtVersion(QtVersion *);
80

81
    void setToolChain(ProjectExplorer::ToolChain *tc);
82

83
84
    QtVersion::QmakeBuildConfigs qmakeBuildConfiguration() const;
    void setQMakeBuildConfiguration(QtVersion::QmakeBuildConfigs config);
85
86
87

    /// \internal for qmakestep
    void emitProFileEvaluteNeeded();
88
    // used by qmake step to notify that the qmake args have changed
dt's avatar
dt committed
89
90
    // not really nice, the build configuration should save the arguments
    // since they are needed for reevaluation
91
    void emitQMakeBuildConfigurationChanged();
92
93
94
    // used by qmake step to notify that the build directory was initialized
    // not really nice
    void emitBuildDirectoryInitialized();
95
96
97
98
    // used by S60CreatePackageStep to notify that the smart installer property changed
    // not really nice
    void emitS60CreatesSmartInstallerChanged();

99
    QStringList configCommandLineArguments() const;
100
101

    // Those functions are used in a few places.
Tobias Hunger's avatar
Tobias Hunger committed
102
103
    // The drawback is that we shouldn't actually depend on them being always there
    // That is generally the stuff that is asked should normally be transferred to
104
105
106
107
108
109
110
    // Qt4Project *
    // So that we can later enable people to build qt4projects the way they would like
    QMakeStep *qmakeStep() const;
    MakeStep *makeStep() const;

    QString makeCommand() const;
    QString defaultMakeTarget() const;
111
    QString makefile() const;
112

113
    bool compareToImportFrom(const QString &makefile);
114
115
116
117
    static void removeQMLInspectorFromArguments(QString *args);
    static QString extractSpecFromArguments(QString *arguments,
                                            const QString &directory, const QtVersion *version,
                                            QStringList *outArgs = 0);
118

119
    QVariantMap toMap() const;
120

121
122
    ProjectExplorer::IOutputParser *createOutputParser() const;

123
124
125
126
    virtual bool isEnabled() const;
    /// \internal For Qt4Project, since that manages the parsing information
    void setEnabled(bool enabled);

127
128
    BuildType buildType() const;

129
130
131
public slots:
    void importFromBuildDirectory();

132
signals:
133
134
    /// emitted if the qt version changes (either directly, or because the default qt version changed
    /// or because the user changed the settings for the qt version
135
    void qtVersionChanged();
136
137
138
    /// emitted for setQMakeBuildConfig, not emitted for qt version changes, even
    /// if those change the qmakebuildconfig
    void qmakeBuildConfigurationChanged();
139
140
    /// emitted when smart installer property of S60 create package step changes
    void s60CreatesSmartInstallerChanged();
141

dt's avatar
dt committed
142
143
    /// emitted if the build configuration changed in a way that
    /// should trigger a reevaluation of all .pro files
144
    void proFileEvaluateNeeded(Qt4ProjectManager::Qt4BuildConfiguration *);
145

146
147
    void buildDirectoryInitialized();

148
149
private slots:
    void qtVersionsChanged(const QList<int> &changedVersions);
150
    void emitBuildDirectoryChanged();
151
152

protected:
153
154
    Qt4BuildConfiguration(Qt4BaseTarget *target, Qt4BuildConfiguration *source);
    Qt4BuildConfiguration(Qt4BaseTarget *target, const QString &id);
155
156
    virtual bool fromMap(const QVariantMap &map);

157
private:
158
    void ctor();
Tobias Hunger's avatar
Tobias Hunger committed
159
    void pickValidQtVersion();
160
    QString rawBuildDirectory() const;
Tobias Hunger's avatar
Tobias Hunger committed
161

dt's avatar
dt committed
162
    bool m_shadowBuild;
163
    bool m_isEnabled;
dt's avatar
dt committed
164
    QString m_buildDirectory;
165
    QString m_lastEmmitedBuildDirectory;
Tobias Hunger's avatar
Tobias Hunger committed
166
    int m_qtVersionId;
dt's avatar
dt committed
167
    QtVersion::QmakeBuildConfigs m_qmakeBuildConfiguration;
168
    Qt4ProjectManager::Internal::Qt4ProFileNode *m_subNodeBuild;
dt's avatar
dt committed
169
170
};

171
namespace Internal {
172
class QT4PROJECTMANAGER_EXPORT Qt4BuildConfigurationFactory : public ProjectExplorer::IBuildConfigurationFactory
173
174
175
176
{
    Q_OBJECT

public:
177
    explicit Qt4BuildConfigurationFactory(QObject *parent = 0);
178
179
    ~Qt4BuildConfigurationFactory();

Tobias Hunger's avatar
Tobias Hunger committed
180
    QStringList availableCreationIds(ProjectExplorer::Target *parent) const;
181
182
    QString displayNameForId(const QString &id) const;

Tobias Hunger's avatar
Tobias Hunger committed
183
184
185
186
187
188
    bool canCreate(ProjectExplorer::Target *parent, const QString &id) const;
    ProjectExplorer::BuildConfiguration *create(ProjectExplorer::Target *parent, const QString &id);
    bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source) const;
    ProjectExplorer::BuildConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source);
    bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
    ProjectExplorer::BuildConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map);
189
190
191
192
193
194

private slots:
    void update();

private:
    struct VersionInfo {
dt's avatar
dt committed
195
196
197
        VersionInfo()
            : versionId(-1)
            {}
198
        VersionInfo(const QString &d, int v)
dt's avatar
dt committed
199
200
            : displayName(d), versionId(v)
            {}
201
202
203
204
205
206
207
        QString displayName;
        int versionId;
    };

    QMap<QString, VersionInfo> m_versions;
};

dt's avatar
dt committed
208
} // namespace Internal
209
} // namespace Qt4ProjectManager
dt's avatar
dt committed
210
211

#endif // QT4BUILDCONFIGURATION_H