forked from qt-creator/qt-creator
Qnx: Use QFile instead of QTemporary to create the project's bar-descriptor
This enables developers to find and use the prepared bar-descriptor with command lines Change-Id: I1083d18f02d5026e186735fdfcbb61aca30f01b8 Reviewed-by: Tobias Nätterlund <tobias.naetterlund@kdab.com> Reviewed-by: Nicolas Arnaud-Cormos <nicolas@kdab.com>
This commit is contained in:
committed by
Nicolas Arnaud-Cormos
parent
21aef7ddc9
commit
6043621292
@@ -98,7 +98,6 @@ void BlackBerryAbstractDeployStep::run(QFutureInterface<bool> &fi)
|
||||
|
||||
// Finished
|
||||
m_params.clear();
|
||||
cleanup();
|
||||
m_processCounter = -1;
|
||||
|
||||
m_timer->stop();
|
||||
|
||||
@@ -57,7 +57,6 @@ public:
|
||||
|
||||
bool init();
|
||||
void run(QFutureInterface<bool> &fi);
|
||||
virtual void cleanup() = 0;
|
||||
|
||||
protected:
|
||||
BlackBerryAbstractDeployStep(ProjectExplorer::BuildStepList *bsl, BlackBerryAbstractDeployStep *bs);
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QTemporaryFile>
|
||||
#include <QFile>
|
||||
|
||||
using namespace Qnx;
|
||||
using namespace Qnx::Internal;
|
||||
@@ -121,34 +121,24 @@ bool BlackBerryCreatePackageStep::init()
|
||||
}
|
||||
}
|
||||
|
||||
QTemporaryFile *preparedAppDescriptorFile = new QTemporaryFile(buildDir + QLatin1String("/bar-descriptor_XXXXXX.xml"));
|
||||
if (!prepareAppDescriptorFile(info.appDescriptorPath, preparedAppDescriptorFile)) { // If there is an error, prepareAppDescriptorFile() will raise it
|
||||
delete preparedAppDescriptorFile;
|
||||
const QString preparedFilePath = buildDir + QLatin1String("/bar-descriptor-") + project()->displayName() + QLatin1String("-qtc-generated.xml");
|
||||
if (!prepareAppDescriptorFile(info.appDescriptorPath, preparedFilePath))
|
||||
// If there is an error, prepareAppDescriptorFile() will raise it
|
||||
return false;
|
||||
}
|
||||
|
||||
m_preparedAppDescriptorFiles << preparedAppDescriptorFile;
|
||||
|
||||
QStringList args;
|
||||
args << QLatin1String("-devMode");
|
||||
if (!debugToken().isEmpty())
|
||||
args << QLatin1String("-debugToken") << QnxUtils::addQuotes(QDir::toNativeSeparators(debugToken()));
|
||||
args << QLatin1String("-package") << QnxUtils::addQuotes(QDir::toNativeSeparators(info.packagePath));
|
||||
args << QnxUtils::addQuotes(QDir::toNativeSeparators(preparedAppDescriptorFile->fileName()));
|
||||
args << QnxUtils::addQuotes(QDir::toNativeSeparators(preparedFilePath));
|
||||
addCommand(packageCmd, args);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BlackBerryCreatePackageStep::cleanup()
|
||||
{
|
||||
while (!m_preparedAppDescriptorFiles.isEmpty()) {
|
||||
QTemporaryFile *file = m_preparedAppDescriptorFiles.takeFirst();
|
||||
delete file;
|
||||
}
|
||||
}
|
||||
|
||||
ProjectExplorer::BuildStepConfigWidget *BlackBerryCreatePackageStep::createConfigWidget()
|
||||
{
|
||||
return new BlackBerryCreatePackageStepConfigWidget();
|
||||
@@ -168,10 +158,9 @@ void BlackBerryCreatePackageStep::raiseError(const QString &errorMessage)
|
||||
emit addOutput(errorMessage, BuildStep::ErrorMessageOutput);
|
||||
emit addTask(ProjectExplorer::Task(ProjectExplorer::Task::Error, errorMessage, Utils::FileName(), -1,
|
||||
Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)));
|
||||
cleanup();
|
||||
}
|
||||
|
||||
bool BlackBerryCreatePackageStep::prepareAppDescriptorFile(const QString &appDescriptorPath, QTemporaryFile *preparedFile)
|
||||
bool BlackBerryCreatePackageStep::prepareAppDescriptorFile(const QString &appDescriptorPath, const QString &preparedFilePath)
|
||||
{
|
||||
BlackBerryQtVersion *qtVersion = dynamic_cast<BlackBerryQtVersion *>(QtSupport::QtKitInformation::qtVersion(target()->kit()));
|
||||
if (!qtVersion) {
|
||||
@@ -185,8 +174,15 @@ bool BlackBerryCreatePackageStep::prepareAppDescriptorFile(const QString &appDes
|
||||
return false;
|
||||
}
|
||||
|
||||
QFile preparedFile(preparedFilePath);
|
||||
|
||||
QByteArray fileContent = file.readAll();
|
||||
|
||||
// Add Warning text
|
||||
const QString warningText = QString::fromLatin1("<!-- This file is autogenerated;"
|
||||
" any changes will get overwritten if deploying with Qt Creator -->\n<qnx");
|
||||
fileContent.replace("<qnx", warningText.toLatin1());
|
||||
|
||||
// Replace Qt path placeholders
|
||||
if (fileContent.contains(QT_INSTALL_LIBS_VAR))
|
||||
fileContent.replace(QT_INSTALL_LIBS_VAR, qtVersion->versionInfo().value(QLatin1String(QT_INSTALL_LIBS)).toLatin1());
|
||||
@@ -211,13 +207,13 @@ bool BlackBerryCreatePackageStep::prepareAppDescriptorFile(const QString &appDes
|
||||
}
|
||||
|
||||
const QString buildDir = target()->activeBuildConfiguration()->buildDirectory();
|
||||
if (!preparedFile->open()) {
|
||||
if (!preparedFile.open(QIODevice::WriteOnly)) {
|
||||
raiseError(tr("Could not create prepared application descriptor file in '%1'").arg(buildDir));
|
||||
return false;
|
||||
}
|
||||
|
||||
preparedFile->write(fileContent);
|
||||
preparedFile->close();
|
||||
preparedFile.write(fileContent);
|
||||
preparedFile.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "blackberryabstractdeploystep.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QTemporaryFile;
|
||||
class QFile;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Qnx {
|
||||
@@ -50,7 +50,6 @@ public:
|
||||
explicit BlackBerryCreatePackageStep(ProjectExplorer::BuildStepList *bsl);
|
||||
|
||||
bool init();
|
||||
void cleanup();
|
||||
ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
|
||||
|
||||
QString debugToken() const;
|
||||
@@ -61,9 +60,7 @@ protected:
|
||||
void raiseError(const QString &errorMessage);
|
||||
|
||||
private:
|
||||
bool prepareAppDescriptorFile(const QString &appDescriptorPath, QTemporaryFile *preparedFile);
|
||||
|
||||
QList<QTemporaryFile *> m_preparedAppDescriptorFiles;
|
||||
bool prepareAppDescriptorFile(const QString &appDescriptorPath, const QString &preparedFilePath);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user