Skip to content
Snippets Groups Projects
Commit 8f883cad authored by con's avatar con
Browse files

Merge branch 'master' of scm.dev.nokia.troll.no:creator/mainline

parents f29edad5 2dfa9772
No related branches found
No related tags found
No related merge requests found
......@@ -161,11 +161,16 @@ bool MaemoPackageCreationStep::createPackage()
env.insert(envPattern.cap(1), envPattern.cap(2));
} while (!line.isEmpty());
QProcess buildProc;
buildProc.setProcessEnvironment(env);
buildProc.setWorkingDirectory(buildDir);
buildProc.start("cd " + buildDir);
buildProc.waitForFinished();
m_buildProc.reset(new QProcess);
connect(m_buildProc.data(), SIGNAL(readyReadStandardOutput()), this,
SLOT(handleBuildOutput()));
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
// 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()) {
const QString command = QLatin1String("dh_make -s -n -p ")
% executableFileName().toLower() % QLatin1Char('_') % versionString();
if (!runCommand(buildProc, command))
if (!runCommand(command))
return false;
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;
// Workaround for non-working dh_builddeb --destdir=.
......@@ -244,7 +249,7 @@ bool MaemoPackageCreationStep::createPackage()
return true;
}
bool MaemoPackageCreationStep::runCommand(QProcess &proc, const QString &command)
bool MaemoPackageCreationStep::runCommand(const QString &command)
{
QTextCharFormat 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
perl = maddeRoot() + QLatin1String("/bin/perl.exe ");
#endif
proc.start(perl + maddeRoot() % QLatin1String("/madbin/") % command);
if (!proc.waitForStarted()) {
m_buildProc->start(perl + maddeRoot() % QLatin1String("/madbin/") % command);
if (!m_buildProc->waitForStarted()) {
raiseError(tr("Packaging failed."),
tr("Packaging error: Could not start command '%1'. Reason: %2")
.arg(command).arg(proc.errorString()));
.arg(command).arg(m_buildProc->errorString()));
return false;
}
proc.write("\n"); // For dh_make
proc.waitForFinished(-1);
if (proc.error() != QProcess::UnknownError || proc.exitCode() != 0) {
m_buildProc->write("\n"); // For dh_make
m_buildProc->waitForFinished(-1);
if (m_buildProc->error() != QProcess::UnknownError || m_buildProc->exitCode() != 0) {
QString mainMessage = tr("Packaging Error: Command '%1' failed.")
.arg(command);
if (proc.error() != QProcess::UnknownError)
mainMessage += tr(" Reason: %1").arg(proc.errorString());
if (m_buildProc->error() != QProcess::UnknownError)
mainMessage += tr(" Reason: %1").arg(m_buildProc->errorString());
else
mainMessage += tr("Exit code: %1").arg(proc.exitCode());
raiseError(mainMessage, mainMessage + QLatin1Char('\n')
+ tr("Output was: ") + proc.readAllStandardError()
+ QLatin1Char('\n') + proc.readAllStandardOutput());
mainMessage += tr("Exit code: %1").arg(m_buildProc->exitCode());
raiseError(mainMessage);
return false;
}
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
{
return static_cast<Qt4BuildConfiguration *>(buildConfiguration());
......
......@@ -44,6 +44,7 @@
#include <projectexplorer/buildstep.h>
#include <QtCore/QScopedPointer>
#include <QtCore/QSharedPointer>
QT_BEGIN_NAMESPACE
......@@ -80,6 +81,9 @@ public:
QString versionString() const;
void setVersionString(const QString &version);
private slots:
void handleBuildOutput();
private:
MaemoPackageCreationStep(ProjectExplorer::BuildConfiguration *buildConfig,
MaemoPackageCreationStep *other);
......@@ -92,7 +96,7 @@ private:
virtual bool fromMap(const QVariantMap &map);
bool createPackage();
bool runCommand(QProcess &proc, const QString &command);
bool runCommand(const QString &command);
const MaemoToolChain *maemoToolChain() const;
QString maddeRoot() const;
QString targetRoot() const;
......@@ -108,6 +112,7 @@ private:
bool m_packagingEnabled;
QString m_versionString;
mutable QSharedPointer<ProFileWrapper> m_proFileWrapper;
QScopedPointer<QProcess> m_buildProc;
};
} // namespace Internal
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment