1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
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 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
37 #include "projectconfiguration.h"
38 #include "projectexplorer_export.h"
41 #include <QtCore/QFutureInterface>
42 #include <QtGui/QWidget>
44 namespace ProjectExplorer {
46 class BuildConfiguration;
51 // BuildSteps are the primary way plugin developers can customize
52 // how their projects (or projects from other plugins) are build.
54 // Building a project, is done by taking the list of buildsteps
55 // from the project and calling first init() than run() on them.
57 // That means to change the way your project is build, reimplemnt
58 // this class and add your Step to the buildStep list of the project.
60 // Note: The projects own the buildstep, do not delete them yourself.
62 // init() is called in the GUI thread and can be used to query the
63 // project for any information you need.
65 // run() is run via QtConccurrent in a own thread, if you need an
66 // eventloop you need to create it yourself!
70 class BuildStepConfigWidget;
72 class PROJECTEXPLORER_EXPORT BuildStep : public ProjectConfiguration
77 BuildStep(BuildStepList *bsl, const QString &id);
78 BuildStep(BuildStepList *bsl, BuildStep *bs);
83 // This function is run in the gui thread,
84 // use it to retrieve any information that you need in run()
85 virtual bool init() = 0;
87 // Reimplement this. This function is called when the target is build.
88 // This function is NOT run in the gui thread. It runs in its own thread
89 // If you need an event loop, you need to create one.
90 // The absolute minimal implementation is:
91 // fi.reportResult(true);
92 virtual void run(QFutureInterface<bool> &fi) = 0;
94 // the Widget shown in the target settings dialog for this buildStep
95 // ownership is transferred to the caller
96 virtual BuildStepConfigWidget *createConfigWidget() = 0;
98 // if this function returns true, the user can't delete this BuildStep for this target
99 // and the user is prevented from changing the order immutable steps are run
100 // the default implementation returns false
101 virtual bool immutable() const;
103 BuildConfiguration *buildConfiguration() const;
104 Target *target() const;
106 enum OutputFormat { NormalOutput, ErrorOutput, MessageOutput, ErrorMessageOutput };
110 void addTask(const ProjectExplorer::Task &task);
111 // The string is added to the generated output, usually in the output
113 // It should be in plain text, with the format in the parameter
114 void addOutput(const QString &string, ProjectExplorer::BuildStep::OutputFormat format);
117 class PROJECTEXPLORER_EXPORT IBuildStepFactory :
123 explicit IBuildStepFactory(QObject *parent = 0);
124 virtual ~IBuildStepFactory();
126 // used to show the list of possible additons to a target, returns a list of types
127 virtual QStringList availableCreationIds(BuildStepList *parent) const = 0;
128 // used to translate the types to names to display to the user
129 virtual QString displayNameForId(const QString &id) const = 0;
131 virtual bool canCreate(BuildStepList *parent, const QString &id) const = 0;
132 virtual BuildStep *create(BuildStepList *parent, const QString &id) = 0;
133 // used to recreate the runConfigurations when restoring settings
134 virtual bool canRestore(BuildStepList *parent, const QVariantMap &map) const = 0;
135 virtual BuildStep *restore(BuildStepList *parent, const QVariantMap &map) = 0;
136 virtual bool canClone(BuildStepList *parent, BuildStep *product) const = 0;
137 virtual BuildStep *clone(BuildStepList *parent, BuildStep *product) = 0;
140 class PROJECTEXPLORER_EXPORT BuildConfigWidget
149 virtual QString displayName() const = 0;
151 // This is called to set up the config widget before showing it
152 virtual void init(BuildConfiguration *bc) = 0;
155 void displayNameChanged(const QString &);
158 class PROJECTEXPLORER_EXPORT BuildStepConfigWidget
163 BuildStepConfigWidget()
166 virtual void init() = 0;
167 virtual QString summaryText() const = 0;
168 virtual QString displayName() const = 0;
170 void updateSummary();
173 } // namespace ProjectExplorer
175 Q_DECLARE_METATYPE(ProjectExplorer::BuildStep::OutputFormat)
177 #endif // BUILDSTEP_H