Publis to Ovi: Implementing PublishStep with wipe function

Make Publish to Ovi no so "hardcoded"
and base it upon custom steps.

Now the code is recleaned and rebuild after
freeze

Change-Id: I555136d58f728d563eb7dabcb48f314ce4a19003
Reviewed-on: http://codereview.qt.nokia.com/92
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
Pawel Polanski
2011-05-24 16:25:06 +02:00
committed by Daniel Teske
parent 32b457994b
commit 16eefb3a88
4 changed files with 232 additions and 114 deletions

View File

@@ -56,7 +56,8 @@ namespace Internal {
S60PublisherOvi::S60PublisherOvi(QObject *parent) :
QObject(parent),
m_reader(0)
m_reader(0),
m_finishedAndSuccessful(false)
{
// build m_rejectedVendorNames
m_rejectedVendorNames.append(Constants::REJECTED_VENDOR_NAMES_NOKIA);
@@ -80,18 +81,6 @@ S60PublisherOvi::S60PublisherOvi(QObject *parent) :
m_commandColor = Qt::blue;
m_okColor = Qt::darkGreen;
m_normalColor = Qt::black;
m_finishedAndSuccessful = false;
m_cleanProc = new QProcess(this);
m_qmakeProc = new QProcess(this);
m_buildProc = new QProcess(this);
m_createSisProc = new QProcess(this);
connect(m_cleanProc,SIGNAL(finished(int)), SLOT(runQMake(int)));
connect(m_qmakeProc,SIGNAL(finished(int)), SLOT(runBuild(int)));
connect(m_buildProc,SIGNAL(finished(int)), SLOT(runCreateSis(int)));
connect(m_createSisProc,SIGNAL(finished(int)), SLOT(endBuild(int)));
}
S60PublisherOvi::~S60PublisherOvi()
@@ -136,6 +125,7 @@ void S60PublisherOvi::cleanUp()
m_qt4project->destroyProFileReader(m_reader);
m_reader = 0;
}
m_publishSteps.clear();
}
void S60PublisherOvi::completeCreation()
@@ -156,17 +146,52 @@ void S60PublisherOvi::completeCreation()
profile->deref();
// set up process for creating the resulting sis files
m_cleanProc->setEnvironment(m_qt4bc->environment().toStringList());
m_cleanProc->setWorkingDirectory(m_qt4bc->buildDirectory());
ProjectExplorer::AbstractProcessStep * makeStep = m_qt4bc->makeStep();
makeStep->init();
const ProjectExplorer::ProcessParameters * const makepp = makeStep->processParameters();
m_qmakeProc->setEnvironment(m_qt4bc->environment().toStringList());
m_qmakeProc->setWorkingDirectory(m_qt4bc->buildDirectory());
ProjectExplorer::AbstractProcessStep *qmakeStep = m_qt4bc->qmakeStep();
qmakeStep->init();
const ProjectExplorer::ProcessParameters * const qmakepp = qmakeStep->processParameters();
m_buildProc->setEnvironment(m_qt4bc->environment().toStringList());
m_buildProc->setWorkingDirectory(m_qt4bc->buildDirectory());
m_publishSteps.clear();
m_publishSteps.append(new S60CommandPublishStep(*m_qt4bc,
makepp->effectiveCommand() + ' ' + QLatin1String("clean -w"),
tr("Clean"),
false));
m_createSisProc->setEnvironment(m_qt4bc->environment().toStringList());
m_createSisProc->setWorkingDirectory(m_qt4bc->buildDirectory());
m_publishSteps.append(new S60CommandPublishStep(*m_qt4bc,
qmakepp->effectiveCommand() + ' ' + qmakepp->arguments(),
tr("QMake")));
m_publishSteps.append(new S60CommandPublishStep(*m_qt4bc,
makepp->effectiveCommand() + ' ' + makepp->arguments(),
tr("Build")));
const QString freezeArg = QLatin1String("freeze-") + makepp->arguments();
m_publishSteps.append(new S60CommandPublishStep(*m_qt4bc,
makepp->effectiveCommand() + ' ' + freezeArg,
tr("Freeze")));
m_publishSteps.append(new S60CommandPublishStep(*m_qt4bc,
makepp->effectiveCommand() + ' ' + QLatin1String("clean -w"),
tr("Secondary Clean"),
false));
m_publishSteps.append(new S60CommandPublishStep(*m_qt4bc,
qmakepp->effectiveCommand() + ' ' + qmakepp->arguments(),
tr("Secondary QMake")));
m_publishSteps.append(new S60CommandPublishStep(*m_qt4bc,
makepp->effectiveCommand() + ' ' + makepp->arguments(),
tr("Secondary Build")));
QString signArg = QLatin1String("unsigned_installer_sis");
if (m_qt4bc->qtVersion()->qtVersion() == QtSupport::QtVersionNumber(4,6,3) )
signArg = QLatin1String("installer_sis");
m_publishSteps.append(new S60CommandPublishStep(*m_qt4bc,
makepp->effectiveCommand() + ' ' + signArg,
tr("Making Sis File")));
// set up access to vendor names
QStringList deploymentLevelVars = m_reader->values(QLatin1String("DEPLOYMENT"));
@@ -345,91 +370,68 @@ void S60PublisherOvi::updateProFile()
void S60PublisherOvi::buildSis()
{
updateProFile();
runClean();
if (!runStep()) {
emit progressReport(tr("Done!\n"), m_commandColor);
emit finished();
}
}
void S60PublisherOvi::runClean()
bool S60PublisherOvi::runStep()
{
m_finishedAndSuccessful = false;
QTC_ASSERT(m_publishSteps.count(), return false);
ProjectExplorer::AbstractProcessStep * makeStep = m_qt4bc->makeStep();
makeStep->init();
const ProjectExplorer::ProcessParameters * const makepp = makeStep->processParameters();
QString makeTarget = QLatin1String(" clean -w");
runStep(QProcess::NormalExit,
tr("Running Clean Step"),
makepp->effectiveCommand() + makeTarget,
m_cleanProc,
0);
S60PublishStep *step = m_publishSteps.at(0);
emit progressReport(step->displayDescription() + '\n', m_commandColor);
connect(step, SIGNAL(finished(bool)), this, SLOT(publishStepFinished(bool)));
connect(step, SIGNAL(output(QString,bool)), this, SLOT(printMessage(QString,bool)));
step->start();
return true;
}
void S60PublisherOvi::runQMake(int result)
bool S60PublisherOvi::nextStep()
{
Q_UNUSED(result)
ProjectExplorer::AbstractProcessStep *qmakeStep = m_qt4bc->qmakeStep();
qmakeStep->init();
const ProjectExplorer::ProcessParameters * const qmakepp = qmakeStep->processParameters();
runStep(QProcess::NormalExit, // ignore all errors from Clean step
tr("Running QMake"),
qmakepp->effectiveCommand() + ' ' + qmakepp->arguments(),
m_qmakeProc,
m_cleanProc);
QTC_ASSERT(m_publishSteps.count(), return false);
m_publishSteps.removeAt(0);
return m_publishSteps.count();
}
void S60PublisherOvi::runBuild(int result)
void S60PublisherOvi::printMessage(QString message, bool error)
{
ProjectExplorer::AbstractProcessStep * makeStep = m_qt4bc->makeStep();
makeStep->init();
const ProjectExplorer::ProcessParameters * const makepp = makeStep->processParameters();
// freeze all the libraries
const QString makeArg = QLatin1String("freeze-") + makepp->arguments();
runStep(result,
tr("Running Build Steps"),
makepp->effectiveCommand() + ' ' + makeArg,
m_buildProc,
m_qmakeProc);
emit progressReport(message + '\n', error ? m_errorColor : m_okColor);
}
void S60PublisherOvi::runCreateSis(int result)
void S60PublisherOvi::publishStepFinished(bool success)
{
ProjectExplorer::AbstractProcessStep * makeStep = m_qt4bc->makeStep();
makeStep->init();
const ProjectExplorer::ProcessParameters * const makepp = makeStep->processParameters();
QString makeTarget = QLatin1String(" unsigned_installer_sis");
if (!success && m_publishSteps.at(0)->mandatory()) {
emit progressReport(tr("Sis file not created due to previous errors\n") , m_errorColor);
emit finished();
return;
}
if (m_qt4bc->qtVersion()->qtVersion() == QtSupport::QtVersionNumber(4,6,3) )
makeTarget = QLatin1String(" installer_sis");
runStep(result,
tr("Making Sis File"),
makepp->effectiveCommand() + makeTarget,
m_createSisProc,
m_buildProc);
if (nextStep())
runStep();
else {
QString sisFile;
if (sisExists(sisFile)) {
emit progressReport(tr("Created %1\n").arg(QDir::toNativeSeparators(sisFile)), m_normalColor);
m_finishedAndSuccessful = true;
emit succeeded();
}
emit progressReport(tr("Done!\n"), m_commandColor);
emit finished();
}
}
void S60PublisherOvi::endBuild(int result)
bool S60PublisherOvi::sisExists(QString &sisFile)
{
// show what happened in last step
emit progressReport(QString(m_createSisProc->readAllStandardOutput() + '\n'), m_okColor);
emit progressReport(QString(m_createSisProc->readAllStandardError() + '\n'), m_errorColor);
QString fileNamePostFix = QLatin1String("_installer_unsigned.sis");
QString fileNamePostFix = QLatin1String("_installer_unsigned.sis");
if (m_qt4bc->qtVersion()->qtVersion() == QtSupport::QtVersionNumber(4,6,3) )
fileNamePostFix = QLatin1String("_installer.sis");
QString resultFile = m_qt4bc->buildDirectory() + QLatin1Char('/') + m_qt4project->displayName() + fileNamePostFix;
sisFile = m_qt4bc->buildDirectory() + QLatin1Char('/') + m_qt4project->displayName() + fileNamePostFix;
QFileInfo fi(resultFile);
if (result == QProcess::NormalExit && fi.exists()) {
emit progressReport(tr("Created %1\n").arg(QDir::toNativeSeparators(resultFile)), m_normalColor);
m_finishedAndSuccessful = true;
emit succeeded();
} else {
emit progressReport(tr(" Sis file not created due to previous errors\n"), m_errorColor);
}
emit progressReport(tr("Done!\n"), m_commandColor);
emit finished();
QFileInfo fi(sisFile);
return fi.exists();
}
QString S60PublisherOvi::createdSisFileContainingFolder()
@@ -461,25 +463,72 @@ bool S60PublisherOvi::hasSucceeded()
return m_finishedAndSuccessful;
}
void S60PublisherOvi::runStep(int result, const QString& buildStep, const QString& command, QProcess* currProc, QProcess* prevProc)
// ======== S60PublishStep
S60PublishStep::S60PublishStep(bool mandatory, QObject *parent)
: QObject(parent),
m_succeeded(false),
m_mandatory(mandatory)
{
// todo react to readyRead() instead of reading all at the end
// show what happened in last step
if (prevProc) {
emit progressReport(QString(prevProc->readAllStandardOutput() + '\n'), m_okColor);
emit progressReport(QString(prevProc->readAllStandardError() + '\n'), m_errorColor);
}
}
// if the last state finished ok then run the build.
if (result == QProcess::NormalExit) {
emit progressReport(buildStep + '\n', m_commandColor);
emit progressReport(command + '\n', m_commandColor);
bool S60PublishStep::succeeded() const
{
return m_succeeded;
}
currProc->start(command);
} else {
emit progressReport(tr("Sis file not created due to previous errors\n") , m_errorColor);
emit finished();
}
bool S60PublishStep::mandatory() const
{
return m_mandatory;
}
void S60PublishStep::setSucceeded(bool succeeded)
{
m_succeeded = succeeded;
}
// ======== S60CommandPublishStep
S60CommandPublishStep::S60CommandPublishStep(const Qt4ProjectManager::Qt4BuildConfiguration &bc,
const QString &command,
const QString &name,
bool mandatory,
QObject *parent)
: S60PublishStep(mandatory, parent),
m_proc(new QProcess(this)),
m_command(command),
m_name(name)
{
m_proc->setEnvironment(bc.environment().toStringList());
m_proc->setWorkingDirectory(bc.buildDirectory());
connect(m_proc, SIGNAL(finished(int)), SLOT(processFinished(int)));
}
void S60CommandPublishStep::processFinished(int exitCode)
{
QByteArray outputText = m_proc->readAllStandardOutput();
if (!outputText.isEmpty())
emit output(outputText, false);
outputText = m_proc->readAllStandardError();
if (!outputText.isEmpty())
emit output(outputText, true);
setSucceeded(exitCode == QProcess::NormalExit);
emit finished(succeeded());
}
void S60CommandPublishStep::start()
{
emit output(m_command, false);
m_proc->start(m_command);
}
QString S60CommandPublishStep::displayDescription() const
{
//: %1 is a name of the Publish Step i.e. Clean Step
return tr("Running %1").arg(m_name);
}
} // namespace Internal

