forked from qt-creator/qt-creator
Incredibuild: Do not rely on metaobject classnames for build steps
The preferred interface are step ids, #include'ing other modules *constants.h header is considered ok for siblings in the core distribution and does not create run time dependencies between plugins. Change-Id: I0421936068b459c1aea61e23310f860d8ed1f0d4 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -26,15 +26,12 @@
|
||||
#include "cmakecommandbuilder.h"
|
||||
|
||||
#include <projectexplorer/buildconfiguration.h>
|
||||
#include <projectexplorer/buildstep.h>
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
#include <projectexplorer/project.h>
|
||||
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
#include <cmakeprojectmanager/cmakeprojectconstants.h> // Compile-time only
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QStandardPaths>
|
||||
|
||||
@@ -43,19 +40,9 @@ using namespace ProjectExplorer;
|
||||
namespace IncrediBuild {
|
||||
namespace Internal {
|
||||
|
||||
bool CMakeCommandBuilder::canMigrate(BuildStepList *buildStepList)
|
||||
QList<Utils::Id> CMakeCommandBuilder::migratableSteps() const
|
||||
{
|
||||
// "Make"
|
||||
QString makeClassName("CMakeProjectManager::Internal::CMakeBuildStep");
|
||||
for (int i = buildStepList->count() - 1; i >= 0; --i) {
|
||||
QString className = QString::fromUtf8(buildStepList->at(i)->metaObject()->className());
|
||||
if (className.compare(makeClassName) == 0) {
|
||||
buildStepList->at(i)->setEnabled(false);
|
||||
buildStepList->at(i)->projectConfiguration()->project()->saveSettings();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return {CMakeProjectManager::Constants::CMAKE_BUILD_STEP_ID};
|
||||
}
|
||||
|
||||
QString CMakeCommandBuilder::defaultCommand() const
|
||||
|
@@ -36,7 +36,7 @@ public:
|
||||
CMakeCommandBuilder(ProjectExplorer::BuildStep *buildStep) : CommandBuilder(buildStep) {}
|
||||
|
||||
private:
|
||||
bool canMigrate(ProjectExplorer::BuildStepList *buildStepList) final;
|
||||
QList<Utils::Id> migratableSteps() const final;
|
||||
QString id() const final { return "CMakeCommandBuilder"; }
|
||||
QString displayName() const final { return tr("CMake"); }
|
||||
QString defaultCommand() const final;
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
#include <projectexplorer/buildstep.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
CommandBuilder(ProjectExplorer::BuildStep *buildStep) : m_buildStep(buildStep) {}
|
||||
virtual ~CommandBuilder() = default;
|
||||
|
||||
virtual bool canMigrate(ProjectExplorer::BuildStepList*) { return false; }
|
||||
virtual QList<Utils::Id> migratableSteps() const { return {}; }
|
||||
|
||||
ProjectExplorer::BuildStep *buildStep() const { return m_buildStep; }
|
||||
|
||||
|
@@ -30,6 +30,8 @@
|
||||
#include "makecommandbuilder.h"
|
||||
|
||||
#include <projectexplorer/abstractprocessstep.h>
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
#include <projectexplorer/project.h>
|
||||
|
||||
#include <utils/environment.h>
|
||||
#include <utils/pathchooser.h>
|
||||
@@ -69,7 +71,7 @@ public:
|
||||
&m_cmakeCommandBuilder
|
||||
};
|
||||
|
||||
// Default to the first in list, which should be the "Custom Command"
|
||||
// Default to "Custom Command", but try to upgrade in tryToMigrate() later.
|
||||
CommandBuilder *m_activeCommandBuilder = m_commandBuilders[0];
|
||||
|
||||
bool m_loadedFromMap = false;
|
||||
@@ -115,12 +117,17 @@ void CommandBuilderAspectPrivate::setActiveCommandBuilder(const QString &command
|
||||
|
||||
void CommandBuilderAspectPrivate::tryToMigrate()
|
||||
{
|
||||
// This constructor is called when creating a fresh build step.
|
||||
// This function is called when creating a fresh build step.
|
||||
// Attempt to detect build system from pre-existing steps.
|
||||
for (CommandBuilder *p : m_commandBuilders) {
|
||||
if (p->canMigrate(m_buildStep->stepList())) {
|
||||
const QList<Utils::Id> migratableSteps = p->migratableSteps();
|
||||
for (Utils::Id stepId : migratableSteps) {
|
||||
if (BuildStep *bs = m_buildStep->stepList()->firstStepWithId(stepId)) {
|
||||
m_activeCommandBuilder = p;
|
||||
break;
|
||||
bs->setEnabled(false);
|
||||
m_buildStep->project()->saveSettings();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -34,6 +34,8 @@
|
||||
#include <projectexplorer/toolchain.h>
|
||||
#include <projectexplorer/project.h>
|
||||
|
||||
#include <qmakeprojectmanager/qmakeprojectmanagerconstants.h> // Compile-time only
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFileInfo>
|
||||
#include <QRegularExpression>
|
||||
@@ -43,19 +45,9 @@ using namespace ProjectExplorer;
|
||||
namespace IncrediBuild {
|
||||
namespace Internal {
|
||||
|
||||
bool MakeCommandBuilder::canMigrate(BuildStepList *buildStepList)
|
||||
QList<Utils::Id> MakeCommandBuilder::migratableSteps() const
|
||||
{
|
||||
// "Make"
|
||||
QString makeClassName("QmakeProjectManager::QmakeMakeStep");
|
||||
for (int i = buildStepList->count() - 1; i >= 0; --i) {
|
||||
QString className = QString::fromUtf8(buildStepList->at(i)->metaObject()->className());
|
||||
if (className.compare(makeClassName) == 0) {
|
||||
buildStepList->at(i)->setEnabled(false);
|
||||
buildStepList->at(i)->projectConfiguration()->project()->saveSettings();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return {QmakeProjectManager::Constants::MAKESTEP_BS_ID};
|
||||
}
|
||||
|
||||
QString MakeCommandBuilder::defaultCommand() const
|
||||
|
@@ -36,7 +36,7 @@ public:
|
||||
MakeCommandBuilder(ProjectExplorer::BuildStep *buildStep) : CommandBuilder(buildStep) {}
|
||||
|
||||
private:
|
||||
bool canMigrate(ProjectExplorer::BuildStepList *buildStepList) final;
|
||||
QList<Utils::Id> migratableSteps() const final;
|
||||
QString id() const final { return "MakeCommandBuilder"; }
|
||||
QString displayName() const final { return tr("Make"); }
|
||||
QString defaultCommand() const final;
|
||||
|
Reference in New Issue
Block a user