-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathqtcrunworkerfactory.cpp
More file actions
66 lines (51 loc) · 2.57 KB
/
qtcrunworkerfactory.cpp
File metadata and controls
66 lines (51 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "qtcrunworkerfactory.h"
#include "qtcdevpluginconstants.h"
#include <projectexplorer/projectexplorerconstants.h>
#include <extensionsystem/pluginmanager.h>
namespace QtcDevPlugin {
namespace Internal {
QtcRunWorkerFactory::QtcRunWorkerFactory(Utils::Id runMode, const ReceipeProducer& baseReceipe)
: ProjectExplorer::RunWorkerFactory()
{
addSupportedRunMode(runMode);
addSupportedDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
addSupportedRunConfig(Utils::Id(Constants::QtcRunConfigurationId));
addSupportedRunConfig(Utils::Id(Constants::QtcTestRunConfigurationId));
setProducer([this, baseReceipe] (ProjectExplorer::RunControl* runControl) {
return new ProjectExplorer::RunWorker(runControl, Tasking::Group {
Tasking::onGroupSetup([this, runControl] () {
movePluginFile(runControl->targetFilePath(), QString(), QLatin1String(".del"));
for (Utils::FilePath pluginFilePath: pluginPaths(runControl->targetFilePath().fileName()))
movePluginFile(pluginFilePath, QString(), QLatin1String(".del"));
}),
Tasking::onGroupDone([this, runControl] () {
movePluginFile(runControl->targetFilePath(), QLatin1String(".del"), QString());
for (Utils::FilePath pluginFilePath: pluginPaths(runControl->targetFilePath().fileName()))
movePluginFile(pluginFilePath, QLatin1String(".del"), QString());
}),
baseReceipe(runControl)
});
});
}
std::list<Utils::FilePath> QtcRunWorkerFactory::pluginPaths(const QString& fileName)
{
std::list<Utils::FilePath> ans;
for (Utils::FilePath pluginPath: ExtensionSystem::PluginManager::pluginPaths())
ans.push_back(pluginPath / fileName);
return ans;
}
void QtcRunWorkerFactory::movePluginFile(const Utils::FilePath& targetPath, const QString& oldSuffix, const QString& newSuffix)
{
Utils::FilePath oldTargetPath = Utils::FilePath(targetPath).stringAppended(oldSuffix);
Utils::FilePath newTargetPath = Utils::FilePath(targetPath).stringAppended(newSuffix);
qDebug() << "Before:" << oldTargetPath << oldTargetPath.exists()
<< newTargetPath << newTargetPath.exists();
if (oldTargetPath.exists()) {
QTC_CHECK(QFile::rename(oldTargetPath.nativePath(), newTargetPath.nativePath()));
qDebug() << "After: " << oldTargetPath << oldTargetPath.exists()
<< newTargetPath << newTargetPath.exists();
}
QTC_CHECK(!oldTargetPath.exists());
}
} // Internal
} // QtcDevPlugin