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 {
|
||||
|
||||
class AppManagerPluginPrivate
|
||||
{
|
||||
public:
|
||||
AppManagerRunConfigurationFactory runConfigFactory;
|
||||
AppManagerRunWorkerFactory runWorkerFactory;
|
||||
AppManagerDebugWorkerFactory debugWorkerFactory;
|
||||
AppManagerQmlToolingWorkerFactory toolingWorkerFactory;
|
||||
};
|
||||
|
||||
AppManagerPlugin::~AppManagerPlugin()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
AppManagerPlugin::~AppManagerPlugin() = default;
|
||||
|
||||
void AppManagerPlugin::initialize()
|
||||
{
|
||||
@@ -44,7 +32,11 @@ void AppManagerPlugin::initialize()
|
||||
setupAppManagerDeployConfiguration();
|
||||
setupAppManagerDeployConfigurationAutoSwitcher();
|
||||
|
||||
d = new AppManagerPluginPrivate;
|
||||
setupAppManagerRunConfiguration();
|
||||
|
||||
setupAppManagerRunWorker();
|
||||
setupAppManagerDebugWorker();
|
||||
setupAppManagerQmlToolingWorker();
|
||||
}
|
||||
|
||||
} // AppManager::Internal
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
|
||||
#include "appmanagerconstants.h"
|
||||
#include "appmanagertargetinformation.h"
|
||||
#include "appmanagertr.h"
|
||||
|
||||
#include <projectexplorer/buildsystem.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
@@ -18,48 +17,45 @@
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/filesystemwatcher.h>
|
||||
|
||||
#include <qtsupport/baseqtversion.h>
|
||||
#include <qtsupport/qtkitaspect.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace AppManager {
|
||||
namespace Internal {
|
||||
namespace AppManager::Internal {
|
||||
|
||||
AppManagerRunConfiguration::AppManagerRunConfiguration(Target *target, Id id)
|
||||
: 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
|
||||
class AppManagerRunConfiguration final : public RunConfiguration
|
||||
{
|
||||
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()
|
||||
: RunConfigurationFactory()
|
||||
, d(new AppManagerRunConfigurationFactoryPrivate())
|
||||
class AppManagerRunConfigurationFactory final : public RunConfigurationFactory
|
||||
{
|
||||
public:
|
||||
AppManagerRunConfigurationFactory()
|
||||
{
|
||||
registerRunConfiguration<AppManagerRunConfiguration>(Constants::RUNCONFIGURATION_ID);
|
||||
addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
|
||||
addSupportedTargetDeviceType(RemoteLinux::Constants::GenericLinuxOsType);
|
||||
}
|
||||
}
|
||||
|
||||
AppManagerRunConfigurationFactory::~AppManagerRunConfigurationFactory() = default;
|
||||
|
||||
QList<RunConfigurationCreationInfo> AppManagerRunConfigurationFactory::availableCreators(Target *target) const
|
||||
{
|
||||
QObject::connect(&d->fileSystemWatcher, &FileSystemWatcher::fileChanged, target->project(), &Project::displayNameChanged, Qt::UniqueConnection);
|
||||
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) {
|
||||
@@ -76,14 +72,21 @@ QList<RunConfigurationCreationInfo> AppManagerRunConfigurationFactory::available
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace AppManager
|
||||
} // AppManager::Internal
|
||||
|
||||
@@ -5,36 +5,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/runconfigurationaspects.h>
|
||||
namespace AppManager::Internal {
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
void setupAppManagerRunConfiguration();
|
||||
|
||||
namespace AppManager {
|
||||
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
|
||||
} // AppManager::Internal
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "appmanagerconstants.h"
|
||||
#include "appmanagertargetinformation.h"
|
||||
#include "appmanagertr.h"
|
||||
#include "appmanagerutilities.h"
|
||||
|
||||
#include <debugger/debuggerengine.h>
|
||||
@@ -19,7 +20,7 @@
|
||||
#include <projectexplorer/buildtargetinfo.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/runcontrol.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
|
||||
@@ -38,7 +39,7 @@ namespace AppManager::Internal {
|
||||
|
||||
// AppManagerRunner
|
||||
|
||||
class AppManagerRunner : public SimpleTargetRunner
|
||||
class AppManagerRunner final : public SimpleTargetRunner
|
||||
{
|
||||
public:
|
||||
AppManagerRunner(RunControl *runControl)
|
||||
@@ -46,7 +47,7 @@ public:
|
||||
{
|
||||
setId("ApplicationManagerPlugin.Run.TargetRunner");
|
||||
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);
|
||||
});
|
||||
|
||||
@@ -143,8 +144,8 @@ public:
|
||||
setCommandLine(cmd);
|
||||
setWorkingDirectory(targetInformation.workingDirectory());
|
||||
|
||||
appendMessage(tr("Starting AppMan Debugging..."), NormalMessageFormat);
|
||||
appendMessage(tr("Using: %1").arg(cmd.toUserOutput()), NormalMessageFormat);
|
||||
appendMessage(Tr::tr("Starting AppMan Debugging..."), NormalMessageFormat);
|
||||
appendMessage(Tr::tr("Using: %1").arg(cmd.toUserOutput()), NormalMessageFormat);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -164,7 +165,7 @@ private:
|
||||
|
||||
// AppManagerDebugSupport
|
||||
|
||||
class AppManagerDebugSupport : public Debugger::DebuggerRunTool
|
||||
class AppManagerDebugSupport final : public Debugger::DebuggerRunTool
|
||||
{
|
||||
private:
|
||||
QString m_symbolFile;
|
||||
@@ -202,7 +203,7 @@ public:
|
||||
return ti.buildKey == targetInformation.manifest.code || ti.projectFilePath.toString() == targetInformation.manifest.code;
|
||||
}).targetFilePath.toString();
|
||||
} 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,18 +250,9 @@ private:
|
||||
class AppManagerQmlToolingSupport final : public RunWorker
|
||||
{
|
||||
public:
|
||||
explicit AppManagerQmlToolingSupport(RunControl *runControl);
|
||||
|
||||
private:
|
||||
void start() override;
|
||||
|
||||
AppManInferiorRunner *m_runner = nullptr;
|
||||
RunWorker *m_worker = nullptr;
|
||||
};
|
||||
|
||||
AppManagerQmlToolingSupport::AppManagerQmlToolingSupport(RunControl *runControl)
|
||||
explicit AppManagerQmlToolingSupport(RunControl *runControl)
|
||||
: RunWorker(runControl)
|
||||
{
|
||||
{
|
||||
setId("AppManagerQmlToolingSupport");
|
||||
|
||||
QmlDebug::QmlDebugServicesPreset services = QmlDebug::servicesForRunMode(runControl->runMode());
|
||||
@@ -271,38 +263,69 @@ AppManagerQmlToolingSupport::AppManagerQmlToolingSupport(RunControl *runControl)
|
||||
m_worker = runControl->createWorker(QmlDebug::runnerIdForRunMode(runControl->runMode()));
|
||||
m_worker->addStartDependency(this);
|
||||
addStopDependency(m_worker);
|
||||
}
|
||||
}
|
||||
|
||||
void AppManagerQmlToolingSupport::start()
|
||||
{
|
||||
private:
|
||||
void start() final
|
||||
{
|
||||
m_worker->recordData("QmlServerUrl", m_runner->qmlServer());
|
||||
reportStarted();
|
||||
}
|
||||
}
|
||||
|
||||
AppManInferiorRunner *m_runner = nullptr;
|
||||
RunWorker *m_worker = nullptr;
|
||||
};
|
||||
|
||||
|
||||
// Factories
|
||||
|
||||
AppManagerRunWorkerFactory::AppManagerRunWorkerFactory()
|
||||
class AppManagerRunWorkerFactory final : public RunWorkerFactory
|
||||
{
|
||||
public:
|
||||
AppManagerRunWorkerFactory()
|
||||
{
|
||||
setProduct<AppManagerRunner>();
|
||||
addSupportedRunMode(ProjectExplorer::Constants::NORMAL_RUN_MODE);
|
||||
addSupportedRunConfig(Constants::RUNCONFIGURATION_ID);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
AppManagerDebugWorkerFactory::AppManagerDebugWorkerFactory()
|
||||
class AppManagerDebugWorkerFactory final : public RunWorkerFactory
|
||||
{
|
||||
public:
|
||||
AppManagerDebugWorkerFactory()
|
||||
{
|
||||
setProduct<AppManagerDebugSupport>();
|
||||
addSupportedRunMode(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||
addSupportedRunConfig(Constants::RUNCONFIGURATION_ID);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
AppManagerQmlToolingWorkerFactory::AppManagerQmlToolingWorkerFactory()
|
||||
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;
|
||||
}
|
||||
|
||||
void setupAppManagerDebugWorker()
|
||||
{
|
||||
static AppManagerDebugWorkerFactory theAppManagerDebugWorkerFactory;
|
||||
}
|
||||
|
||||
void setupAppManagerQmlToolingWorker()
|
||||
{
|
||||
static AppManagerQmlToolingWorkerFactory theAppManagerQmlToolingWorkerFactory;
|
||||
}
|
||||
|
||||
} // AppManager::Internal
|
||||
|
||||
@@ -5,28 +5,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/runcontrol.h>
|
||||
namespace AppManager::Internal {
|
||||
|
||||
namespace AppManager {
|
||||
namespace Internal {
|
||||
void setupAppManagerRunWorker();
|
||||
void setupAppManagerDebugWorker();
|
||||
void setupAppManagerQmlToolingWorker();
|
||||
|
||||
class AppManagerRunWorkerFactory : public ProjectExplorer::RunWorkerFactory
|
||||
{
|
||||
public:
|
||||
AppManagerRunWorkerFactory();
|
||||
};
|
||||
|
||||
class AppManagerDebugWorkerFactory : public ProjectExplorer::RunWorkerFactory
|
||||
{
|
||||
public:
|
||||
AppManagerDebugWorkerFactory();
|
||||
};
|
||||
|
||||
class AppManagerQmlToolingWorkerFactory : public ProjectExplorer::RunWorkerFactory
|
||||
{
|
||||
public:
|
||||
AppManagerQmlToolingWorkerFactory();
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace AppManager
|
||||
} // AppManager::Internal
|
||||
|
||||
Reference in New Issue
Block a user