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;
47 // BuildSteps are the primary way plugin developers can customize
48 // how their projects (or projects from other plugins) are build.
50 // Building a project, is done by taking the list of buildsteps
51 // from the project and calling first init() than run() on them.
53 // That means to change the way your project is build, reimplemnt
54 // this class and add your Step to the buildStep list of the project.
56 // Note: The projects own the buildstep, do not delete them yourself.
58 // init() is called in the GUI thread and can be used to query the
59 // project for any information you need.
61 // run() is run via QtConccurrent in a own thread, if you need an
62 // eventloop you need to create it yourself!
66 class BuildStepConfigWidget;
68 class PROJECTEXPLORER_EXPORT BuildStep : public ProjectConfiguration
73 BuildStep(BuildStepList *bsl, const QString &id);
74 BuildStep(BuildStepList *bsl, BuildStep *bs);
79 // This function is run in the gui thread,
80 // use it to retrieve any information that you need in run()
81 virtual bool init() = 0;
83 // Reimplement this. This function is called when the target is build.
84 // This function is NOT run in the gui thread. It runs in its own thread
85 // If you need an event loop, you need to create one.
86 // The absolute minimal implementation is:
87 // fi.reportResult(true);
88 virtual void run(QFutureInterface<bool> &fi) = 0;
90 // the Widget shown in the target settings dialog for this buildStep
91 // ownership is transferred to the caller
92 virtual BuildStepConfigWidget *createConfigWidget() = 0;
94 // if this function returns true, the user can't delete this BuildStep for this target
95 // and the user is prevented from changing the order immutable steps are run
96 // the default implementation returns false
97 virtual bool immutable() const;
99 BuildConfiguration *buildConfiguration() const;
100 Target *target() const;
102 enum OutputFormat { NormalOutput, ErrorOutput, MessageOutput, ErrorMessageOutput };
106 void addTask(const ProjectExplorer::Task &task);
107 // The string is added to the generated output, usually in the output
109 // It should be in plain text, with the format in the parameter
110 void addOutput(const QString &string, ProjectExplorer::BuildStep::OutputFormat format);
113 class PROJECTEXPLORER_EXPORT IBuildStepFactory :
119 explicit IBuildStepFactory(QObject *parent = 0);
120 virtual ~IBuildStepFactory();
122 // used to show the list of possible additons to a target, returns a list of types
123 virtual QStringList availableCreationIds(BuildStepList *parent) const = 0;
124 // used to translate the types to names to display to the user
125 virtual QString displayNameForId(const QString &id) const = 0;
127 virtual bool canCreate(BuildStepList *parent, const QString &id) const = 0;
128 virtual BuildStep *create(BuildStepList *parent, const QString &id) = 0;
129 // used to recreate the runConfigurations when restoring settings
130 virtual bool canRestore(BuildStepList *parent, const QVariantMap &map) const = 0;
131 virtual BuildStep *restore(BuildStepList *parent, const QVariantMap &map) = 0;
132 virtual bool canClone(BuildStepList *parent, BuildStep *product) const = 0;
133 virtual BuildStep *clone(BuildStepList *parent, BuildStep *product) = 0;
136 class PROJECTEXPLORER_EXPORT BuildConfigWidget
145 virtual QString displayName() const = 0;
147 // This is called to set up the config widget before showing it
148 virtual void init(BuildConfiguration *bc) = 0;
151 void displayNameChanged(const QString &);
154 class PROJECTEXPLORER_EXPORT BuildStepConfigWidget
159 BuildStepConfigWidget()
162 virtual void init() = 0;
163 virtual QString summaryText() const = 0;
164 virtual QString displayName() const = 0;
166 void updateSummary();
169 } // namespace ProjectExplorer
171 Q_DECLARE_METATYPE(ProjectExplorer::BuildStep::OutputFormat)
173 #endif // BUILDSTEP_H