1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** Licensees holding valid Qt Commercial licenses may use this file in
12 ** accordance with the Qt Commercial License Agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and Nokia.
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** If you are unsure which license is appropriate for your use, please
26 ** contact the sales department at http://qt.nokia.com/contact.
28 **************************************************************************/
33 #include "projectconfiguration.h"
34 #include "projectexplorer_export.h"
37 #include <QtCore/QFutureInterface>
38 #include <QtGui/QWidget>
40 namespace ProjectExplorer {
42 class BuildConfiguration;
45 // BuildSteps are the primary way plugin developers can customize
46 // how their projects (or projects from other plugins) are build.
48 // Building a project, is done by taking the list of buildsteps
49 // from the project and calling first init() than run() on them.
51 // That means to change the way your project is build, reimplemnt
52 // this class and add your Step to the buildStep list of the project.
54 // Note: The projects own the buildstep, do not delete them yourself.
56 // init() is called in the GUI thread and can be used to query the
57 // project for any information you need.
59 // run() is run via QtConccurrent in a own thread, if you need an
60 // eventloop you need to create it yourself!
64 class BuildStepConfigWidget;
66 class PROJECTEXPLORER_EXPORT BuildStep : public ProjectConfiguration
71 BuildStep(BuildConfiguration *bc, const QString &id);
72 BuildStep(BuildConfiguration *bc, BuildStep *bs);
85 // This function is run in the gui thread,
86 // use it to retrieve any information that you need in run()
87 virtual bool init() = 0;
89 // Reimplement this. This function is called when the target is build.
90 // This function is NOT run in the gui thread. It runs in its own thread
91 // If you need an event loop, you need to create one.
92 // The absolute minimal implementation is:
93 // fi.reportResult(true);
94 virtual void run(QFutureInterface<bool> &fi) = 0;
96 // the Widget shown in the target settings dialog for this buildStep
97 // ownership is transferred to the caller
98 virtual BuildStepConfigWidget *createConfigWidget() = 0;
100 // if this function returns true, the user can't delete this BuildStep for this target
101 // and the user is prevented from changing the order immutable steps are run
102 // the default implementation returns false
103 virtual bool immutable() const;
105 BuildConfiguration *buildConfiguration() const;
109 void addTask(const ProjectExplorer::Task &task);
110 // The string is added to the generated output, usually in the output
112 // It should be in plain text, with the format in the parameter
113 void addOutput(const QString &string, const QTextCharFormat &textCharFormat);
116 BuildConfiguration *m_buildConfiguration;
119 class PROJECTEXPLORER_EXPORT IBuildStepFactory :
125 explicit IBuildStepFactory(QObject *parent = 0);
126 virtual ~IBuildStepFactory();
128 // used to show the list of possible additons to a target, returns a list of types
129 virtual QStringList availableCreationIds(BuildConfiguration *parent, BuildStep::Type type) const = 0;
130 // used to translate the types to names to display to the user
131 virtual QString displayNameForId(const QString &id) const = 0;
133 virtual bool canCreate(BuildConfiguration *parent, BuildStep::Type type, const QString &id) const = 0;
134 virtual BuildStep *create(BuildConfiguration *parent, BuildStep::Type type, const QString &id) = 0;
135 // used to recreate the runConfigurations when restoring settings
136 virtual bool canRestore(BuildConfiguration *parent, BuildStep::Type type, const QVariantMap &map) const = 0;
137 virtual BuildStep *restore(BuildConfiguration *parent, BuildStep::Type type, const QVariantMap &map) = 0;
138 virtual bool canClone(BuildConfiguration *parent, BuildStep::Type type, BuildStep *product) const = 0;
139 virtual BuildStep *clone(BuildConfiguration *parent, BuildStep::Type type, BuildStep *product) = 0;
142 class PROJECTEXPLORER_EXPORT BuildConfigWidget
151 virtual QString displayName() const = 0;
153 // This is called to set up the config widget before showing it
154 virtual void init(BuildConfiguration *bc) = 0;
157 class PROJECTEXPLORER_EXPORT BuildStepConfigWidget
162 BuildStepConfigWidget()
165 virtual void init() = 0;
166 virtual QString summaryText() const = 0;
167 virtual QString displayName() const = 0;
169 void updateSummary();
172 } // namespace ProjectExplorer
174 #endif // BUILDSTEP_H