2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-04 13:06:02 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-04 13:06:02 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-04 13:06:02 +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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-04 13:06:02 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-01-14 17:41:29 +01:00
|
|
|
|
2016-01-07 12:33:52 +01:00
|
|
|
#include "cmakebuildstep.h"
|
2010-01-14 17:41:29 +01:00
|
|
|
|
2013-07-10 21:43:49 +03:00
|
|
|
#include "cmakebuildconfiguration.h"
|
2019-10-25 09:55:32 +02:00
|
|
|
#include "cmakebuildsystem.h"
|
2016-01-07 13:15:29 +01:00
|
|
|
#include "cmakekitinformation.h"
|
2013-07-10 21:43:49 +03:00
|
|
|
#include "cmakeparser.h"
|
2008-12-04 13:06:02 +01:00
|
|
|
#include "cmakeprojectconstants.h"
|
2016-01-07 13:15:29 +01:00
|
|
|
#include "cmaketool.h"
|
2008-12-04 13:06:02 +01:00
|
|
|
|
2020-09-24 13:03:25 +03:00
|
|
|
#include <android/androidconstants.h>
|
2020-04-17 15:30:05 +02:00
|
|
|
#include <coreplugin/find/itemviewfind.h>
|
2010-07-16 14:00:41 +02:00
|
|
|
#include <projectexplorer/buildsteplist.h>
|
2016-02-12 12:34:35 +01:00
|
|
|
#include <projectexplorer/gnumakeparser.h>
|
2020-09-24 13:03:25 +03:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2018-11-17 21:19:04 +02:00
|
|
|
#include <projectexplorer/processparameters.h>
|
2020-04-17 15:30:05 +02:00
|
|
|
#include <projectexplorer/project.h>
|
2013-07-10 21:43:49 +03:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
2020-04-17 15:30:05 +02:00
|
|
|
#include <projectexplorer/runconfiguration.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2020-09-24 13:03:25 +03:00
|
|
|
#include <qtsupport/baseqtversion.h>
|
|
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2020-06-02 19:37:25 +02:00
|
|
|
#include <utils/algorithm.h>
|
2020-09-18 12:11:40 +02:00
|
|
|
#include <utils/layoutbuilder.h>
|
2020-06-02 19:37:25 +02:00
|
|
|
|
2020-04-17 15:30:05 +02:00
|
|
|
#include <QBoxLayout>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QListWidget>
|
2020-07-30 13:16:43 +02:00
|
|
|
#include <QRegularExpression>
|
2020-09-10 17:01:32 +02:00
|
|
|
#include <QTreeView>
|
2008-12-09 15:25:01 +01:00
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
using namespace Core;
|
2009-10-27 14:16:28 +01:00
|
|
|
using namespace ProjectExplorer;
|
2020-08-13 16:48:44 +02:00
|
|
|
using namespace Utils;
|
2008-12-04 13:06:02 +01:00
|
|
|
|
2020-02-20 18:04:36 +01:00
|
|
|
namespace CMakeProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2012-08-03 15:24:33 +02:00
|
|
|
const char BUILD_TARGETS_KEY[] = "CMakeProjectManager.MakeStep.BuildTargets";
|
2020-06-02 17:23:47 +02:00
|
|
|
const char CMAKE_ARGUMENTS_KEY[] = "CMakeProjectManager.MakeStep.CMakeArguments";
|
2016-01-07 13:15:29 +01:00
|
|
|
const char TOOL_ARGUMENTS_KEY[] = "CMakeProjectManager.MakeStep.AdditionalArguments";
|
2020-09-10 17:01:32 +02:00
|
|
|
|
|
|
|
|
// CmakeProgressParser
|
2020-02-20 18:04:36 +01:00
|
|
|
|
2020-07-30 13:16:43 +02:00
|
|
|
class CmakeProgressParser : public Utils::OutputLineParser
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void progress(int percentage);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Result handleLine(const QString &line, Utils::OutputFormat format) override
|
|
|
|
|
{
|
|
|
|
|
if (format != Utils::StdOutFormat)
|
|
|
|
|
return Status::NotHandled;
|
|
|
|
|
|
|
|
|
|
static const QRegularExpression percentProgress("^\\[\\s*(\\d*)%\\]");
|
|
|
|
|
static const QRegularExpression ninjaProgress("^\\[\\s*(\\d*)/\\s*(\\d*)");
|
|
|
|
|
|
|
|
|
|
QRegularExpressionMatch match = percentProgress.match(line);
|
|
|
|
|
if (match.hasMatch()) {
|
|
|
|
|
bool ok = false;
|
|
|
|
|
const int percent = match.captured(1).toInt(&ok);
|
|
|
|
|
if (ok)
|
|
|
|
|
emit progress(percent);
|
|
|
|
|
return Status::Done;
|
|
|
|
|
}
|
|
|
|
|
match = ninjaProgress.match(line);
|
|
|
|
|
if (match.hasMatch()) {
|
|
|
|
|
m_useNinja = true;
|
|
|
|
|
bool ok = false;
|
|
|
|
|
const int done = match.captured(1).toInt(&ok);
|
|
|
|
|
if (ok) {
|
|
|
|
|
const int all = match.captured(2).toInt(&ok);
|
|
|
|
|
if (ok && all != 0) {
|
|
|
|
|
const int percent = static_cast<int>(100.0 * done / all);
|
|
|
|
|
emit progress(percent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Status::Done;
|
|
|
|
|
}
|
|
|
|
|
return Status::NotHandled;
|
|
|
|
|
}
|
|
|
|
|
bool hasDetectedRedirection() const override { return m_useNinja; }
|
|
|
|
|
|
|
|
|
|
// TODO: Shouldn't we know the backend in advance? Then we could merge this class
|
|
|
|
|
// with CmakeParser.
|
|
|
|
|
bool m_useNinja = false;
|
|
|
|
|
};
|
|
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
|
|
|
|
|
// CmakeTargetItem
|
|
|
|
|
|
|
|
|
|
CMakeTargetItem::CMakeTargetItem(const QString &target, CMakeBuildStep *step, bool special)
|
|
|
|
|
: m_target(target), m_step(step), m_special(special)
|
2020-02-20 18:04:36 +01:00
|
|
|
{
|
2020-09-10 17:01:32 +02:00
|
|
|
}
|
2020-02-20 18:04:36 +01:00
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
QVariant CMakeTargetItem::data(int column, int role) const
|
|
|
|
|
{
|
|
|
|
|
if (column == 0) {
|
|
|
|
|
if (role == Qt::DisplayRole) {
|
|
|
|
|
if (m_target.isEmpty())
|
|
|
|
|
return CMakeBuildStep::tr("Current executable");
|
|
|
|
|
return m_target;
|
|
|
|
|
}
|
2020-02-20 18:04:36 +01:00
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
if (role == Qt::ToolTipRole) {
|
|
|
|
|
if (m_target.isEmpty()) {
|
|
|
|
|
return CMakeBuildStep::tr("Build the executable used in the active Run "
|
|
|
|
|
"configuration. Currently: %1")
|
|
|
|
|
.arg(m_step->activeRunConfigTarget());
|
|
|
|
|
}
|
|
|
|
|
return CMakeBuildStep::tr("Target: %1").arg(m_target);
|
|
|
|
|
}
|
2020-02-20 18:04:36 +01:00
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
if (role == Qt::CheckStateRole)
|
|
|
|
|
return m_step->buildsBuildTarget(m_target) ? Qt::Checked : Qt::Unchecked;
|
2010-01-14 17:41:29 +01:00
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
if (role == Qt::FontRole) {
|
|
|
|
|
if (m_special) {
|
|
|
|
|
QFont italics;
|
|
|
|
|
italics.setItalic(true);
|
|
|
|
|
return italics;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return QVariant();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CMakeTargetItem::setData(int column, const QVariant &data, int role)
|
2016-04-22 15:54:16 +02:00
|
|
|
{
|
2020-09-10 17:01:32 +02:00
|
|
|
if (column == 0 && role == Qt::CheckStateRole) {
|
|
|
|
|
m_step->setBuildsBuildTarget(m_target, data.value<Qt::CheckState>() == Qt::Checked);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return TreeItem::setData(column, data, role);
|
2016-04-22 15:54:16 +02:00
|
|
|
}
|
|
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
Qt::ItemFlags CMakeTargetItem::flags(int) const
|
|
|
|
|
{
|
|
|
|
|
return Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CMakeBuildStep
|
|
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
CMakeBuildStep::CMakeBuildStep(BuildStepList *bsl, Utils::Id id) :
|
2019-12-20 17:05:30 +01:00
|
|
|
AbstractProcessStep(bsl, id)
|
2010-01-14 17:41:29 +01:00
|
|
|
{
|
2020-09-08 14:53:15 +02:00
|
|
|
m_cmakeArguments = addAspect<StringAspect>();
|
|
|
|
|
m_cmakeArguments->setSettingsKey(CMAKE_ARGUMENTS_KEY);
|
|
|
|
|
m_cmakeArguments->setLabelText(tr("CMake arguments:"));
|
|
|
|
|
m_cmakeArguments->setDisplayStyle(StringAspect::LineEditDisplay);
|
|
|
|
|
|
|
|
|
|
m_toolArguments = addAspect<StringAspect>();
|
|
|
|
|
m_toolArguments->setSettingsKey(TOOL_ARGUMENTS_KEY);
|
|
|
|
|
m_toolArguments->setLabelText(tr("Tool arguments:"));
|
|
|
|
|
m_toolArguments->setDisplayStyle(StringAspect::LineEditDisplay);
|
|
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
m_buildTargetModel.setHeader({tr("Target")});
|
|
|
|
|
|
|
|
|
|
setBuildTargets({defaultBuildTarget()});
|
2017-04-26 15:34:04 +02:00
|
|
|
|
2019-10-09 21:29:12 +03:00
|
|
|
setLowPriority();
|
2019-09-10 23:39:29 +03:00
|
|
|
|
2020-09-14 17:17:55 +02:00
|
|
|
setCommandLineProvider([this] { return cmakeCommand(); });
|
|
|
|
|
|
2020-08-13 16:48:44 +02:00
|
|
|
setEnvironmentModifier([](Environment &env) {
|
|
|
|
|
const QString ninjaProgressString = "[%f/%t "; // ninja: [33/100
|
|
|
|
|
Environment::setupEnglishOutput(&env);
|
|
|
|
|
if (!env.expandedValueForKey("NINJA_STATUS").startsWith(ninjaProgressString))
|
|
|
|
|
env.set("NINJA_STATUS", ninjaProgressString + "%o/sec] ");
|
|
|
|
|
});
|
|
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
connect(target(), &Target::parsingFinished, this, [this](bool success) {
|
|
|
|
|
if (success) // Do not change when parsing failed.
|
|
|
|
|
recreateBuildTargetsModel();
|
2020-06-02 19:37:25 +02:00
|
|
|
});
|
2020-09-10 17:01:32 +02:00
|
|
|
|
|
|
|
|
connect(target(), &Target::activeRunConfigurationChanged,
|
|
|
|
|
this, &CMakeBuildStep::updateBuildTargetsModel);
|
2013-08-26 16:01:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
|
2016-01-07 12:33:52 +01:00
|
|
|
QVariantMap CMakeBuildStep::toMap() const
|
2009-10-15 19:06:51 +02:00
|
|
|
{
|
2010-01-14 17:41:29 +01:00
|
|
|
QVariantMap map(AbstractProcessStep::toMap());
|
2020-09-10 17:01:32 +02:00
|
|
|
map.insert(BUILD_TARGETS_KEY, m_buildTargets);
|
2010-01-14 17:41:29 +01:00
|
|
|
return map;
|
2009-10-15 19:06:51 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-07 12:33:52 +01:00
|
|
|
bool CMakeBuildStep::fromMap(const QVariantMap &map)
|
2009-10-15 19:06:51 +02:00
|
|
|
{
|
2020-09-10 17:01:32 +02:00
|
|
|
setBuildTargets(map.value(BUILD_TARGETS_KEY).toStringList());
|
2010-01-14 17:41:29 +01:00
|
|
|
return BuildStep::fromMap(map);
|
2009-10-15 19:06:51 +02:00
|
|
|
}
|
|
|
|
|
|
2019-01-10 15:31:44 +01:00
|
|
|
bool CMakeBuildStep::init()
|
2008-12-04 13:06:02 +01:00
|
|
|
{
|
2020-09-14 17:17:55 +02:00
|
|
|
if (!AbstractProcessStep::init())
|
|
|
|
|
return false;
|
|
|
|
|
|
2020-09-08 15:20:30 +02:00
|
|
|
BuildConfiguration *bc = buildConfiguration();
|
2020-02-24 10:46:54 +01:00
|
|
|
QTC_ASSERT(bc, return false);
|
2020-09-10 17:01:32 +02:00
|
|
|
|
2020-02-24 10:46:54 +01:00
|
|
|
if (!bc->isEnabled()) {
|
2020-01-15 08:56:11 +01:00
|
|
|
emit addTask(BuildSystemTask(Task::Error,
|
2020-02-26 08:35:05 +01:00
|
|
|
tr("The build configuration is currently disabled.")));
|
2020-09-10 17:01:32 +02:00
|
|
|
emitFaultyConfigurationMessage();
|
|
|
|
|
return false;
|
2017-04-24 13:37:55 +02:00
|
|
|
}
|
2016-01-07 13:15:29 +01:00
|
|
|
|
2020-09-07 15:56:18 +02:00
|
|
|
CMakeTool *tool = CMakeKitAspect::cmakeTool(kit());
|
2016-01-07 13:15:29 +01:00
|
|
|
if (!tool || !tool->isValid()) {
|
2020-01-15 08:56:11 +01:00
|
|
|
emit addTask(BuildSystemTask(Task::Error,
|
2017-08-29 11:48:48 +02:00
|
|
|
tr("A CMake tool must be set up for building. "
|
2020-01-15 08:56:11 +01:00
|
|
|
"Configure a CMake tool in the kit options.")));
|
2020-09-10 17:01:32 +02:00
|
|
|
emitFaultyConfigurationMessage();
|
|
|
|
|
return false;
|
2016-01-07 13:15:29 +01:00
|
|
|
}
|
2009-02-16 13:12:12 +01:00
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
if (m_buildTargets.contains(QString())) {
|
|
|
|
|
RunConfiguration *rc = target()->activeRunConfiguration();
|
|
|
|
|
if (!rc || rc->buildKey().isEmpty()) {
|
|
|
|
|
emit addTask(BuildSystemTask(Task::Error,
|
|
|
|
|
QCoreApplication::translate("ProjectExplorer::Task",
|
2016-01-11 11:40:24 +01:00
|
|
|
"You asked to build the current Run Configuration's build target only, "
|
|
|
|
|
"but it is not associated with a build target. "
|
2020-01-15 08:56:11 +01:00
|
|
|
"Update the Make Step in your build settings.")));
|
2020-09-10 17:01:32 +02:00
|
|
|
emitFaultyConfigurationMessage();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2012-09-06 13:13:12 +02:00
|
|
|
}
|
|
|
|
|
|
2017-06-22 13:53:48 +02:00
|
|
|
// Warn if doing out-of-source builds with a CMakeCache.txt is the source directory
|
2019-05-28 13:49:26 +02:00
|
|
|
const Utils::FilePath projectDirectory = bc->target()->project()->projectDirectory();
|
2017-06-22 13:53:48 +02:00
|
|
|
if (bc->buildDirectory() != projectDirectory) {
|
2019-05-15 14:54:25 +02:00
|
|
|
if (projectDirectory.pathAppended("CMakeCache.txt").exists()) {
|
2020-01-15 08:56:11 +01:00
|
|
|
emit addTask(BuildSystemTask(Task::Warning,
|
2017-06-22 13:53:48 +02:00
|
|
|
tr("There is a CMakeCache.txt file in \"%1\", which suggest an "
|
|
|
|
|
"in-source build was done before. You are now building in \"%2\", "
|
|
|
|
|
"and the CMakeCache.txt file might confuse CMake.")
|
2020-01-15 08:56:11 +01:00
|
|
|
.arg(projectDirectory.toUserOutput(), bc->buildDirectory().toUserOutput())));
|
2017-06-22 13:53:48 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-02 19:37:25 +02:00
|
|
|
setIgnoreReturnValue(m_buildTargets == QStringList(CMakeBuildStep::cleanTarget()));
|
2009-06-22 16:11:45 +02:00
|
|
|
|
2020-09-14 17:17:55 +02:00
|
|
|
return true;
|
2008-12-04 13:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
2020-04-16 13:53:05 +02:00
|
|
|
void CMakeBuildStep::setupOutputFormatter(Utils::OutputFormatter *formatter)
|
|
|
|
|
{
|
|
|
|
|
CMakeParser *cmakeParser = new CMakeParser;
|
2020-07-30 13:16:43 +02:00
|
|
|
CmakeProgressParser * const progressParser = new CmakeProgressParser;
|
|
|
|
|
connect(progressParser, &CmakeProgressParser::progress, this, [this](int percent) {
|
|
|
|
|
emit progress(percent, {});
|
|
|
|
|
});
|
|
|
|
|
formatter->addLineParser(progressParser);
|
2020-04-16 13:53:05 +02:00
|
|
|
cmakeParser->setSourceDirectory(project()->projectDirectory().toString());
|
|
|
|
|
formatter->addLineParsers({cmakeParser, new GnuMakeParser});
|
2020-09-07 15:56:18 +02:00
|
|
|
const QList<Utils::OutputLineParser *> additionalParsers = kit()->createOutputParsers();
|
2020-07-30 13:16:43 +02:00
|
|
|
for (Utils::OutputLineParser * const p : additionalParsers)
|
|
|
|
|
p->setRedirectionDetector(progressParser);
|
|
|
|
|
formatter->addLineParsers(additionalParsers);
|
2020-04-16 13:53:05 +02:00
|
|
|
formatter->addSearchDir(processParameters()->effectiveWorkingDirectory());
|
|
|
|
|
AbstractProcessStep::setupOutputFormatter(formatter);
|
|
|
|
|
}
|
|
|
|
|
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
void CMakeBuildStep::doRun()
|
2016-02-25 14:18:05 +01:00
|
|
|
{
|
|
|
|
|
// Make sure CMake state was written to disk before trying to build:
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
m_waiting = false;
|
2020-02-19 11:55:48 +01:00
|
|
|
auto bs = static_cast<CMakeBuildSystem *>(buildSystem());
|
2019-10-25 09:55:32 +02:00
|
|
|
if (bs->persistCMakeState()) {
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(tr("Persisting CMake state..."), BuildStep::OutputFormat::NormalMessage);
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
m_waiting = true;
|
2020-02-19 11:55:48 +01:00
|
|
|
} else if (buildSystem()->isWaitingForParse()) {
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(tr("Running CMake in preparation to build..."), BuildStep::OutputFormat::NormalMessage);
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
m_waiting = true;
|
2016-10-06 15:55:55 +02:00
|
|
|
}
|
2016-02-25 14:18:05 +01:00
|
|
|
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
if (m_waiting) {
|
2019-10-25 09:55:32 +02:00
|
|
|
m_runTrigger = connect(target(), &Target::parsingFinished,
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
this, [this](bool success) { handleProjectWasParsed(success); });
|
2016-02-25 14:18:05 +01:00
|
|
|
} else {
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
runImpl();
|
2016-02-25 14:18:05 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
void CMakeBuildStep::runImpl()
|
2016-02-25 14:18:05 +01:00
|
|
|
{
|
|
|
|
|
// Do the actual build:
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
AbstractProcessStep::doRun();
|
2017-06-19 17:29:35 +02:00
|
|
|
}
|
|
|
|
|
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
void CMakeBuildStep::handleProjectWasParsed(bool success)
|
2017-06-19 17:29:35 +02:00
|
|
|
{
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
m_waiting = false;
|
2016-02-25 14:18:05 +01:00
|
|
|
disconnect(m_runTrigger);
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
if (isCanceled()) {
|
|
|
|
|
emit finished(false);
|
|
|
|
|
} else if (success) {
|
|
|
|
|
runImpl();
|
2017-07-18 16:48:02 +02:00
|
|
|
} else {
|
2017-10-20 14:58:40 +02:00
|
|
|
AbstractProcessStep::stdError(tr("Project did not parse successfully, cannot build."));
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
emit finished(false);
|
2017-07-18 16:48:02 +02:00
|
|
|
}
|
2016-02-25 14:18:05 +01:00
|
|
|
}
|
|
|
|
|
|
2019-07-23 13:05:07 +02:00
|
|
|
QString CMakeBuildStep::defaultBuildTarget() const
|
|
|
|
|
{
|
2019-08-16 12:16:17 +02:00
|
|
|
const BuildStepList *const bsl = stepList();
|
|
|
|
|
QTC_ASSERT(bsl, return {});
|
2020-06-26 13:59:38 +02:00
|
|
|
const Utils::Id parentId = bsl->id();
|
2019-07-23 13:05:07 +02:00
|
|
|
if (parentId == ProjectExplorer::Constants::BUILDSTEPS_CLEAN)
|
|
|
|
|
return cleanTarget();
|
|
|
|
|
if (parentId == ProjectExplorer::Constants::BUILDSTEPS_DEPLOY)
|
|
|
|
|
return installTarget();
|
|
|
|
|
return allTarget();
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-02 19:37:25 +02:00
|
|
|
QStringList CMakeBuildStep::buildTargets() const
|
2011-10-21 23:17:58 +02:00
|
|
|
{
|
2020-06-02 19:37:25 +02:00
|
|
|
return m_buildTargets;
|
2011-10-21 23:17:58 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-07 12:33:52 +01:00
|
|
|
bool CMakeBuildStep::buildsBuildTarget(const QString &target) const
|
2009-01-12 15:10:33 +01:00
|
|
|
{
|
2020-06-02 19:37:25 +02:00
|
|
|
return m_buildTargets.contains(target);
|
2009-01-12 15:10:33 +01:00
|
|
|
}
|
|
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
void CMakeBuildStep::setBuildsBuildTarget(const QString &target, bool on)
|
|
|
|
|
{
|
|
|
|
|
QStringList targets = m_buildTargets;
|
|
|
|
|
if (on && !m_buildTargets.contains(target))
|
|
|
|
|
targets.append(target);
|
|
|
|
|
if (!on)
|
|
|
|
|
targets.removeAll(target);
|
|
|
|
|
setBuildTargets(targets);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-02 19:37:25 +02:00
|
|
|
void CMakeBuildStep::setBuildTargets(const QStringList &buildTargets)
|
2011-10-21 23:17:58 +02:00
|
|
|
{
|
2020-09-10 17:01:32 +02:00
|
|
|
if (buildTargets.isEmpty())
|
|
|
|
|
m_buildTargets = QStringList(defaultBuildTarget());
|
|
|
|
|
else
|
|
|
|
|
m_buildTargets = buildTargets;
|
|
|
|
|
updateBuildTargetsModel();
|
2011-10-21 23:17:58 +02:00
|
|
|
}
|
|
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
CommandLine CMakeBuildStep::cmakeCommand() const
|
2015-11-26 19:50:39 +01:00
|
|
|
{
|
2020-09-07 15:56:18 +02:00
|
|
|
CMakeTool *tool = CMakeKitAspect::cmakeTool(kit());
|
2015-11-26 19:50:39 +01:00
|
|
|
|
2019-05-29 18:54:45 +02:00
|
|
|
Utils::CommandLine cmd(tool ? tool->cmakeExecutable() : Utils::FilePath(), {});
|
|
|
|
|
cmd.addArgs({"--build", "."});
|
2015-11-26 19:50:39 +01:00
|
|
|
|
2020-06-02 19:37:25 +02:00
|
|
|
cmd.addArg("--target");
|
2020-09-10 17:01:32 +02:00
|
|
|
cmd.addArgs(Utils::transform(m_buildTargets, [this](const QString &s) {
|
|
|
|
|
if (s.isEmpty()) {
|
|
|
|
|
if (RunConfiguration *rc = target()->activeRunConfiguration())
|
|
|
|
|
return rc->buildKey();
|
2019-07-29 13:51:43 +02:00
|
|
|
}
|
2020-09-10 17:01:32 +02:00
|
|
|
return s;
|
2020-06-02 19:37:25 +02:00
|
|
|
}));
|
2016-01-07 13:15:29 +01:00
|
|
|
|
2020-09-08 14:53:15 +02:00
|
|
|
if (!m_cmakeArguments->value().isEmpty())
|
|
|
|
|
cmd.addArgs(m_cmakeArguments->value(), CommandLine::Raw);
|
2016-03-30 13:06:21 +02:00
|
|
|
|
2020-09-08 14:53:15 +02:00
|
|
|
if (!m_toolArguments->value().isEmpty()) {
|
2019-05-29 18:54:45 +02:00
|
|
|
cmd.addArg("--");
|
2020-09-08 14:53:15 +02:00
|
|
|
cmd.addArgs(m_toolArguments->value(), CommandLine::Raw);
|
2016-01-07 13:15:29 +01:00
|
|
|
}
|
2014-04-03 16:33:04 +02:00
|
|
|
|
2019-05-29 18:54:45 +02:00
|
|
|
return cmd;
|
2014-10-02 17:51:02 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-07 12:33:52 +01:00
|
|
|
QString CMakeBuildStep::cleanTarget()
|
2016-01-07 12:09:59 +01:00
|
|
|
{
|
2017-04-28 08:23:57 +02:00
|
|
|
return QString("clean");
|
2016-01-07 12:09:59 +01:00
|
|
|
}
|
|
|
|
|
|
2016-03-30 13:06:21 +02:00
|
|
|
QString CMakeBuildStep::allTarget()
|
|
|
|
|
{
|
2017-04-28 08:23:57 +02:00
|
|
|
return QString("all");
|
2017-04-26 15:27:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString CMakeBuildStep::installTarget()
|
|
|
|
|
{
|
2017-04-28 08:23:57 +02:00
|
|
|
return QString("install");
|
2017-04-26 15:27:01 +02:00
|
|
|
}
|
|
|
|
|
|
2017-06-02 09:11:39 +02:00
|
|
|
QString CMakeBuildStep::testTarget()
|
|
|
|
|
{
|
|
|
|
|
return QString("test");
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-26 15:27:01 +02:00
|
|
|
QStringList CMakeBuildStep::specialTargets()
|
|
|
|
|
{
|
2017-06-02 09:11:39 +02:00
|
|
|
return { allTarget(), cleanTarget(), installTarget(), testTarget() };
|
2016-03-30 13:06:21 +02:00
|
|
|
}
|
|
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
QString CMakeBuildStep::activeRunConfigTarget() const
|
|
|
|
|
{
|
|
|
|
|
RunConfiguration *rc = target()->activeRunConfiguration();
|
|
|
|
|
return rc ? rc->buildKey() : QString();
|
|
|
|
|
}
|
2009-03-12 15:51:44 +01:00
|
|
|
|
2020-10-02 17:53:39 +02:00
|
|
|
QWidget *CMakeBuildStep::createConfigWidget()
|
2009-01-12 15:10:33 +01:00
|
|
|
{
|
2020-10-02 17:53:39 +02:00
|
|
|
auto widget = new QWidget;
|
2020-09-10 17:01:32 +02:00
|
|
|
|
2020-09-14 12:37:32 +02:00
|
|
|
auto updateDetails = [this] {
|
2020-09-10 17:01:32 +02:00
|
|
|
ProcessParameters param;
|
|
|
|
|
setupProcessParameters(¶m);
|
|
|
|
|
param.setCommandLine(cmakeCommand());
|
2020-09-14 12:37:32 +02:00
|
|
|
setSummaryText(param.summary(displayName()));
|
2020-09-10 17:01:32 +02:00
|
|
|
};
|
2018-10-12 17:52:09 +02:00
|
|
|
|
2020-09-14 12:37:32 +02:00
|
|
|
setDisplayName(tr("Build", "ConfigWidget display name."));
|
2009-03-12 15:51:44 +01:00
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
LayoutBuilder builder(widget);
|
|
|
|
|
builder.addRow(m_cmakeArguments);
|
|
|
|
|
builder.addRow(m_toolArguments);
|
2014-08-04 12:16:04 +02:00
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
auto buildTargetsView = new QTreeView;
|
|
|
|
|
buildTargetsView->setMinimumHeight(200);
|
|
|
|
|
buildTargetsView->setModel(&m_buildTargetModel);
|
|
|
|
|
buildTargetsView->setRootIsDecorated(false);
|
|
|
|
|
buildTargetsView->setHeaderHidden(true);
|
|
|
|
|
|
|
|
|
|
auto frame = ItemViewFind::createSearchableWrapper(buildTargetsView,
|
|
|
|
|
ItemViewFind::LightColored);
|
2014-08-04 12:16:04 +02:00
|
|
|
|
2020-09-18 04:54:41 +02:00
|
|
|
builder.addRow({new QLabel(tr("Targets:")), frame});
|
2009-01-12 15:10:33 +01:00
|
|
|
|
2011-05-30 13:30:10 +02:00
|
|
|
updateDetails();
|
|
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
connect(m_cmakeArguments, &StringAspect::changed, this, updateDetails);
|
|
|
|
|
connect(m_toolArguments, &StringAspect::changed, this, updateDetails);
|
2020-09-08 14:53:15 +02:00
|
|
|
|
2016-01-07 12:33:52 +01:00
|
|
|
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
|
2020-09-10 17:01:32 +02:00
|
|
|
this, updateDetails);
|
2014-10-02 17:51:02 +02:00
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
connect(buildConfiguration(), &BuildConfiguration::environmentChanged,
|
|
|
|
|
this, updateDetails);
|
|
|
|
|
|
|
|
|
|
connect(this, &CMakeBuildStep::buildTargetsChanged, widget, updateDetails);
|
|
|
|
|
|
2020-09-24 13:03:25 +03:00
|
|
|
// For Qt 6 for Android: Make sure to add "<target>_prepare_apk_dir" if only
|
|
|
|
|
// "all" target is selected. This copies the build shared libs to android-build
|
|
|
|
|
// folder, partially the same as done in AndroidPackageInstallationStep for
|
|
|
|
|
// qmake install step.
|
|
|
|
|
const Kit *k = target()->kit();
|
|
|
|
|
if (DeviceTypeKitAspect::deviceTypeId(k) == Android::Constants::ANDROID_DEVICE_TYPE) {
|
|
|
|
|
const QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(k);
|
|
|
|
|
if (qt && qt->qtVersion() >= QtSupport::QtVersionNumber{6, 0, 0}) {
|
|
|
|
|
QMetaObject::Connection *const connection = new QMetaObject::Connection;
|
|
|
|
|
*connection = connect(this, &CMakeBuildStep::buildTargetsChanged, widget, [this, connection]() {
|
|
|
|
|
const QString mainTarget = activeRunConfigTarget();
|
|
|
|
|
if (!mainTarget.isEmpty()) {
|
|
|
|
|
QStringList targets{buildTargets()};
|
|
|
|
|
if (targets == QStringList{allTarget()}) {
|
|
|
|
|
targets.append(QString("%1_prepare_apk_dir").arg(mainTarget));
|
|
|
|
|
setBuildTargets({targets});
|
|
|
|
|
QObject::disconnect(*connection);
|
|
|
|
|
delete connection;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
return widget;
|
2009-01-12 15:10:33 +01:00
|
|
|
}
|
2008-12-04 13:06:02 +01:00
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
void CMakeBuildStep::recreateBuildTargetsModel()
|
2017-03-31 17:17:20 +02:00
|
|
|
{
|
2020-09-10 17:01:32 +02:00
|
|
|
auto addItem = [this](const QString &target, bool special = false) {
|
|
|
|
|
auto item = new CMakeTargetItem(target, this, special);
|
|
|
|
|
m_buildTargetModel.rootItem()->appendChild(item);
|
|
|
|
|
};
|
2020-06-02 19:37:25 +02:00
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
m_buildTargetModel.clear();
|
2018-07-20 12:17:36 +02:00
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
auto bs = qobject_cast<CMakeBuildSystem *>(buildSystem());
|
|
|
|
|
QStringList targetList = bs ? bs->buildTargetTitles() : QStringList();
|
2017-03-31 17:17:20 +02:00
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
targetList.sort();
|
2016-03-30 13:06:21 +02:00
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
addItem(QString(), true);
|
2017-04-26 15:29:54 +02:00
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
for (const QString &buildTarget : qAsConst(targetList))
|
|
|
|
|
addItem(buildTarget, specialTargets().contains(buildTarget));
|
2016-03-30 13:06:21 +02:00
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
updateBuildTargetsModel();
|
2009-08-06 17:26:38 +02:00
|
|
|
}
|
|
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
void CMakeBuildStep::updateBuildTargetsModel()
|
2013-08-26 16:01:24 +02:00
|
|
|
{
|
2020-09-10 17:01:32 +02:00
|
|
|
emit m_buildTargetModel.layoutChanged();
|
|
|
|
|
emit buildTargetsChanged();
|
2013-08-26 16:01:24 +02:00
|
|
|
}
|
2018-07-20 12:17:36 +02:00
|
|
|
|
2020-09-10 17:01:32 +02:00
|
|
|
void CMakeBuildStep::processFinished(int exitCode, QProcess::ExitStatus status)
|
2009-08-06 17:26:38 +02:00
|
|
|
{
|
2020-09-10 17:01:32 +02:00
|
|
|
AbstractProcessStep::processFinished(exitCode, status);
|
|
|
|
|
emit progress(100, QString());
|
2009-08-06 15:31:32 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-07 12:33:52 +01:00
|
|
|
// CMakeBuildStepFactory
|
2008-12-04 13:06:02 +01:00
|
|
|
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
CMakeBuildStepFactory::CMakeBuildStepFactory()
|
2010-01-14 17:41:29 +01:00
|
|
|
{
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
registerStep<CMakeBuildStep>(Constants::CMAKE_BUILD_STEP_ID);
|
2020-09-24 17:29:46 +02:00
|
|
|
setDisplayName(CMakeBuildStep::tr("CMake Build", "Display name for CMakeProjectManager::CMakeBuildStep id."));
|
2020-04-07 14:44:22 +02:00
|
|
|
setSupportedProjectType(Constants::CMAKE_PROJECT_ID);
|
2010-01-14 17:41:29 +01:00
|
|
|
}
|
|
|
|
|
|
2020-02-20 18:04:36 +01:00
|
|
|
} // Internal
|
|
|
|
|
} // CMakeProjectManager
|
2020-07-30 13:16:43 +02:00
|
|
|
|
|
|
|
|
#include <cmakebuildstep.moc>
|