forked from qt-creator/qt-creator
AppMan: Use new setup pattern for run related factories
Change-Id: I416d9a5f0b83770c7ef7673f499ed2f6b4529197 Reviewed-by: Dominik Holland <dominik.holland@qt.io>
This commit is contained in:
@@ -18,19 +18,7 @@
|
|||||||
|
|
||||||
namespace AppManager::Internal {
|
namespace AppManager::Internal {
|
||||||
|
|
||||||
class AppManagerPluginPrivate
|
AppManagerPlugin::~AppManagerPlugin() = default;
|
||||||
{
|
|
||||||
public:
|
|
||||||
AppManagerRunConfigurationFactory runConfigFactory;
|
|
||||||
AppManagerRunWorkerFactory runWorkerFactory;
|
|
||||||
AppManagerDebugWorkerFactory debugWorkerFactory;
|
|
||||||
AppManagerQmlToolingWorkerFactory toolingWorkerFactory;
|
|
||||||
};
|
|
||||||
|
|
||||||
AppManagerPlugin::~AppManagerPlugin()
|
|
||||||
{
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppManagerPlugin::initialize()
|
void AppManagerPlugin::initialize()
|
||||||
{
|
{
|
||||||
@@ -44,7 +32,11 @@ void AppManagerPlugin::initialize()
|
|||||||
setupAppManagerDeployConfiguration();
|
setupAppManagerDeployConfiguration();
|
||||||
setupAppManagerDeployConfigurationAutoSwitcher();
|
setupAppManagerDeployConfigurationAutoSwitcher();
|
||||||
|
|
||||||
d = new AppManagerPluginPrivate;
|
setupAppManagerRunConfiguration();
|
||||||
|
|
||||||
|
setupAppManagerRunWorker();
|
||||||
|
setupAppManagerDebugWorker();
|
||||||
|
setupAppManagerQmlToolingWorker();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // AppManager::Internal
|
} // AppManager::Internal
|
||||||
|
|||||||
@@ -7,9 +7,8 @@
|
|||||||
|
|
||||||
#include "appmanagerconstants.h"
|
#include "appmanagerconstants.h"
|
||||||
#include "appmanagertargetinformation.h"
|
#include "appmanagertargetinformation.h"
|
||||||
|
#include "appmanagertr.h"
|
||||||
|
|
||||||
#include <projectexplorer/buildsystem.h>
|
|
||||||
#include <projectexplorer/project.h>
|
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
|
|
||||||
@@ -18,72 +17,76 @@
|
|||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/filesystemwatcher.h>
|
#include <utils/filesystemwatcher.h>
|
||||||
|
|
||||||
#include <qtsupport/baseqtversion.h>
|
|
||||||
#include <qtsupport/qtkitaspect.h>
|
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace AppManager {
|
namespace AppManager::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
AppManagerRunConfiguration::AppManagerRunConfiguration(Target *target, Id id)
|
class AppManagerRunConfiguration final : public RunConfiguration
|
||||||
: RunConfiguration(target, id)
|
|
||||||
{
|
|
||||||
setDefaultDisplayName(tr("Run on AM Device"));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AppManagerRunConfiguration::disabledReason() const
|
|
||||||
{
|
|
||||||
if (activeBuildSystem()->isParsing())
|
|
||||||
return tr("The project file \"%1\" is currently being parsed.").arg(project()->projectFilePath().toString());
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
class AppManagerRunConfigurationFactoryPrivate
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FileSystemWatcher fileSystemWatcher;
|
AppManagerRunConfiguration(Target *target, Id id)
|
||||||
|
: RunConfiguration(target, id)
|
||||||
|
{
|
||||||
|
setDefaultDisplayName(Tr::tr("Run on AM Device"));
|
||||||
|
}
|
||||||
|
|
||||||
|
QString disabledReason() const override
|
||||||
|
{
|
||||||
|
if (activeBuildSystem()->isParsing()) {
|
||||||
|
return Tr::tr("The project file \"%1\" is currently being parsed.")
|
||||||
|
.arg(project()->projectFilePath().toString());
|
||||||
|
}
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
AppManagerRunConfigurationFactory::AppManagerRunConfigurationFactory()
|
class AppManagerRunConfigurationFactory final : public RunConfigurationFactory
|
||||||
: RunConfigurationFactory()
|
|
||||||
, d(new AppManagerRunConfigurationFactoryPrivate())
|
|
||||||
{
|
{
|
||||||
registerRunConfiguration<AppManagerRunConfiguration>(Constants::RUNCONFIGURATION_ID);
|
public:
|
||||||
addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
|
AppManagerRunConfigurationFactory()
|
||||||
addSupportedTargetDeviceType(RemoteLinux::Constants::GenericLinuxOsType);
|
{
|
||||||
|
registerRunConfiguration<AppManagerRunConfiguration>(Constants::RUNCONFIGURATION_ID);
|
||||||
|
addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
|
||||||
|
addSupportedTargetDeviceType(RemoteLinux::Constants::GenericLinuxOsType);
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<RunConfigurationCreationInfo> availableCreators(Target *target) const final
|
||||||
|
{
|
||||||
|
QObject::connect(&m_fileSystemWatcher, &FileSystemWatcher::fileChanged,
|
||||||
|
target->project(), &Project::displayNameChanged,
|
||||||
|
Qt::UniqueConnection);
|
||||||
|
|
||||||
|
const auto buildTargets = TargetInformation::readFromProject(target);
|
||||||
|
auto result = Utils::transform(buildTargets, [this, target](const TargetInformation &ti) {
|
||||||
|
|
||||||
|
QVariantMap settings;
|
||||||
|
// ti.buildKey is currently our app id
|
||||||
|
settings.insert("id", ti.buildKey);
|
||||||
|
target->setNamedSettings("runConfigurationSettings", settings);
|
||||||
|
|
||||||
|
RunConfigurationCreationInfo rci;
|
||||||
|
rci.factory = this;
|
||||||
|
rci.buildKey = ti.buildKey;
|
||||||
|
rci.displayName = ti.displayName;
|
||||||
|
rci.displayNameUniquifier = ti.displayNameUniquifier;
|
||||||
|
rci.creationMode = RunConfigurationCreationInfo::AlwaysCreate;
|
||||||
|
rci.useTerminal = false;
|
||||||
|
if (!m_fileSystemWatcher.files().contains(ti.manifest.fileName)) {
|
||||||
|
m_fileSystemWatcher.addFile(ti.manifest.fileName, FileSystemWatcher::WatchAllChanges);
|
||||||
|
}
|
||||||
|
return rci;
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
mutable FileSystemWatcher m_fileSystemWatcher;
|
||||||
|
};
|
||||||
|
|
||||||
|
void setupAppManagerRunConfiguration()
|
||||||
|
{
|
||||||
|
static AppManagerRunConfigurationFactory theAppManagerRunConfigurationFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
AppManagerRunConfigurationFactory::~AppManagerRunConfigurationFactory() = default;
|
} // AppManager::Internal
|
||||||
|
|
||||||
QList<RunConfigurationCreationInfo> AppManagerRunConfigurationFactory::availableCreators(Target *target) const
|
|
||||||
{
|
|
||||||
QObject::connect(&d->fileSystemWatcher, &FileSystemWatcher::fileChanged, target->project(), &Project::displayNameChanged, Qt::UniqueConnection);
|
|
||||||
|
|
||||||
const auto buildTargets = TargetInformation::readFromProject(target);
|
|
||||||
auto result = Utils::transform(buildTargets, [this, target](const TargetInformation &ti) {
|
|
||||||
|
|
||||||
QVariantMap settings;
|
|
||||||
// ti.buildKey is currently our app id
|
|
||||||
settings.insert("id", ti.buildKey);
|
|
||||||
target->setNamedSettings("runConfigurationSettings", settings);
|
|
||||||
|
|
||||||
RunConfigurationCreationInfo rci;
|
|
||||||
rci.factory = this;
|
|
||||||
rci.buildKey = ti.buildKey;
|
|
||||||
rci.displayName = ti.displayName;
|
|
||||||
rci.displayNameUniquifier = ti.displayNameUniquifier;
|
|
||||||
rci.creationMode = RunConfigurationCreationInfo::AlwaysCreate;
|
|
||||||
rci.useTerminal = false;
|
|
||||||
if (!this->d->fileSystemWatcher.files().contains(ti.manifest.fileName)) {
|
|
||||||
this->d->fileSystemWatcher.addFile(ti.manifest.fileName, Utils::FileSystemWatcher::WatchAllChanges);
|
|
||||||
}
|
|
||||||
return rci;
|
|
||||||
});
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace AppManager
|
|
||||||
|
|||||||
@@ -5,36 +5,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <projectexplorer/runconfigurationaspects.h>
|
namespace AppManager::Internal {
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
void setupAppManagerRunConfiguration();
|
||||||
|
|
||||||
namespace AppManager {
|
} // AppManager::Internal
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class AppManagerRunConfiguration : public ProjectExplorer::RunConfiguration
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
AppManagerRunConfiguration(ProjectExplorer::Target *target, Utils::Id id);
|
|
||||||
|
|
||||||
QString disabledReason() const override;
|
|
||||||
};
|
|
||||||
|
|
||||||
class AppManagerRunConfigurationFactoryPrivate;
|
|
||||||
|
|
||||||
class AppManagerRunConfigurationFactory : public ProjectExplorer::RunConfigurationFactory
|
|
||||||
{
|
|
||||||
QScopedPointer<AppManagerRunConfigurationFactoryPrivate> d;
|
|
||||||
|
|
||||||
public:
|
|
||||||
AppManagerRunConfigurationFactory();
|
|
||||||
~AppManagerRunConfigurationFactory() override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
QList<ProjectExplorer::RunConfigurationCreationInfo> availableCreators(ProjectExplorer::Target *parent) const override;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace AppManager
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "appmanagerconstants.h"
|
#include "appmanagerconstants.h"
|
||||||
#include "appmanagertargetinformation.h"
|
#include "appmanagertargetinformation.h"
|
||||||
|
#include "appmanagertr.h"
|
||||||
#include "appmanagerutilities.h"
|
#include "appmanagerutilities.h"
|
||||||
|
|
||||||
#include <debugger/debuggerengine.h>
|
#include <debugger/debuggerengine.h>
|
||||||
@@ -19,7 +20,7 @@
|
|||||||
#include <projectexplorer/buildtargetinfo.h>
|
#include <projectexplorer/buildtargetinfo.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/runcontrol.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
#include <projectexplorer/toolchain.h>
|
#include <projectexplorer/toolchain.h>
|
||||||
|
|
||||||
@@ -38,7 +39,7 @@ namespace AppManager::Internal {
|
|||||||
|
|
||||||
// AppManagerRunner
|
// AppManagerRunner
|
||||||
|
|
||||||
class AppManagerRunner : public SimpleTargetRunner
|
class AppManagerRunner final : public SimpleTargetRunner
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AppManagerRunner(RunControl *runControl)
|
AppManagerRunner(RunControl *runControl)
|
||||||
@@ -46,7 +47,7 @@ public:
|
|||||||
{
|
{
|
||||||
setId("ApplicationManagerPlugin.Run.TargetRunner");
|
setId("ApplicationManagerPlugin.Run.TargetRunner");
|
||||||
connect(this, &RunWorker::stopped, this, [this, runControl] {
|
connect(this, &RunWorker::stopped, this, [this, runControl] {
|
||||||
appendMessage(tr("%1 exited").arg(runControl->runnable().command.toUserOutput()),
|
appendMessage(Tr::tr("%1 exited").arg(runControl->runnable().command.toUserOutput()),
|
||||||
OutputFormat::NormalMessageFormat);
|
OutputFormat::NormalMessageFormat);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -143,8 +144,8 @@ public:
|
|||||||
setCommandLine(cmd);
|
setCommandLine(cmd);
|
||||||
setWorkingDirectory(targetInformation.workingDirectory());
|
setWorkingDirectory(targetInformation.workingDirectory());
|
||||||
|
|
||||||
appendMessage(tr("Starting AppMan Debugging..."), NormalMessageFormat);
|
appendMessage(Tr::tr("Starting AppMan Debugging..."), NormalMessageFormat);
|
||||||
appendMessage(tr("Using: %1").arg(cmd.toUserOutput()), NormalMessageFormat);
|
appendMessage(Tr::tr("Using: %1").arg(cmd.toUserOutput()), NormalMessageFormat);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +165,7 @@ private:
|
|||||||
|
|
||||||
// AppManagerDebugSupport
|
// AppManagerDebugSupport
|
||||||
|
|
||||||
class AppManagerDebugSupport : public Debugger::DebuggerRunTool
|
class AppManagerDebugSupport final : public Debugger::DebuggerRunTool
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
QString m_symbolFile;
|
QString m_symbolFile;
|
||||||
@@ -202,7 +203,7 @@ public:
|
|||||||
return ti.buildKey == targetInformation.manifest.code || ti.projectFilePath.toString() == targetInformation.manifest.code;
|
return ti.buildKey == targetInformation.manifest.code || ti.projectFilePath.toString() == targetInformation.manifest.code;
|
||||||
}).targetFilePath.toString();
|
}).targetFilePath.toString();
|
||||||
} else {
|
} else {
|
||||||
reportFailure(tr("Cannot debug: Only QML and native applications are supported."));
|
reportFailure(Tr::tr("Cannot debug: Only QML and native applications are supported."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,60 +250,82 @@ private:
|
|||||||
class AppManagerQmlToolingSupport final : public RunWorker
|
class AppManagerQmlToolingSupport final : public RunWorker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit AppManagerQmlToolingSupport(RunControl *runControl);
|
explicit AppManagerQmlToolingSupport(RunControl *runControl)
|
||||||
|
: RunWorker(runControl)
|
||||||
|
{
|
||||||
|
setId("AppManagerQmlToolingSupport");
|
||||||
|
|
||||||
|
QmlDebug::QmlDebugServicesPreset services = QmlDebug::servicesForRunMode(runControl->runMode());
|
||||||
|
m_runner = new AppManInferiorRunner(runControl, false, false, true, services);
|
||||||
|
addStartDependency(m_runner);
|
||||||
|
addStopDependency(m_runner);
|
||||||
|
|
||||||
|
m_worker = runControl->createWorker(QmlDebug::runnerIdForRunMode(runControl->runMode()));
|
||||||
|
m_worker->addStartDependency(this);
|
||||||
|
addStopDependency(m_worker);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void start() override;
|
void start() final
|
||||||
|
{
|
||||||
|
m_worker->recordData("QmlServerUrl", m_runner->qmlServer());
|
||||||
|
reportStarted();
|
||||||
|
}
|
||||||
|
|
||||||
AppManInferiorRunner *m_runner = nullptr;
|
AppManInferiorRunner *m_runner = nullptr;
|
||||||
RunWorker *m_worker = nullptr;
|
RunWorker *m_worker = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
AppManagerQmlToolingSupport::AppManagerQmlToolingSupport(RunControl *runControl)
|
|
||||||
: RunWorker(runControl)
|
|
||||||
{
|
|
||||||
setId("AppManagerQmlToolingSupport");
|
|
||||||
|
|
||||||
QmlDebug::QmlDebugServicesPreset services = QmlDebug::servicesForRunMode(runControl->runMode());
|
|
||||||
m_runner = new AppManInferiorRunner(runControl, false, false, true, services);
|
|
||||||
addStartDependency(m_runner);
|
|
||||||
addStopDependency(m_runner);
|
|
||||||
|
|
||||||
m_worker = runControl->createWorker(QmlDebug::runnerIdForRunMode(runControl->runMode()));
|
|
||||||
m_worker->addStartDependency(this);
|
|
||||||
addStopDependency(m_worker);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppManagerQmlToolingSupport::start()
|
|
||||||
{
|
|
||||||
m_worker->recordData("QmlServerUrl", m_runner->qmlServer());
|
|
||||||
reportStarted();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Factories
|
// Factories
|
||||||
|
|
||||||
AppManagerRunWorkerFactory::AppManagerRunWorkerFactory()
|
class AppManagerRunWorkerFactory final : public RunWorkerFactory
|
||||||
{
|
{
|
||||||
setProduct<AppManagerRunner>();
|
public:
|
||||||
addSupportedRunMode(ProjectExplorer::Constants::NORMAL_RUN_MODE);
|
AppManagerRunWorkerFactory()
|
||||||
addSupportedRunConfig(Constants::RUNCONFIGURATION_ID);
|
{
|
||||||
|
setProduct<AppManagerRunner>();
|
||||||
|
addSupportedRunMode(ProjectExplorer::Constants::NORMAL_RUN_MODE);
|
||||||
|
addSupportedRunConfig(Constants::RUNCONFIGURATION_ID);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class AppManagerDebugWorkerFactory final : public RunWorkerFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AppManagerDebugWorkerFactory()
|
||||||
|
{
|
||||||
|
setProduct<AppManagerDebugSupport>();
|
||||||
|
addSupportedRunMode(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||||
|
addSupportedRunConfig(Constants::RUNCONFIGURATION_ID);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class AppManagerQmlToolingWorkerFactory final : public RunWorkerFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AppManagerQmlToolingWorkerFactory()
|
||||||
|
{
|
||||||
|
setProduct<AppManagerQmlToolingSupport>();
|
||||||
|
addSupportedRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||||
|
addSupportedRunMode(ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE);
|
||||||
|
addSupportedRunConfig(Constants::RUNCONFIGURATION_ID);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void setupAppManagerRunWorker()
|
||||||
|
{
|
||||||
|
static AppManagerRunWorkerFactory theAppManagerRunWorkerFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
AppManagerDebugWorkerFactory::AppManagerDebugWorkerFactory()
|
void setupAppManagerDebugWorker()
|
||||||
{
|
{
|
||||||
setProduct<AppManagerDebugSupport>();
|
static AppManagerDebugWorkerFactory theAppManagerDebugWorkerFactory;
|
||||||
addSupportedRunMode(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
|
||||||
addSupportedRunConfig(Constants::RUNCONFIGURATION_ID);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AppManagerQmlToolingWorkerFactory::AppManagerQmlToolingWorkerFactory()
|
void setupAppManagerQmlToolingWorker()
|
||||||
{
|
{
|
||||||
setProduct<AppManagerQmlToolingSupport>();
|
static AppManagerQmlToolingWorkerFactory theAppManagerQmlToolingWorkerFactory;
|
||||||
addSupportedRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
|
||||||
addSupportedRunMode(ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE);
|
|
||||||
addSupportedRunConfig(Constants::RUNCONFIGURATION_ID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // AppManager::Internal
|
} // AppManager::Internal
|
||||||
|
|||||||
@@ -5,28 +5,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <projectexplorer/runcontrol.h>
|
namespace AppManager::Internal {
|
||||||
|
|
||||||
namespace AppManager {
|
void setupAppManagerRunWorker();
|
||||||
namespace Internal {
|
void setupAppManagerDebugWorker();
|
||||||
|
void setupAppManagerQmlToolingWorker();
|
||||||
|
|
||||||
class AppManagerRunWorkerFactory : public ProjectExplorer::RunWorkerFactory
|
} // AppManager::Internal
|
||||||
{
|
|
||||||
public:
|
|
||||||
AppManagerRunWorkerFactory();
|
|
||||||
};
|
|
||||||
|
|
||||||
class AppManagerDebugWorkerFactory : public ProjectExplorer::RunWorkerFactory
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AppManagerDebugWorkerFactory();
|
|
||||||
};
|
|
||||||
|
|
||||||
class AppManagerQmlToolingWorkerFactory : public ProjectExplorer::RunWorkerFactory
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AppManagerQmlToolingWorkerFactory();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace AppManager
|
|
||||||
|
|||||||
Reference in New Issue
Block a user