2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "buildstep.h"
|
2008-12-09 15:25:01 +01:00
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
#include "buildconfiguration.h"
|
|
|
|
|
#include "buildsteplist.h"
|
2011-02-21 17:38:12 +01:00
|
|
|
#include "deployconfiguration.h"
|
2010-07-16 14:00:41 +02:00
|
|
|
#include "target.h"
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::BuildStep
|
|
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The BuildStep class provides build steps for projects.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
Build steps are the primary way plugin developers can customize
|
|
|
|
|
how their projects (or projects from other plugins) are built.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
Projects are built by taking the list of build steps
|
|
|
|
|
from the project and calling first \c init() and then \c run() on them.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
To change the way your project is built, reimplement
|
|
|
|
|
this class and add your build step to the build step list of the project.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
\note The projects own the build step. Do not delete them yourself.
|
|
|
|
|
|
|
|
|
|
\c init() is called in the GUI thread and can be used to query the
|
2011-04-14 12:58:14 +02:00
|
|
|
project for any information you need.
|
|
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
\c run() is run via QtConcurrent in a separate thread. If you need an
|
|
|
|
|
event loop, you need to create it yourself.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn bool ProjectExplorer::BuildStep::init()
|
|
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
This function is run in the GUI thread. Use it to retrieve any information
|
|
|
|
|
that you need in the run() function.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn void ProjectExplorer::BuildStep::run(QFutureInterface<bool> &fi)
|
|
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
Reimplement this function. It is called when the target is built.
|
|
|
|
|
By default, this function is NOT run in the GUI thread, but runs in its
|
2011-07-07 15:15:43 +02:00
|
|
|
own thread. If you need an event loop, you need to create one.
|
|
|
|
|
This function should block until the task is done
|
2011-04-14 12:58:14 +02:00
|
|
|
|
|
|
|
|
The absolute minimal implementation is:
|
|
|
|
|
\code
|
|
|
|
|
fi.reportResult(true);
|
|
|
|
|
\endcode
|
2011-07-07 15:15:43 +02:00
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
By returning \c true from runInGuiThread(), this function is called in
|
|
|
|
|
the GUI thread. Then the function should not block and instead the
|
2011-07-07 15:15:43 +02:00
|
|
|
finished() signal should be emitted.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
\sa runInGuiThread()
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
2013-09-10 17:16:10 +02:00
|
|
|
\fn BuildStepConfigWidget *ProjectExplorer::BuildStep::createConfigWidget()
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
Returns the Widget shown in the target settings dialog for this build step.
|
|
|
|
|
Ownership is transferred to the caller.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn void ProjectExplorer::BuildStep::addTask(const ProjectExplorer::Task &task)
|
2013-09-10 17:16:10 +02:00
|
|
|
Adds \a task.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
2013-05-23 16:13:55 +02:00
|
|
|
\fn void ProjectExplorer::BuildStep::addOutput(const QString &string, ProjectExplorer::BuildStep::OutputFormat format,
|
|
|
|
|
ProjectExplorer::BuildStep::OutputNewlineSetting newlineSetting = DoAppendNewline) const
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
The \a string is added to the generated output, usually in the output pane.
|
2011-04-14 12:58:14 +02:00
|
|
|
It should be in plain text, with the format in the parameter.
|
|
|
|
|
*/
|
|
|
|
|
|
2011-07-07 15:15:43 +02:00
|
|
|
/*!
|
|
|
|
|
\fn void ProjectExplorer::BuildStep::finished()
|
2013-09-10 17:16:10 +02:00
|
|
|
This signal needs to be emitted if the build step runs in the GUI thread.
|
2011-07-07 15:15:43 +02:00
|
|
|
*/
|
|
|
|
|
|
2012-01-23 14:55:58 +01:00
|
|
|
static const char buildStepEnabledKey[] = "ProjectExplorer.BuildStep.Enabled";
|
|
|
|
|
|
2009-04-20 16:29:46 +02:00
|
|
|
using namespace ProjectExplorer;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
BuildStep::BuildStep(BuildStepList *bsl, Core::Id id) :
|
2012-01-23 14:55:58 +01:00
|
|
|
ProjectConfiguration(bsl, id), m_enabled(true)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
Q_ASSERT(bsl);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
BuildStep::BuildStep(BuildStepList *bsl, BuildStep *bs) :
|
2012-01-23 14:55:58 +01:00
|
|
|
ProjectConfiguration(bsl, bs), m_enabled(bs->m_enabled)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
Q_ASSERT(bsl);
|
2012-03-05 12:35:52 +01:00
|
|
|
setDisplayName(bs->displayName());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2012-01-23 14:55:58 +01:00
|
|
|
bool BuildStep::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
m_enabled = map.value(QLatin1String(buildStepEnabledKey), true).toBool();
|
|
|
|
|
return ProjectConfiguration::fromMap(map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap BuildStep::toMap() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map = ProjectConfiguration::toMap();
|
|
|
|
|
map.insert(QLatin1String(buildStepEnabledKey), m_enabled);
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
BuildConfiguration *BuildStep::buildConfiguration() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-10-21 13:06:26 +00:00
|
|
|
return qobject_cast<BuildConfiguration *>(parent()->parent());
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
|
2011-02-21 17:38:12 +01:00
|
|
|
DeployConfiguration *BuildStep::deployConfiguration() const
|
|
|
|
|
{
|
2011-10-21 13:06:26 +00:00
|
|
|
return qobject_cast<DeployConfiguration *>(parent()->parent());
|
2011-02-21 17:38:12 +01:00
|
|
|
}
|
|
|
|
|
|
2011-10-24 13:10:38 +00:00
|
|
|
ProjectConfiguration *BuildStep::projectConfiguration() const
|
|
|
|
|
{
|
|
|
|
|
return static_cast<ProjectConfiguration *>(parent()->parent());
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
Target *BuildStep::target() const
|
|
|
|
|
{
|
|
|
|
|
return qobject_cast<Target *>(parent()->parent()->parent());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-10-21 13:06:26 +00:00
|
|
|
Project *BuildStep::project() const
|
|
|
|
|
{
|
|
|
|
|
return target()->project();
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
/*!
|
|
|
|
|
If this function returns \c true, the user cannot delete this build step for
|
|
|
|
|
this target and the user is prevented from changing the order in which
|
|
|
|
|
immutable steps are run. The default implementation returns \c false.
|
|
|
|
|
*/
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
bool BuildStep::immutable() const
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-07 15:15:43 +02:00
|
|
|
bool BuildStep::runInGuiThread() const
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
/*!
|
|
|
|
|
This function needs to be reimplemented only for build steps that return
|
|
|
|
|
\c false from runInGuiThread().
|
|
|
|
|
|
|
|
|
|
\sa runInGuiThread()
|
|
|
|
|
*/
|
2011-07-07 15:15:43 +02:00
|
|
|
void BuildStep::cancel()
|
|
|
|
|
{
|
|
|
|
|
// Do nothing
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-23 14:55:58 +01:00
|
|
|
void BuildStep::setEnabled(bool b)
|
|
|
|
|
{
|
|
|
|
|
if (m_enabled == b)
|
|
|
|
|
return;
|
|
|
|
|
m_enabled = b;
|
|
|
|
|
emit enabledChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BuildStep::enabled() const
|
|
|
|
|
{
|
|
|
|
|
return m_enabled;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-14 17:41:29 +01:00
|
|
|
IBuildStepFactory::IBuildStepFactory(QObject *parent) :
|
|
|
|
|
QObject(parent)
|
2010-07-16 14:00:41 +02:00
|
|
|
{ }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
IBuildStepFactory::~IBuildStepFactory()
|
2010-07-16 14:00:41 +02:00
|
|
|
{ }
|