Files
qt-creator/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp

568 lines
18 KiB
C++
Raw Normal View History

/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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
** 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.
**
** 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
**
****************************************************************************/
#include "cmakebuildstep.h"
#include "cmakebuildconfiguration.h"
#include "cmakebuildsystem.h"
#include "cmakekitinformation.h"
#include "cmakeparser.h"
#include "cmakeprojectconstants.h"
#include "cmakeproject.h"
#include "cmaketool.h"
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/deployconfiguration.h>
#include <projectexplorer/gnumakeparser.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/processparameters.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/target.h>
#include <projectexplorer/toolchain.h>
#include <qtsupport/qtkitinformation.h>
#include <qtsupport/qtparser.h>
#include <coreplugin/find/itemviewfind.h>
#include <utils/algorithm.h>
#include <utils/qtcprocess.h>
#include <utils/pathchooser.h>
#include <QCheckBox>
#include <QDir>
#include <QFormLayout>
#include <QGroupBox>
#include <QLineEdit>
#include <QListWidget>
#include <QRadioButton>
2008-12-09 15:25:01 +01:00
using namespace CMakeProjectManager;
using namespace CMakeProjectManager::Internal;
using namespace ProjectExplorer;
namespace {
const char BUILD_TARGETS_KEY[] = "CMakeProjectManager.MakeStep.BuildTargets";
const char TOOL_ARGUMENTS_KEY[] = "CMakeProjectManager.MakeStep.AdditionalArguments";
const char ADD_RUNCONFIGURATION_ARGUMENT_KEY[] = "CMakeProjectManager.MakeStep.AddRunConfigurationArgument";
const char ADD_RUNCONFIGURATION_TEXT[] = "Current executable";
}
static bool isCurrentExecutableTarget(const QString &target)
{
return target == ADD_RUNCONFIGURATION_TEXT;
}
CMakeBuildStep::CMakeBuildStep(BuildStepList *bsl, Core::Id id) :
AbstractProcessStep(bsl, id)
{
m_percentProgress = QRegExp("^\\[\\s*(\\d*)%\\]");
m_ninjaProgress = QRegExp("^\\[\\s*(\\d*)/\\s*(\\d*)");
m_ninjaProgressString = "[%f/%t "; // ninja: [33/100
//: Default display name for the cmake make step.
setDefaultDisplayName(tr("CMake Build"));
// Set a good default build target:
if (m_buildTarget.isEmpty())
setBuildTarget(defaultBuildTarget());
setLowPriority();
connect(target(), &Target::parsingFinished,
this, &CMakeBuildStep::handleBuildTargetChanges);
}
CMakeBuildConfiguration *CMakeBuildStep::cmakeBuildConfiguration() const
2009-11-26 14:43:27 +01:00
{
return static_cast<CMakeBuildConfiguration *>(buildConfiguration());
}
void CMakeBuildStep::handleBuildTargetChanges(bool success)
{
if (!success)
return; // Do not change when parsing failed.
if (!isCurrentExecutableTarget(m_buildTarget) && !knownBuildTargets().contains(m_buildTarget)) {
setBuildTarget(defaultBuildTarget());
}
emit buildTargetsChanged();
}
QVariantMap CMakeBuildStep::toMap() const
{
QVariantMap map(AbstractProcessStep::toMap());
// Use QStringList for compatibility with old files
map.insert(BUILD_TARGETS_KEY, QStringList(m_buildTarget));
map.insert(TOOL_ARGUMENTS_KEY, m_toolArguments);
return map;
}
bool CMakeBuildStep::fromMap(const QVariantMap &map)
{
const QStringList targetList = map.value(BUILD_TARGETS_KEY).toStringList();
if (!targetList.isEmpty())
m_buildTarget = targetList.last();
m_toolArguments = map.value(TOOL_ARGUMENTS_KEY).toString();
if (map.value(ADD_RUNCONFIGURATION_ARGUMENT_KEY, false).toBool())
m_buildTarget = ADD_RUNCONFIGURATION_TEXT;
return BuildStep::fromMap(map);
}
bool CMakeBuildStep::init()
{
bool canInit = true;
2009-11-26 14:43:27 +01:00
CMakeBuildConfiguration *bc = cmakeBuildConfiguration();
if (!bc) {
emit addTask(Task::buildConfigurationMissingTask());
canInit = false;
}
if (bc && !bc->isEnabled()) {
emit addTask(BuildSystemTask(Task::Error,
tr("CMakeProjectManager::CMakeBuildStep")));
canInit = false;
}
CMakeTool *tool = CMakeKitAspect::cmakeTool(target()->kit());
if (!tool || !tool->isValid()) {
emit addTask(BuildSystemTask(Task::Error,
tr("A CMake tool must be set up for building. "
"Configure a CMake tool in the kit options.")));
canInit = false;
}
RunConfiguration *rc = target()->activeRunConfiguration();
ProjectExplorer: Consolidate RunConfiguration identifications The previously per-Project/RunConfiguration changing meanings of BuildTargetInfo::buildTarget have by now been split into separate values in BuildTargetInfo: - buildKey a handle to one item in Target::applicationTargetList - displayName a user-visible string in the run settings page The buildKey was tweaked to coincide with the previous 'extraId', i.e. the non-RunConfiguration-type part of the project configuration id that (still) use id mangling. This allows replacing the cases of locally stored seven different versions of buildKey(-ish) data by one RunConfiguration::m_buildKey, and do all remaining extraId handling in RC::{from,to}Map only, i.e. remove the base ProjectConfiguration::extraId() virtual and remove the "re-try fromMap with mangled id" hack entirely. The id mangling is still used to temporarily maintain .user file compatibility in some cases for now, but should be replaced by storing the build key and the RunConfiguration type soon. Qbs already changes in here to only use the uniqueProductName as buildKey, without the previously added display name which is stored as part of the ProjectConfiguration already. It turns out that RunConfiguration::buildSystemTarget was intended and used to retrieve an item from the Target::applicationTargetList for some configurations, coinciding with what buildKey does always. So use that insteand and drop RunConfiguration::buildSystemTarget. There is clearly is further consolidation potential left. handling of (default)displayNames is still a per-runconfiguration mess and there is further consolidation potential left. Change-Id: I448ed30f1b562fb91b970e328a42fa5f6fb2e43e Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2018-04-09 12:33:10 +02:00
if (isCurrentExecutableTarget(m_buildTarget) && (!rc || rc->buildKey().isEmpty())) {
emit addTask(BuildSystemTask(Task::Error,
QCoreApplication::translate("ProjectExplorer::Task",
"You asked to build the current Run Configuration's build target only, "
"but it is not associated with a build target. "
"Update the Make Step in your build settings.")));
canInit = false;
}
if (!canInit) {
emitFaultyConfigurationMessage();
return false;
}
// Warn if doing out-of-source builds with a CMakeCache.txt is the source directory
const Utils::FilePath projectDirectory = bc->target()->project()->projectDirectory();
if (bc->buildDirectory() != projectDirectory) {
if (projectDirectory.pathAppended("CMakeCache.txt").exists()) {
emit addTask(BuildSystemTask(Task::Warning,
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.")
.arg(projectDirectory.toUserOutput(), bc->buildDirectory().toUserOutput())));
}
}
setIgnoreReturnValue(m_buildTarget == CMakeBuildStep::cleanTarget());
ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc->macroExpander());
Utils::Environment env = bc->environment();
Utils::Environment::setupEnglishOutput(&env);
if (!env.expandedValueForKey("NINJA_STATUS").startsWith(m_ninjaProgressString))
env.set("NINJA_STATUS", m_ninjaProgressString + "%o/sec] ");
pp->setEnvironment(env);
pp->setWorkingDirectory(bc->buildDirectory());
pp->setCommandLine(cmakeCommand(rc));
pp->resolveAll();
CMakeParser *cmakeParser = new CMakeParser;
cmakeParser->setSourceDirectory(projectDirectory.toString());
setOutputParser(cmakeParser);
appendOutputParser(new GnuMakeParser);
IOutputParser *parser = target()->kit()->createOutputParser();
if (parser)
appendOutputParser(parser);
outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory());
return AbstractProcessStep::init();
}
void CMakeBuildStep::doRun()
{
// Make sure CMake state was written to disk before trying to build:
CMakeBuildConfiguration *bc = cmakeBuildConfiguration();
QTC_ASSERT(bc, return);
m_waiting = false;
auto bs = static_cast<CMakeBuildSystem *>(buildSystem());
if (bs->persistCMakeState()) {
emit addOutput(tr("Persisting CMake state..."), BuildStep::OutputFormat::NormalMessage);
m_waiting = true;
} else if (buildSystem()->isWaitingForParse()) {
emit addOutput(tr("Running CMake in preparation to build..."), BuildStep::OutputFormat::NormalMessage);
m_waiting = true;
}
if (m_waiting) {
m_runTrigger = connect(target(), &Target::parsingFinished,
this, [this](bool success) { handleProjectWasParsed(success); });
} else {
runImpl();
}
}
void CMakeBuildStep::runImpl()
{
// Do the actual build:
AbstractProcessStep::doRun();
}
void CMakeBuildStep::handleProjectWasParsed(bool success)
{
m_waiting = false;
disconnect(m_runTrigger);
if (isCanceled()) {
emit finished(false);
} else if (success) {
runImpl();
} else {
AbstractProcessStep::stdError(tr("Project did not parse successfully, cannot build."));
emit finished(false);
}
}
BuildStepConfigWidget *CMakeBuildStep::createConfigWidget()
{
return new CMakeBuildStepConfigWidget(this);
}
QString CMakeBuildStep::defaultBuildTarget() const
{
const BuildStepList *const bsl = stepList();
QTC_ASSERT(bsl, return {});
const Core::Id parentId = bsl->id();
if (parentId == ProjectExplorer::Constants::BUILDSTEPS_CLEAN)
return cleanTarget();
if (parentId == ProjectExplorer::Constants::BUILDSTEPS_DEPLOY)
return installTarget();
return allTarget();
}
void CMakeBuildStep::stdOutput(const QString &line)
{
if (m_percentProgress.indexIn(line) != -1) {
AbstractProcessStep::stdOutput(line);
bool ok = false;
int percent = m_percentProgress.cap(1).toInt(&ok);
if (ok)
emit progress(percent, QString());
return;
} else if (m_ninjaProgress.indexIn(line) != -1) {
AbstractProcessStep::stdOutput(line);
m_useNinja = true;
bool ok = false;
int done = m_ninjaProgress.cap(1).toInt(&ok);
if (ok) {
int all = m_ninjaProgress.cap(2).toInt(&ok);
if (ok && all != 0) {
const int percent = static_cast<int>(100.0 * done/all);
emit progress(percent, QString());
}
}
return;
}
if (m_useNinja)
AbstractProcessStep::stdError(line);
else
AbstractProcessStep::stdOutput(line);
}
QString CMakeBuildStep::buildTarget() const
{
return m_buildTarget;
}
bool CMakeBuildStep::buildsBuildTarget(const QString &target) const
{
return target == m_buildTarget;
}
void CMakeBuildStep::setBuildTarget(const QString &buildTarget)
{
if (m_buildTarget == buildTarget)
return;
m_buildTarget = buildTarget;
emit targetToBuildChanged();
}
QString CMakeBuildStep::toolArguments() const
{
return m_toolArguments;
}
void CMakeBuildStep::setToolArguments(const QString &list)
{
m_toolArguments = list;
}
Utils::CommandLine CMakeBuildStep::cmakeCommand(RunConfiguration *rc) const
{
CMakeTool *tool = CMakeKitAspect::cmakeTool(target()->kit());
Utils::CommandLine cmd(tool ? tool->cmakeExecutable() : Utils::FilePath(), {});
cmd.addArgs({"--build", "."});
QString target;
if (isCurrentExecutableTarget(m_buildTarget)) {
if (rc) {
target = rc->buildKey();
const int pos = target.indexOf("///::///");
if (pos >= 0) {
target = target.mid(pos + 8);
}
} else {
target = "<i>&lt;" + tr(ADD_RUNCONFIGURATION_TEXT) + "&gt;</i>";
}
} else {
target = m_buildTarget;
}
cmd.addArgs({"--target", target});
if (!m_toolArguments.isEmpty()) {
cmd.addArg("--");
cmd.addArgs(m_toolArguments, Utils::CommandLine::Raw);
}
return cmd;
}
QStringList CMakeBuildStep::knownBuildTargets()
{
auto bc = qobject_cast<CMakeBuildSystem *>(buildSystem());
return bc ? bc->buildTargetTitles() : QStringList();
}
QString CMakeBuildStep::cleanTarget()
{
return QString("clean");
}
QString CMakeBuildStep::allTarget()
{
return QString("all");
}
QString CMakeBuildStep::installTarget()
{
return QString("install");
}
QString CMakeBuildStep::testTarget()
{
return QString("test");
}
QStringList CMakeBuildStep::specialTargets()
{
return { allTarget(), cleanTarget(), installTarget(), testTarget() };
}
//
// CMakeBuildStepConfigWidget
//
CMakeBuildStepConfigWidget::CMakeBuildStepConfigWidget(CMakeBuildStep *buildStep) :
BuildStepConfigWidget(buildStep),
m_buildStep(buildStep),
m_toolArguments(new QLineEdit),
m_buildTargetsList(new QListWidget)
{
setDisplayName(tr("Build", "CMakeProjectManager::CMakeBuildStepConfigWidget display name."));
auto fl = new QFormLayout(this);
fl->setContentsMargins(0, 0, 0, 0);
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
setLayout(fl);
fl->addRow(tr("Tool arguments:"), m_toolArguments);
m_toolArguments->setText(m_buildStep->toolArguments());
m_buildTargetsList->setFrameStyle(QFrame::NoFrame);
m_buildTargetsList->setMinimumHeight(200);
auto frame = new QFrame(this);
frame->setFrameStyle(QFrame::StyledPanel);
auto frameLayout = new QVBoxLayout(frame);
frameLayout->setContentsMargins(0, 0, 0, 0);
frameLayout->addWidget(Core::ItemViewFind::createSearchableWrapper(m_buildTargetsList,
Core::ItemViewFind::LightColored));
fl->addRow(tr("Targets:"), frame);
buildTargetsChanged();
updateDetails();
connect(m_toolArguments, &QLineEdit::textEdited, this, &CMakeBuildStepConfigWidget::toolArgumentsEdited);
connect(m_buildTargetsList, &QListWidget::itemChanged, this, &CMakeBuildStepConfigWidget::itemChanged);
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
this, &CMakeBuildStepConfigWidget::updateDetails);
connect(m_buildStep,
&CMakeBuildStep::buildTargetsChanged,
this,
&CMakeBuildStepConfigWidget::buildTargetsChanged);
connect(m_buildStep,
&CMakeBuildStep::targetToBuildChanged,
this,
&CMakeBuildStepConfigWidget::updateBuildTarget);
connect(m_buildStep->buildConfiguration(),
&BuildConfiguration::environmentChanged,
this,
&CMakeBuildStepConfigWidget::updateDetails);
}
void CMakeBuildStepConfigWidget::toolArgumentsEdited()
{
m_buildStep->setToolArguments(m_toolArguments->text());
updateDetails();
}
void CMakeBuildStepConfigWidget::itemChanged(QListWidgetItem *item)
{
const QString target =
(item->checkState() == Qt::Checked) ? item->data(Qt::UserRole).toString() : CMakeBuildStep::allTarget();
m_buildStep->setBuildTarget(target);
updateDetails();
}
void CMakeBuildStepConfigWidget::buildTargetsChanged()
{
{
auto addItem = [this](const QString &buildTarget,
const QString &displayName) {
auto item = new QListWidgetItem(m_buildTargetsList);
auto button = new QRadioButton(displayName);
connect(button, &QRadioButton::toggled, this, [this, buildTarget](bool toggled) {
if (toggled) {
m_buildStep->setBuildTarget(buildTarget);
}
});
m_buildTargetsList->setItemWidget(item, button);
item->setData(Qt::UserRole, buildTarget);
};
QSignalBlocker blocker(m_buildTargetsList);
m_buildTargetsList->clear();
QStringList targetList = m_buildStep->knownBuildTargets();
targetList.sort();
QFont italics;
italics.setItalic(true);
addItem(ADD_RUNCONFIGURATION_TEXT, tr(ADD_RUNCONFIGURATION_TEXT));
foreach (const QString &buildTarget, targetList)
addItem(buildTarget, buildTarget);
for (int i = 0; i < m_buildTargetsList->count(); ++i) {
QListWidgetItem *item = m_buildTargetsList->item(i);
const QString title = item->data(Qt::UserRole).toString();
QRadioButton *radio = itemWidget(item);
radio->setChecked(m_buildStep->buildsBuildTarget(title));
// Print utility targets in italics:
if (CMakeBuildStep::specialTargets().contains(title) || title == ADD_RUNCONFIGURATION_TEXT)
radio->setFont(italics);
}
}
updateDetails();
}
void CMakeBuildStepConfigWidget::updateBuildTarget()
{
const QString buildTarget = m_buildStep->buildTarget();
{
QSignalBlocker blocker(m_buildTargetsList);
for (int y = 0; y < m_buildTargetsList->count(); ++y) {
QListWidgetItem *item = m_buildTargetsList->item(y);
const QString itemTarget = item->data(Qt::UserRole).toString();
if (itemTarget == buildTarget) {
QRadioButton *radio = itemWidget(item);
radio->setChecked(true);
}
}
}
updateDetails();
}
QRadioButton *CMakeBuildStepConfigWidget::itemWidget(QListWidgetItem *item)
{
return static_cast<QRadioButton *>(m_buildTargetsList->itemWidget(item));
}
void CMakeBuildStepConfigWidget::updateDetails()
{
BuildConfiguration *bc = m_buildStep->buildConfiguration();
if (!bc) {
setSummaryText(tr("<b>No build configuration found on this kit.</b>"));
return;
}
ProcessParameters param;
param.setMacroExpander(m_buildStep->macroExpander());
param.setEnvironment(m_buildStep->buildEnvironment());
param.setWorkingDirectory(m_buildStep->buildDirectory());
param.setCommandLine(m_buildStep->cmakeCommand(nullptr));
setSummaryText(param.summary(displayName()));
}
//
// CMakeBuildStepFactory
//
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()
{
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);
setDisplayName(CMakeBuildStep::tr("Build", "Display name for CMakeProjectManager::CMakeBuildStep id."));
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
setSupportedProjectType(Constants::CMAKEPROJECT_ID);
}
void CMakeBuildStep::processStarted()
{
m_useNinja = false;
AbstractProcessStep::processStarted();
}
void CMakeBuildStep::processFinished(int exitCode, QProcess::ExitStatus status)
{
AbstractProcessStep::processFinished(exitCode, status);
emit progress(100, QString());
}