View File

@@ -52,6 +52,7 @@ class Qt4BuildConfiguration;
class Qt4Project;
namespace Internal {
class Qt4SymbianTarget;
class S60PublishStep;
namespace Constants {
const char * const REJECTED_VENDOR_NAMES_VENDOR = "Vendor";
@@ -144,25 +145,21 @@ signals:
void finished();
public slots:
void runClean();
void runQMake(int result);
void runBuild(int result);
void runCreateSis(int result);
void endBuild(int result);
void publishStepFinished(bool succeeded);
void printMessage(QString message, bool error);
private:
void runStep(int result, const QString& buildStep, const QString& command, QProcess* currProc, QProcess* prevProc);
bool nextStep();
bool runStep();
bool sisExists(QString &sisFile);
private:
QColor m_errorColor;
QColor m_commandColor;
QColor m_okColor;
QColor m_normalColor;
QProcess* m_cleanProc;
QProcess* m_qmakeProc;
QProcess* m_buildProc;
QProcess* m_createSisProc;
Qt4BuildConfiguration * m_qt4bc;
const Qt4SymbianTarget * m_activeTargetOfProject;
Qt4Project * m_qt4project;
@@ -176,9 +173,59 @@ private:
QString m_appUid;
QString m_displayName;
QList<S60PublishStep *> m_publishSteps;
bool m_finishedAndSuccessful;
};
class S60PublishStep : public QObject
{
Q_OBJECT
public:
explicit S60PublishStep(bool mandatory, QObject *parent = 0);
virtual void start() = 0;
virtual QString displayDescription() const = 0;
bool succeeded() const;
bool mandatory() const;
signals:
void finished(bool succeeded);
void output(QString output, bool error);
protected:
void setSucceeded(bool succeeded);
private:
bool m_succeeded;
bool m_mandatory;
};
class S60CommandPublishStep : public S60PublishStep
{
Q_OBJECT
public:
explicit S60CommandPublishStep(const Qt4BuildConfiguration& bc,
const QString &command,
const QString &name,
bool mandatory = true,
QObject *parent = 0);
virtual void start();
virtual QString displayDescription() const;
private slots:
void processFinished(int exitCode);
private:
QProcess* m_proc;
const QString m_command;
const QString m_name;
};
} // namespace Internal
} // namespace Qt4ProjectManager

