GenericProject: Set deployment data, if available

We use the same approach as for CMake, namely the
QtCreatorDeployment.txt file.

Fixes: QTCREATORBUG-19202
Change-Id: I50605b8236b26f0c911e2448330019e94753af19
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2018-11-14 10:23:47 +01:00
parent 73b1a765f3
commit 1950b38668
4 changed files with 53 additions and 2 deletions

View File

@@ -42,6 +42,7 @@
#include <projectexplorer/abi.h>
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/customexecutablerunconfiguration.h>
#include <projectexplorer/deploymentdata.h>
#include <projectexplorer/headerpath.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/kitmanager.h>
@@ -53,10 +54,12 @@
#include <qtsupport/qtkitinformation.h>
#include <utils/algorithm.h>
#include <utils/filesystemwatcher.h>
#include <utils/fileutils.h>
#include <utils/qtcassert.h>
#include <QDir>
#include <QFileInfo>
#include <QHash>
#include <QSet>
#include <QStringList>
@@ -163,7 +166,8 @@ private:
GenericProject::GenericProject(const Utils::FileName &fileName) :
Project(Constants::GENERICMIMETYPE, fileName, [this]() { refresh(Everything); }),
m_cppCodeModelUpdater(new CppTools::CppProjectUpdater(this))
m_cppCodeModelUpdater(new CppTools::CppProjectUpdater(this)),
m_deployFileWatcher(new FileSystemWatcher(this))
{
setId(Constants::GENERICPROJECT_ID);
setProjectLanguages(Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
@@ -187,6 +191,8 @@ GenericProject::GenericProject(const Utils::FileName &fileName) :
m_configIDocument
= new ProjectDocument(Constants::GENERICMIMETYPE, FileName::fromString(m_configFileName),
[this]() { refresh(Configuration); });
connect(m_deployFileWatcher, &FileSystemWatcher::fileChanged,
this, &GenericProject::updateDeploymentData);
}
GenericProject::~GenericProject()
@@ -366,6 +372,7 @@ void GenericProject::refresh(RefreshOptions options)
}
refreshCppCodeModel();
updateDeploymentData();
emitParsingFinished(true);
}
@@ -454,6 +461,32 @@ void GenericProject::refreshCppCodeModel()
m_cppCodeModelUpdater->update(projectInfoUpdate);
}
void GenericProject::updateDeploymentData()
{
static const QString fileName("QtCreatorDeployment.txt");
Utils::FileName deploymentFilePath;
if (activeTarget() && activeTarget()->activeBuildConfiguration()) {
deploymentFilePath = activeTarget()->activeBuildConfiguration()->buildDirectory()
.appendPath(fileName);
}
bool hasDeploymentData = QFileInfo::exists(deploymentFilePath.toString());
if (!hasDeploymentData) {
deploymentFilePath = projectDirectory().appendPath(fileName);
hasDeploymentData = QFileInfo::exists(deploymentFilePath.toString());
}
if (hasDeploymentData) {
DeploymentData deploymentData;
deploymentData.addFilesFromDeploymentFile(deploymentFilePath.toString(),
projectDirectory().toString());
activeTarget()->setDeploymentData(deploymentData);
if (m_deployFileWatcher->files() != QStringList(deploymentFilePath.toString())) {
m_deployFileWatcher->removeFiles(m_deployFileWatcher->files());
m_deployFileWatcher->addFile(deploymentFilePath.toString(),
FileSystemWatcher::WatchModifiedDate);
}
}
}
void GenericProject::activeTargetWasChanged()
{
if (m_activeTarget) {