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:
hjk
2019-08-06 16:50:30 +02:00
parent 2521023627
commit 07a918c89a
26 changed files with 412 additions and 606 deletions

View File

@@ -32,5 +32,4 @@ add_qtc_plugin(QbsProjectManager
qbsprojectmanagerplugin.cpp qbsprojectmanagerplugin.h
qbsprojectmanagersettings.cpp qbsprojectmanagersettings.h
qbsprojectparser.cpp qbsprojectparser.h
qbsrunconfiguration.cpp qbsrunconfiguration.h
)

View File

@@ -29,7 +29,6 @@
#include "qbsproject.h"
#include "qbsprojectmanagerconstants.h"
#include "qbsprojectmanagerplugin.h"
#include "qbsrunconfiguration.h"
#include <android/androidconstants.h>
#include <coreplugin/fileiconprovider.h>

View File

@@ -37,8 +37,7 @@ HEADERS = \
qbsprojectmanagerconstants.h \
qbsprojectmanagerplugin.h \
qbsprojectmanagersettings.h \
qbsprojectparser.h \
qbsrunconfiguration.h
qbsprojectparser.h
SOURCES = \
customqbspropertiesdialog.cpp \
@@ -59,8 +58,7 @@ SOURCES = \
qbsprojectmanager.cpp \
qbsprojectmanagerplugin.cpp \
qbsprojectmanagersettings.cpp \
qbsprojectparser.cpp \
qbsrunconfiguration.cpp
qbsprojectparser.cpp
FORMS = \
customqbspropertiesdialog.ui \

View File

@@ -103,8 +103,6 @@ QtcPlugin {
"qbsprojectmanagersettings.h",
"qbsprojectparser.cpp",
"qbsprojectparser.h",
"qbsrunconfiguration.cpp",
"qbsrunconfiguration.h",
]
// QML typeinfo stuff

View File

@@ -35,7 +35,6 @@
#include "qbsproject.h"
#include "qbsprojectmanager.h"
#include "qbsprojectmanagerconstants.h"
#include "qbsrunconfiguration.h"
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h>
@@ -91,8 +90,6 @@ public:
QbsBuildStepFactory buildStepFactory;
QbsCleanStepFactory cleanStepFactory;
QbsInstallStepFactory installStepFactory;
QbsRunConfigurationFactory runConfigFactory;
SimpleRunWorkerFactory<SimpleTargetRunner, QbsRunConfiguration> runWorkerFactory;
QbsProfilesSettingsPage profilesSetttingsPage;
QbsKitAspect qbsKitAspect;
};

View File

