forked from qt-creator/qt-creator
Move evaluation of QtCreatorDeploymentData.txt to ProjectExplorer
We want to re-use it outside of the CMakeProjectManager. Change-Id: I7550f86704bb7c2a683e831cf8827d5b0f6d90f6 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -595,27 +595,24 @@ void CMakeProject::updateApplicationAndDeploymentTargets()
|
||||
if (!t)
|
||||
return;
|
||||
|
||||
QFile deploymentFile;
|
||||
QTextStream deploymentStream;
|
||||
QString deploymentPrefix;
|
||||
|
||||
QDir sourceDir(t->project()->projectDirectory().toString());
|
||||
QDir buildDir(t->activeBuildConfiguration()->buildDirectory().toString());
|
||||
|
||||
deploymentFile.setFileName(sourceDir.filePath("QtCreatorDeployment.txt"));
|
||||
// If we don't have a global QtCreatorDeployment.txt check for one created by the active build configuration
|
||||
if (!deploymentFile.exists())
|
||||
deploymentFile.setFileName(buildDir.filePath("QtCreatorDeployment.txt"));
|
||||
if (deploymentFile.open(QFile::ReadOnly | QFile::Text)) {
|
||||
deploymentStream.setDevice(&deploymentFile);
|
||||
deploymentPrefix = deploymentStream.readLine();
|
||||
if (!deploymentPrefix.endsWith('/'))
|
||||
deploymentPrefix.append('/');
|
||||
}
|
||||
|
||||
BuildTargetInfoList appTargetList;
|
||||
DeploymentData deploymentData;
|
||||
|
||||
QString deploymentPrefix;
|
||||
QString deploymentFilePath = sourceDir.filePath("QtCreatorDeployment.txt");
|
||||
bool hasDeploymentFile = QFileInfo::exists(deploymentFilePath);
|
||||
if (!hasDeploymentFile) {
|
||||
deploymentFilePath = buildDir.filePath("QtCreatorDeployment.txt");
|
||||
hasDeploymentFile = QFileInfo::exists(deploymentFilePath);
|
||||
}
|
||||
if (hasDeploymentFile) {
|
||||
deploymentPrefix = deploymentData.addFilesFromDeploymentFile(deploymentFilePath,
|
||||
sourceDir.absolutePath());
|
||||
}
|
||||
|
||||
foreach (const CMakeBuildTarget &ct, buildTargets()) {
|
||||
if (ct.targetType == UtilityType)
|
||||
continue;
|
||||
@@ -639,19 +636,6 @@ void CMakeProject::updateApplicationAndDeploymentTargets()
|
||||
}
|
||||
}
|
||||
|
||||
QString absoluteSourcePath = sourceDir.absolutePath();
|
||||
if (!absoluteSourcePath.endsWith('/'))
|
||||
absoluteSourcePath.append('/');
|
||||
if (deploymentStream.device()) {
|
||||
while (!deploymentStream.atEnd()) {
|
||||
QString line = deploymentStream.readLine();
|
||||
if (!line.contains(':'))
|
||||
continue;
|
||||
QStringList file = line.split(':');
|
||||
deploymentData.addFile(absoluteSourcePath + file.at(0), deploymentPrefix + file.at(1));
|
||||
}
|
||||
}
|
||||
|
||||
t->setApplicationTargets(appTargetList);
|
||||
t->setDeploymentData(deploymentData);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
void DeploymentData::setLocalInstallRoot(const Utils::FileName &installRoot)
|
||||
@@ -64,5 +67,30 @@ bool DeploymentData::operator==(const DeploymentData &other) const
|
||||
&& m_localInstallRoot == other.m_localInstallRoot;
|
||||
}
|
||||
|
||||
QString DeploymentData::addFilesFromDeploymentFile(const QString &deploymentFilePath,
|
||||
const QString &sourceDir)
|
||||
{
|
||||
const QString sourcePrefix = sourceDir.endsWith('/') ? sourceDir : sourceDir + '/';
|
||||
QFile deploymentFile(deploymentFilePath);
|
||||
QTextStream deploymentStream;
|
||||
QString deploymentPrefix;
|
||||
|
||||
if (!deploymentFile.open(QFile::ReadOnly | QFile::Text))
|
||||
return deploymentPrefix;
|
||||
deploymentStream.setDevice(&deploymentFile);
|
||||
deploymentPrefix = deploymentStream.readLine();
|
||||
if (!deploymentPrefix.endsWith('/'))
|
||||
deploymentPrefix.append('/');
|
||||
if (deploymentStream.device()) {
|
||||
while (!deploymentStream.atEnd()) {
|
||||
QString line = deploymentStream.readLine();
|
||||
if (!line.contains(':'))
|
||||
continue;
|
||||
QStringList file = line.split(':');
|
||||
addFile(sourcePrefix + file.at(0), deploymentPrefix + file.at(1));
|
||||
}
|
||||
}
|
||||
return deploymentPrefix;
|
||||
}
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
||||
@@ -44,6 +44,7 @@ public:
|
||||
void addFile(const DeployableFile &file);
|
||||
void addFile(const QString &localFilePath, const QString &remoteDirectory,
|
||||
DeployableFile::Type type = DeployableFile::TypeNormal);
|
||||
QString addFilesFromDeploymentFile(const QString &deploymentFilePath, const QString &sourceDir);
|
||||
|
||||
int fileCount() const { return m_files.count(); }
|
||||
DeployableFile fileAt(int index) const { return m_files.at(index); }
|
||||
|
||||
Reference in New Issue
Block a user