View File

@@ -35,6 +35,7 @@
#include <QtGui/QDesktopServices>
#include <QtGui/QAbstractButton>
#include <QtGui/QScrollBar>
#include <QtCore/QProcess>
namespace Qt4ProjectManager {
@@ -75,11 +76,30 @@ void S60PublishingResultsPageOvi::packageCreationFinished()
void S60PublishingResultsPageOvi::updateResultsPage(const QString& status, QColor c)
{
const bool atBottom = isScrollbarAtBottom();
QTextCursor cur(ui->resultsTextBrowser->document());
QTextCharFormat tcf = cur.charFormat();
tcf.setForeground(c);
cur.movePosition(QTextCursor::End);
cur.insertText(status, tcf);
if (atBottom)
scrollToBottom();
}
bool S60PublishingResultsPageOvi::isScrollbarAtBottom() const
{
QScrollBar *scrollBar = ui->resultsTextBrowser->verticalScrollBar();
return scrollBar->value() == scrollBar->maximum();
}
void S60PublishingResultsPageOvi::scrollToBottom()
{
QScrollBar *scrollBar = ui->resultsTextBrowser->verticalScrollBar();
scrollBar->setValue(scrollBar->maximum());
// QPlainTextEdit destroys the first calls value in case of multiline
// text, so make sure that the scroll bar actually gets the value set.
// Is a noop if the first call succeeded.
scrollBar->setValue(scrollBar->maximum());
}
void S60PublishingResultsPageOvi::openFileLocation()

View File

@@ -53,13 +53,15 @@ public:
virtual void initializePage();
virtual bool isComplete() const;
signals:
public slots:
void updateResultsPage(const QString &status, QColor c);
void openFileLocation();
void packageCreationFinished();
private:
void scrollToBottom();
bool isScrollbarAtBottom() const;
private:
Ui::S60PublishingResultsPageOvi *ui;
S60PublisherOvi * const m_publisher;