@@ -1,170 +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 "qbsrunconfiguration.h"
#include "qbsnodes.h"
#include "qbspmlogging.h"
#include "qbsprojectmanagerconstants.h"
#include "qbsproject.h"
#include <projectexplorer/buildmanager.h>
#include <projectexplorer/deploymentdata.h>
#include <projectexplorer/localenvironmentaspect.h>
#include <projectexplorer/project.h>
#include <projectexplorer/runcontrol.h>
#include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/target.h>
#include <qtsupport/qtoutputformatter.h>
#include <QFileInfo>
using namespace ProjectExplorer;
using namespace Utils;
namespace QbsProjectManager {
namespace Internal {
// --------------------------------------------------------------------
// QbsRunConfiguration:
// --------------------------------------------------------------------
QbsRunConfiguration::QbsRunConfiguration(Target *target, Core::Id id)
: RunConfiguration(target, id)
{
auto envAspect = addAspect<LocalEnvironmentAspect>(target);
envAspect->addModifier([this](Environment &env) {
bool usingLibraryPaths = aspect<UseLibraryPathsAspect>()->value();
BuildTargetInfo bti = buildTargetInfo();
if (bti.runEnvModifier)
bti.runEnvModifier(env, usingLibraryPaths);
});
addAspect<ExecutableAspect>();
addAspect<ArgumentsAspect>();
addAspect<WorkingDirectoryAspect>();
addAspect<TerminalAspect>();
setOutputFormatter<QtSupport::QtOutputFormatter>();
auto libAspect = addAspect<UseLibraryPathsAspect>();
connect(libAspect, &UseLibraryPathsAspect::changed,
envAspect, &EnvironmentAspect::environmentChanged);
if (HostOsInfo::isMacHost()) {
auto dyldAspect = addAspect<UseDyldSuffixAspect>();
connect(dyldAspect, &UseDyldSuffixAspect::changed,
envAspect, &EnvironmentAspect::environmentChanged);
envAspect->addModifier([dyldAspect](Environment &env) {
if (dyldAspect->value())
env.set("DYLD_IMAGE_SUFFIX", "_debug");
});
}
connect(project(), &Project::parsingFinished,
envAspect, &EnvironmentAspect::environmentChanged);
connect(target, &Target::deploymentDataChanged,
this, &QbsRunConfiguration::updateTargetInformation);
connect(target, &Target::applicationTargetsChanged,
this, &QbsRunConfiguration::updateTargetInformation);
// Handles device changes, etc.
connect(target, &Target::kitChanged,
this, &QbsRunConfiguration::updateTargetInformation);
auto qbsProject = static_cast<QbsProject *>(target->project());
connect(qbsProject, &Project::parsingFinished,
this, &QbsRunConfiguration::updateTargetInformation);
}
QVariantMap QbsRunConfiguration::toMap() const
{
return RunConfiguration::toMap();
}
bool QbsRunConfiguration::fromMap(const QVariantMap &map)
{
if (!RunConfiguration::fromMap(map))
return false;
updateTargetInformation();
return true;
}
void QbsRunConfiguration::doAdditionalSetup(const RunConfigurationCreationInfo &info)
{
setDefaultDisplayName(info.displayName);
updateTargetInformation();
}
Utils::FilePath QbsRunConfiguration::executableToRun(const BuildTargetInfo &targetInfo) const
{
const FilePath appInBuildDir = targetInfo.targetFilePath;
if (target()->deploymentData().localInstallRoot().isEmpty())
return appInBuildDir;
const QString deployedAppFilePath = target()->deploymentData()
.deployableForLocalFile(appInBuildDir.toString()).remoteFilePath();
if (deployedAppFilePath.isEmpty())
return appInBuildDir;
const FilePath appInLocalInstallDir = target()->deploymentData().localInstallRoot()
+ deployedAppFilePath;
return appInLocalInstallDir.exists() ? appInLocalInstallDir : appInBuildDir;
}
void QbsRunConfiguration::updateTargetInformation()
{
BuildTargetInfo bti = buildTargetInfo();
setDefaultDisplayName(bti.displayName);
const FilePath executable = executableToRun(bti);
auto terminalAspect = aspect<TerminalAspect>();
terminalAspect->setUseTerminalHint(bti.usesTerminal);
aspect<ExecutableAspect>()->setExecutable(executable);
if (!executable.isEmpty()) {
QString defaultWorkingDir = QFileInfo(executable.toString()).absolutePath();
if (!defaultWorkingDir.isEmpty()) {
auto wdAspect = aspect<WorkingDirectoryAspect>();
wdAspect->setDefaultWorkingDirectory(FilePath::fromString(defaultWorkingDir));
}
}
emit enabledChanged();
}
// --------------------------------------------------------------------
// QbsRunConfigurationFactory:
// --------------------------------------------------------------------
QbsRunConfigurationFactory::QbsRunConfigurationFactory()
{
registerRunConfiguration<QbsRunConfiguration>("Qbs.RunConfiguration:");
addSupportedProjectType(Constants::PROJECT_ID);
addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
}
} // namespace Internal
} // namespace QbsProjectManager

View File

@@ -1,60 +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>
#include <QHash>
#include <QPair>
#include <QStringList>
namespace QbsProjectManager {
namespace Internal {
class QbsRunConfiguration : public ProjectExplorer::RunConfiguration
{
Q_OBJECT
public:
QbsRunConfiguration(ProjectExplorer::Target *target, Core::Id id);
private:
Utils::FilePath executableToRun(const ProjectExplorer::BuildTargetInfo &targetInfo) const;
QVariantMap toMap() const final;
bool fromMap(const QVariantMap &map) final;
void doAdditionalSetup(const ProjectExplorer::RunConfigurationCreationInfo &rci) final;
void updateTargetInformation();
};
class QbsRunConfigurationFactory : public ProjectExplorer::RunConfigurationFactory
{
public:
QbsRunConfigurationFactory();
};
} // namespace Internal
} // namespace QbsProjectManager