forked from qt-creator/qt-creator
Unification of desktop run configurations, step 1
First step, move {DesktopQt,Qbs,CMake}RunConfiguration{,Factory}
into the same new files.
This only moves down to QtSupport, not ProjectExplorer, as there
are in all three cases direct dependencies on QtSupport. Long term
I would expect them to move further down.
Change-Id: Ib16b19df7f3f642ed7f7db89a1f6904601d976ba
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -28,7 +28,6 @@ add_qtc_plugin(CMakeProjectManager
|
||||
cmakeprojectmanager.cpp cmakeprojectmanager.h
|
||||
cmakeprojectnodes.cpp cmakeprojectnodes.h
|
||||
cmakeprojectplugin.cpp cmakeprojectplugin.h
|
||||
cmakerunconfiguration.cpp cmakerunconfiguration.h
|
||||
cmakesettingspage.cpp cmakesettingspage.h
|
||||
cmakespecificsettings.cpp cmakespecificsettings.h
|
||||
cmakespecificsettingspage.cpp cmakespecificsettingspage.h cmakespecificsettingspage.ui
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "cmakeparser.h"
|
||||
#include "cmakeprojectconstants.h"
|
||||
#include "cmakeproject.h"
|
||||
#include "cmakerunconfiguration.h"
|
||||
#include "cmaketool.h"
|
||||
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
@@ -105,11 +104,6 @@ CMakeBuildConfiguration *CMakeBuildStep::cmakeBuildConfiguration() const
|
||||
return static_cast<CMakeBuildConfiguration *>(buildConfiguration());
|
||||
}
|
||||
|
||||
CMakeRunConfiguration *CMakeBuildStep::targetsActiveRunConfiguration() const
|
||||
{
|
||||
return qobject_cast<CMakeRunConfiguration *>(target()->activeRunConfiguration());
|
||||
}
|
||||
|
||||
void CMakeBuildStep::handleBuildTargetChanges(bool success)
|
||||
{
|
||||
if (!success)
|
||||
@@ -169,7 +163,7 @@ bool CMakeBuildStep::init()
|
||||
canInit = false;
|
||||
}
|
||||
|
||||
CMakeRunConfiguration *rc = targetsActiveRunConfiguration();
|
||||
RunConfiguration *rc = target()->activeRunConfiguration();
|
||||
if (isCurrentExecutableTarget(m_buildTarget) && (!rc || rc->buildKey().isEmpty())) {
|
||||
emit addTask(Task(Task::Error,
|
||||
QCoreApplication::translate("ProjectExplorer::Task",
|
||||
@@ -347,7 +341,7 @@ void CMakeBuildStep::setToolArguments(const QString &list)
|
||||
m_toolArguments = list;
|
||||
}
|
||||
|
||||
Utils::CommandLine CMakeBuildStep::cmakeCommand(CMakeRunConfiguration *rc) const
|
||||
Utils::CommandLine CMakeBuildStep::cmakeCommand(RunConfiguration *rc) const
|
||||
{
|
||||
CMakeTool *tool = CMakeKitAspect::cmakeTool(target()->kit());
|
||||
|
||||
|
||||
@@ -40,13 +40,15 @@ class CommandLine;
|
||||
class PathChooser;
|
||||
} // Utils
|
||||
|
||||
namespace ProjectExplorer { class ToolChain; }
|
||||
namespace ProjectExplorer {
|
||||
class RunConfiguration;
|
||||
class ToolChain;
|
||||
} // ProjectManager
|
||||
|
||||
namespace CMakeProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
class CMakeBuildConfiguration;
|
||||
class CMakeRunConfiguration;
|
||||
class CMakeBuildStepFactory;
|
||||
|
||||
class CMakeBuildStep : public ProjectExplorer::AbstractProcessStep
|
||||
@@ -67,7 +69,7 @@ public:
|
||||
QString toolArguments() const;
|
||||
void setToolArguments(const QString &list);
|
||||
|
||||
Utils::CommandLine cmakeCommand(CMakeRunConfiguration *rc) const;
|
||||
Utils::CommandLine cmakeCommand(ProjectExplorer::RunConfiguration *rc) const;
|
||||
|
||||
QVariantMap toMap() const override;
|
||||
|
||||
@@ -104,7 +106,6 @@ private:
|
||||
void handleProjectWasParsed(bool success);
|
||||
|
||||
void handleBuildTargetChanges(bool success);
|
||||
CMakeRunConfiguration *targetsActiveRunConfiguration() const;
|
||||
|
||||
QMetaObject::Connection m_runTrigger;
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ HEADERS = builddirmanager.h \
|
||||
cmakeprojectmanager.h \
|
||||
cmakeprojectconstants.h \
|
||||
cmakeprojectnodes.h \
|
||||
cmakerunconfiguration.h \
|
||||
cmakebuildconfiguration.h \
|
||||
cmakeeditor.h \
|
||||
cmakelocatorfilter.h \
|
||||
@@ -53,7 +52,6 @@ SOURCES = builddirmanager.cpp \
|
||||
cmakeprojectplugin.cpp \
|
||||
cmakeprojectmanager.cpp \
|
||||
cmakeprojectnodes.cpp \
|
||||
cmakerunconfiguration.cpp \
|
||||
cmakebuildconfiguration.cpp \
|
||||
cmakeeditor.cpp \
|
||||
cmakelocatorfilter.cpp \
|
||||
|
||||
@@ -61,8 +61,6 @@ QtcPlugin {
|
||||
"cmakeprojectnodes.h",
|
||||
"cmakeprojectplugin.cpp",
|
||||
"cmakeprojectplugin.h",
|
||||
"cmakerunconfiguration.cpp",
|
||||
"cmakerunconfiguration.h",
|
||||
"cmaketool.cpp",
|
||||
"cmaketool.h",
|
||||
"cmaketoolmanager.cpp",
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "cmakeprojectmanager.h"
|
||||
#include "cmakeprojectnodes.h"
|
||||
#include "cmakebuildconfiguration.h"
|
||||
#include "cmakerunconfiguration.h"
|
||||
#include "cmakeprojectconstants.h"
|
||||
#include "cmakelocatorfilter.h"
|
||||
#include "cmakesettingspage.h"
|
||||
@@ -71,8 +70,6 @@ public:
|
||||
static const std::unique_ptr<CMakeSpecificSettings> projectTypeSpecificSettings;
|
||||
CMakeManager manager;
|
||||
CMakeBuildStepFactory buildStepFactory;
|
||||
CMakeRunConfigurationFactory runConfigFactory;
|
||||
SimpleRunWorkerFactory<SimpleTargetRunner, CMakeRunConfiguration> runWorkerFactory;
|
||||
CMakeBuildConfigurationFactory buildConfigFactory;
|
||||
CMakeEditorFactory editorFactor;
|
||||
BuildCMakeTargetLocatorFilter buildCMakeTargetLocatorFilter;
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cmakerunconfiguration.h"
|
||||
|
||||
#include "cmakeprojectconstants.h"
|
||||
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <qtsupport/qtoutputformatter.h>
|
||||
|
||||
#include <projectexplorer/localenvironmentaspect.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/runconfigurationaspects.h>
|
||||
#include <projectexplorer/runcontrol.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace CMakeProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
CMakeRunConfiguration::CMakeRunConfiguration(Target *target, Core::Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
auto envAspect = addAspect<LocalEnvironmentAspect>(target);
|
||||
|
||||
// Workaround for QTCREATORBUG-19354:
|
||||
if (HostOsInfo::isWindowsHost()) {
|
||||
envAspect->addModifier([target](Environment &env) {
|
||||
const Kit *k = target->kit();
|
||||
if (const QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(k)) {
|
||||
const QString installBinPath = qt->qmakeProperty("QT_INSTALL_BINS");
|
||||
env.prependOrSetPath(installBinPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
addAspect<ExecutableAspect>();
|
||||
addAspect<ArgumentsAspect>();
|
||||
addAspect<WorkingDirectoryAspect>();
|
||||
addAspect<TerminalAspect>();
|
||||
|
||||
connect(target->project(), &Project::parsingFinished,
|
||||
this, &CMakeRunConfiguration::updateTargetInformation);
|
||||
|
||||
if (QtSupport::QtKitAspect::qtVersion(target->kit()))
|
||||
setOutputFormatter<QtSupport::QtOutputFormatter>();
|
||||
}
|
||||
|
||||
void CMakeRunConfiguration::doAdditionalSetup(const RunConfigurationCreationInfo &info)
|
||||
{
|
||||
Q_UNUSED(info)
|
||||
updateTargetInformation();
|
||||
}
|
||||
|
||||
bool CMakeRunConfiguration::isBuildTargetValid() const
|
||||
{
|
||||
return Utils::anyOf(target()->applicationTargets(), [this](const BuildTargetInfo &bti) {
|
||||
return bti.buildKey == buildKey();
|
||||
});
|
||||
}
|
||||
|
||||
void CMakeRunConfiguration::updateEnabledState()
|
||||
{
|
||||
if (!isBuildTargetValid())
|
||||
setEnabled(false);
|
||||
else
|
||||
RunConfiguration::updateEnabledState();
|
||||
}
|
||||
|
||||
QString CMakeRunConfiguration::disabledReason() const
|
||||
{
|
||||
if (!isBuildTargetValid())
|
||||
return tr("The project no longer builds the target associated with this run configuration.");
|
||||
return RunConfiguration::disabledReason();
|
||||
}
|
||||
|
||||
void CMakeRunConfiguration::updateTargetInformation()
|
||||
{
|
||||
BuildTargetInfo bti = buildTargetInfo();
|
||||
aspect<ExecutableAspect>()->setExecutable(bti.targetFilePath);
|
||||
aspect<WorkingDirectoryAspect>()->setDefaultWorkingDirectory(bti.workingDirectory);
|
||||
aspect<LocalEnvironmentAspect>()->environmentChanged();
|
||||
|
||||
auto terminalAspect = aspect<TerminalAspect>();
|
||||
terminalAspect->setUseTerminalHint(bti.usesTerminal);
|
||||
}
|
||||
|
||||
// Factory
|
||||
CMakeRunConfigurationFactory::CMakeRunConfigurationFactory()
|
||||
{
|
||||
registerRunConfiguration<CMakeRunConfiguration>("CMakeProjectManager.CMakeRunConfiguration.");
|
||||
addSupportedProjectType(CMakeProjectManager::Constants::CMAKEPROJECT_ID);
|
||||
addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
|
||||
}
|
||||
|
||||
} // Internal
|
||||
} // CMakeProjectManager
|
||||
@@ -1,57 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
|
||||
namespace CMakeProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
class CMakeRunConfiguration : public ProjectExplorer::RunConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CMakeRunConfiguration(ProjectExplorer::Target *target, Core::Id id);
|
||||
|
||||
private:
|
||||
QString disabledReason() const override;
|
||||
|
||||
void doAdditionalSetup(const ProjectExplorer::RunConfigurationCreationInfo &) override;
|
||||
bool isBuildTargetValid() const;
|
||||
void updateTargetInformation();
|
||||
|
||||
void updateEnabledState() final;
|
||||
};
|
||||
|
||||
class CMakeRunConfigurationFactory : public ProjectExplorer::RunConfigurationFactory
|
||||
{
|
||||
public:
|
||||
CMakeRunConfigurationFactory();
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CMakeProjectManager
|
||||
Reference in New Issue
Block a user