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"
35 #include "taskwindow.h"
37 #include <QtCore/QFutureInterface>
38 #include <QtGui/QWidget>
40 namespace ProjectExplorer {
41 class BuildConfiguration;
44 // BuildSteps are the primary way plugin developers can customize
45 // how their projects (or projects from other plugins) are build.
47 // Building a project, is done by taking the list of buildsteps
48 // from the project and calling first init() than run() on them.
50 // That means to change the way your project is build, reimplemnt
51 // this class and add your Step to the buildStep list of the project.
53 // Note: The projects own the buildstep, do not delete them yourself.
55 // init() is called in the GUI thread and can be used to query the
56 // project for any information you need.
58 // run() is run via QtConccurrent in a own thread, if you need an
59 // eventloop you need to create it yourself!
61 // You can use setValue() to store settings which a specific
62 // to your buildstep. (You can set settings to apply only
63 // to one buildconfiguration.
64 // And later retrieve the same information with value()
68 class BuildStepConfigWidget;
70 class PROJECTEXPLORER_EXPORT BuildStep : public ProjectConfiguration
75 BuildStep(BuildConfiguration *bc, const QString &id);
76 BuildStep(BuildConfiguration *bc, BuildStep *bs);
81 // This function is run in the gui thread,
82 // use it to retrieve any information that you need in run()
83 virtual bool init() = 0;
85 // Reimplement this. This function is called when the target is build.
86 // This function is NOT run in the gui thread. It runs in its own thread
87 // If you need an event loop, you need to create one.
88 // The absolute minimal implementation is:
89 // fi.reportResult(true);
90 virtual void run(QFutureInterface<bool> &fi) = 0;
92 // the Widget shown in the target settings dialog for this buildStep
93 // ownership is transferred to the caller
94 virtual BuildStepConfigWidget *createConfigWidget() = 0;
96 // if this function returns true, the user can't delete this BuildStep for this target
97 // and the user is prevented from changing the order immutable steps are run
98 // the default implementation returns false
99 virtual bool immutable() const;
101 BuildConfiguration *buildConfiguration() const;
105 void addTask(const ProjectExplorer::TaskWindow::Task &task);
106 // The string is added to the generated output, usually in the output
108 // It should be in html format, that is properly escaped
109 void addOutput(const QString &string);
112 BuildConfiguration *m_buildConfiguration;
115 class PROJECTEXPLORER_EXPORT IBuildStepFactory :
121 explicit IBuildStepFactory(QObject *parent = 0);
122 virtual ~IBuildStepFactory();
124 // used to show the list of possible additons to a target, returns a list of types
125 virtual QStringList availableCreationIds(BuildConfiguration *parent) const = 0;
126 // used to translate the types to names to display to the user
127 virtual QString displayNameForId(const QString &id) const = 0;
129 virtual bool canCreate(BuildConfiguration *parent, const QString &id) const = 0;
130 virtual BuildStep *create(BuildConfiguration *parent, const QString &id) = 0;
131 // used to recreate the runConfigurations when restoring settings
132 virtual bool canRestore(BuildConfiguration *parent, const QVariantMap &map) const = 0;
133 virtual BuildStep *restore(BuildConfiguration *parent, const QVariantMap &map) = 0;
134 virtual bool canClone(BuildConfiguration *parent, BuildStep *product) const = 0;
135 virtual BuildStep *clone(BuildConfiguration *parent, BuildStep *product) = 0;
138 class PROJECTEXPLORER_EXPORT BuildConfigWidget
147 virtual QString displayName() const = 0;
149 // This is called to set up the config widget before showing it
150 virtual void init(BuildConfiguration *bc) = 0;
153 class PROJECTEXPLORER_EXPORT BuildStepConfigWidget
158 BuildStepConfigWidget()
161 virtual void init() = 0;
162 virtual QString summaryText() const = 0;
163 virtual QString displayName() const = 0;
165 void updateSummary();
168 } // namespace ProjectExplorer
170 #endif // BUILDSTEP_H