Maemo: Add detailed package creation output.

This commit is contained in:
ck
2010-07-01 11:55:36 +02:00
parent 6dc4a039f2
commit 2dfa9772f6
2 changed files with 42 additions and 21 deletions

View File

@@ -161,11 +161,16 @@ bool MaemoPackageCreationStep::createPackage()
env.insert(envPattern.cap(1), envPattern.cap(2)); env.insert(envPattern.cap(1), envPattern.cap(2));
} while (!line.isEmpty()); } while (!line.isEmpty());
QProcess buildProc;
buildProc.setProcessEnvironment(env); m_buildProc.reset(new QProcess);
buildProc.setWorkingDirectory(buildDir); connect(m_buildProc.data(), SIGNAL(readyReadStandardOutput()), this,
buildProc.start("cd " + buildDir); SLOT(handleBuildOutput()));
buildProc.waitForFinished(); connect(m_buildProc.data(), SIGNAL(readyReadStandardError()), this,
SLOT(handleBuildOutput()));
m_buildProc->setProcessEnvironment(env);
m_buildProc->setWorkingDirectory(buildDir);
m_buildProc->start("cd " + buildDir);
m_buildProc->waitForFinished();
// cache those two since we can change the version number during packaging // cache those two since we can change the version number during packaging
// and might fail later to modify, copy, remove etc. the generated package // and might fail later to modify, copy, remove etc. the generated package
@@ -175,7 +180,7 @@ bool MaemoPackageCreationStep::createPackage()
if (!QFileInfo(buildDir + QLatin1String("/debian")).exists()) { if (!QFileInfo(buildDir + QLatin1String("/debian")).exists()) {
const QString command = QLatin1String("dh_make -s -n -p ") const QString command = QLatin1String("dh_make -s -n -p ")
% executableFileName().toLower() % QLatin1Char('_') % versionString(); % executableFileName().toLower() % QLatin1Char('_') % versionString();
if (!runCommand(buildProc, command)) if (!runCommand(command))
return false; return false;
QFile rulesFile(buildDir + QLatin1String("/debian/rules")); QFile rulesFile(buildDir + QLatin1String("/debian/rules"));
@@ -213,7 +218,7 @@ bool MaemoPackageCreationStep::createPackage()
} }
} }
if (!runCommand(buildProc, "dpkg-buildpackage -nc -uc -us")) if (!runCommand(QLatin1String("dpkg-buildpackage -nc -uc -us")))
return false; return false;
// Workaround for non-working dh_builddeb --destdir=. // Workaround for non-working dh_builddeb --destdir=.
@@ -244,7 +249,7 @@ bool MaemoPackageCreationStep::createPackage()
return true; return true;
} }
bool MaemoPackageCreationStep::runCommand(QProcess &proc, const QString &command) bool MaemoPackageCreationStep::runCommand(const QString &command)
{ {
QTextCharFormat textCharFormat; QTextCharFormat textCharFormat;
emit addOutput(tr("Package Creation: Running command '%1'.").arg(command), textCharFormat); emit addOutput(tr("Package Creation: Running command '%1'.").arg(command), textCharFormat);
@@ -252,30 +257,41 @@ bool MaemoPackageCreationStep::runCommand(QProcess &proc, const QString &command
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
perl = maddeRoot() + QLatin1String("/bin/perl.exe "); perl = maddeRoot() + QLatin1String("/bin/perl.exe ");
#endif #endif
proc.start(perl + maddeRoot() % QLatin1String("/madbin/") % command); m_buildProc->start(perl + maddeRoot() % QLatin1String("/madbin/") % command);
if (!proc.waitForStarted()) { if (!m_buildProc->waitForStarted()) {
raiseError(tr("Packaging failed."), raiseError(tr("Packaging failed."),
tr("Packaging error: Could not start command '%1'. Reason: %2") tr("Packaging error: Could not start command '%1'. Reason: %2")
.arg(command).arg(proc.errorString())); .arg(command).arg(m_buildProc->errorString()));
return false; return false;
} }
proc.write("\n"); // For dh_make m_buildProc->write("\n"); // For dh_make
proc.waitForFinished(-1); m_buildProc->waitForFinished(-1);
if (proc.error() != QProcess::UnknownError || proc.exitCode() != 0) { if (m_buildProc->error() != QProcess::UnknownError || m_buildProc->exitCode() != 0) {
QString mainMessage = tr("Packaging Error: Command '%1' failed.") QString mainMessage = tr("Packaging Error: Command '%1' failed.")
.arg(command); .arg(command);
if (proc.error() != QProcess::UnknownError) if (m_buildProc->error() != QProcess::UnknownError)
mainMessage += tr(" Reason: %1").arg(proc.errorString()); mainMessage += tr(" Reason: %1").arg(m_buildProc->errorString());
else else
mainMessage += tr("Exit code: %1").arg(proc.exitCode()); mainMessage += tr("Exit code: %1").arg(m_buildProc->exitCode());
raiseError(mainMessage, mainMessage + QLatin1Char('\n') raiseError(mainMessage);
+ tr("Output was: ") + proc.readAllStandardError()
+ QLatin1Char('\n') + proc.readAllStandardOutput());
return false; return false;
} }
return true; return true;
} }
void MaemoPackageCreationStep::handleBuildOutput()
{
const QByteArray &stdOut = m_buildProc->readAllStandardOutput();
QTextCharFormat textCharFormat;
if (!stdOut.isEmpty())
emit addOutput(QString::fromLocal8Bit(stdOut), textCharFormat);
const QByteArray &errorOut = m_buildProc->readAllStandardError();
if (!errorOut.isEmpty()) {
textCharFormat.setForeground(QBrush(QColor("red")));
emit addOutput(QString::fromLocal8Bit(errorOut), textCharFormat);
}
}
const Qt4BuildConfiguration *MaemoPackageCreationStep::qt4BuildConfiguration() const const Qt4BuildConfiguration *MaemoPackageCreationStep::qt4BuildConfiguration() const
{ {
return static_cast<Qt4BuildConfiguration *>(buildConfiguration()); return static_cast<Qt4BuildConfiguration *>(buildConfiguration());

View File

@@ -44,6 +44,7 @@
#include <projectexplorer/buildstep.h> #include <projectexplorer/buildstep.h>
#include <QtCore/QScopedPointer>
#include <QtCore/QSharedPointer> #include <QtCore/QSharedPointer>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@@ -80,6 +81,9 @@ public:
QString versionString() const; QString versionString() const;
void setVersionString(const QString &version); void setVersionString(const QString &version);
private slots:
void handleBuildOutput();
private: private:
MaemoPackageCreationStep(ProjectExplorer::BuildConfiguration *buildConfig, MaemoPackageCreationStep(ProjectExplorer::BuildConfiguration *buildConfig,
MaemoPackageCreationStep *other); MaemoPackageCreationStep *other);
@@ -92,7 +96,7 @@ private:
virtual bool fromMap(const QVariantMap &map); virtual bool fromMap(const QVariantMap &map);
bool createPackage(); bool createPackage();
bool runCommand(QProcess &proc, const QString &command); bool runCommand(const QString &command);
const MaemoToolChain *maemoToolChain() const; const MaemoToolChain *maemoToolChain() const;
QString maddeRoot() const; QString maddeRoot() const;
QString targetRoot() const; QString targetRoot() const;
@@ -108,6 +112,7 @@ private:
bool m_packagingEnabled; bool m_packagingEnabled;
QString m_versionString; QString m_versionString;
mutable QSharedPointer<ProFileWrapper> m_proFileWrapper; mutable QSharedPointer<ProFileWrapper> m_proFileWrapper;
QScopedPointer<QProcess> m_buildProc;
}; };
} // namespace Internal } // namespace Internal