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 "cmakecommandbuilder.h"
|
||||||
|
|
||||||
#include <projectexplorer/buildconfiguration.h>
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
#include <projectexplorer/buildstep.h>
|
|
||||||
#include <projectexplorer/buildsteplist.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 <utils/qtcprocess.h>
|
||||||
|
|
||||||
|
#include <cmakeprojectmanager/cmakeprojectconstants.h> // Compile-time only
|
||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
@@ -43,19 +40,9 @@ using namespace ProjectExplorer;
|
|||||||
namespace IncrediBuild {
|
namespace IncrediBuild {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
bool CMakeCommandBuilder::canMigrate(BuildStepList *buildStepList)
|
QList<Utils::Id> CMakeCommandBuilder::migratableSteps() const
|
||||||
{
|
{
|
||||||
// "Make"
|
return {CMakeProjectManager::Constants::CMAKE_BUILD_STEP_ID};
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CMakeCommandBuilder::defaultCommand() const
|
QString CMakeCommandBuilder::defaultCommand() const
|
||||||
|
@@ -36,7 +36,7 @@ public:
|
|||||||
CMakeCommandBuilder(ProjectExplorer::BuildStep *buildStep) : CommandBuilder(buildStep) {}
|
CMakeCommandBuilder(ProjectExplorer::BuildStep *buildStep) : CommandBuilder(buildStep) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool canMigrate(ProjectExplorer::BuildStepList *buildStepList) final;
|
QList<Utils::Id> migratableSteps() const final;
|
||||||
QString id() const final { return "CMakeCommandBuilder"; }
|
QString id() const final { return "CMakeCommandBuilder"; }
|
||||||
QString displayName() const final { return tr("CMake"); }
|
QString displayName() const final { return tr("CMake"); }
|
||||||
QString defaultCommand() const final;
|
QString defaultCommand() const final;
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <projectexplorer/buildsteplist.h>
|
#include <projectexplorer/buildstep.h>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ public:
|
|||||||
CommandBuilder(ProjectExplorer::BuildStep *buildStep) : m_buildStep(buildStep) {}
|
CommandBuilder(ProjectExplorer::BuildStep *buildStep) : m_buildStep(buildStep) {}
|
||||||
virtual ~CommandBuilder() = default;
|
virtual ~CommandBuilder() = default;
|
||||||
|
|
||||||
virtual bool canMigrate(ProjectExplorer::BuildStepList*) { return false; }
|
virtual QList<Utils::Id> migratableSteps() const { return {}; }
|
||||||
|
|
||||||
ProjectExplorer::BuildStep *buildStep() const { return m_buildStep; }
|
ProjectExplorer::BuildStep *buildStep() const { return m_buildStep; }
|
||||||
|
|
||||||
|
@@ -30,6 +30,8 @@
|
|||||||
#include "makecommandbuilder.h"
|
#include "makecommandbuilder.h"
|
||||||
|
|
||||||
#include <projectexplorer/abstractprocessstep.h>
|
#include <projectexplorer/abstractprocessstep.h>
|
||||||
|
#include <projectexplorer/buildsteplist.h>
|
||||||
|
#include <projectexplorer/project.h>
|
||||||
|
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
#include <utils/pathchooser.h>
|
#include <utils/pathchooser.h>
|
||||||
@@ -69,7 +71,7 @@ public:
|
|||||||
&m_cmakeCommandBuilder
|
&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];
|
CommandBuilder *m_activeCommandBuilder = m_commandBuilders[0];
|
||||||
|
|
||||||
bool m_loadedFromMap = false;
|
bool m_loadedFromMap = false;
|
||||||
@@ -115,12 +117,17 @@ void CommandBuilderAspectPrivate::setActiveCommandBuilder(const QString &command
|
|||||||
|
|
||||||
void CommandBuilderAspectPrivate::tryToMigrate()
|
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.
|
// Attempt to detect build system from pre-existing steps.
|
||||||
for (CommandBuilder *p : m_commandBuilders) {
|
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;
|
m_activeCommandBuilder = p;
|
||||||
break;
|
bs->setEnabled(false);
|
||||||
|
m_buildStep->project()->saveSettings();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -34,6 +34,8 @@
|
|||||||
#include <projectexplorer/toolchain.h>
|
#include <projectexplorer/toolchain.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
|
|
||||||
|
#include <qmakeprojectmanager/qmakeprojectmanagerconstants.h> // Compile-time only
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
@@ -43,19 +45,9 @@ using namespace ProjectExplorer;
|
|||||||
namespace IncrediBuild {
|
namespace IncrediBuild {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
bool MakeCommandBuilder::canMigrate(BuildStepList *buildStepList)
|
QList<Utils::Id> MakeCommandBuilder::migratableSteps() const
|
||||||
{
|
{
|
||||||
// "Make"
|
return {QmakeProjectManager::Constants::MAKESTEP_BS_ID};
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MakeCommandBuilder::defaultCommand() const
|
QString MakeCommandBuilder::defaultCommand() const
|
||||||
|
@@ -36,7 +36,7 @@ public:
|
|||||||
MakeCommandBuilder(ProjectExplorer::BuildStep *buildStep) : CommandBuilder(buildStep) {}
|
MakeCommandBuilder(ProjectExplorer::BuildStep *buildStep) : CommandBuilder(buildStep) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool canMigrate(ProjectExplorer::BuildStepList *buildStepList) final;
|
QList<Utils::Id> migratableSteps() const final;
|
||||||
QString id() const final { return "MakeCommandBuilder"; }
|
QString id() const final { return "MakeCommandBuilder"; }
|
||||||
QString displayName() const final { return tr("Make"); }
|
QString displayName() const final { return tr("Make"); }
|
||||||
QString defaultCommand() const final;
|
QString defaultCommand() const final;
|
||||||
|
Reference in New Issue
Block a user