Commit 16c91946 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

Maemo: Get rid of some environment setting redundancies.

Reviewed-by: kh1
parent 1ff82ca8
......@@ -29,8 +29,12 @@
#include "maemoglobal.h"
#include <utils/environment.h>
#include <QtCore/QCoreApplication>
#include <QtGui/QDesktopServices>
#include <QtCore/QDir>
#include <QtCore/QProcess>
#include <QtCore/QString>
#define TR(text) QCoreApplication::translate("Qt4ProjectManager::Internal::MaemoGlobal", text)
......@@ -104,5 +108,24 @@ bool MaemoGlobal::removeRecursively(const QString &filePath, QString &error)
return true;
}
void MaemoGlobal::callMaddeShellScript(QProcess &proc, const QString &maddeRoot,
const QString &command, const QStringList &args)
{
QString actualCommand = command;
QStringList actualArgs = args;
#ifdef Q_OS_WIN
Utils::Environment env(proc.environment());
env.prependOrSetPath(maddeRoot + QLatin1String("/bin"));
env.prependOrSet(QLatin1String("HOME"),
QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
proc.setEnvironment(env.toStringList());
actualArgs.prepend(command);
actualCommand = maddeRoot + QLatin1String("/bin/sh.exe");
#else
Q_UNUSED(maddeRoot);
#endif
proc.start(actualCommand, actualArgs);
}
} // namespace Internal
} // namespace Qt4ProjectManager
......@@ -42,6 +42,7 @@
MaemoGlobal::assertState<State>(expected, actual, Q_FUNC_INFO)
QT_BEGIN_NAMESPACE
class QProcess;
class QString;
QT_END_NAMESPACE
......@@ -58,6 +59,8 @@ public:
static QString remoteSourceProfilesCommand();
static bool removeRecursively(const QString &filePath, QString &error);
static void callMaddeShellScript(QProcess &proc, const QString &maddeRoot,
const QString &command, const QStringList &args);
template<class T> static T *buildStep(const ProjectExplorer::DeployConfiguration *dc)
{
......
......@@ -32,6 +32,7 @@
#include "maemoconstants.h"
#include "maemodeploystepfactory.h"
#include "maemodeviceconfigurations.h"
#include "maemoglobal.h"
#include "maemopackagecreationfactory.h"
#include "maemopublishingwizardfactories.h"
#include "maemoqemumanager.h"
......@@ -106,25 +107,14 @@ bool MaemoManager::isValidMaemoQtVersion(const QtVersion *version) const
QDir dir(path);
const QByteArray target = dir.dirName().toAscii();
dir.cdUp(); dir.cdUp();
QString madAdminCommand(dir.absolutePath() + QLatin1String("/bin/mad-admin"));
const QString madAdminCommand(dir.absolutePath() + QLatin1String("/bin/mad-admin"));
if (!QFileInfo(madAdminCommand).exists())
return false;
QProcess madAdminProc;
QStringList arguments(QLatin1String("list"));
#ifdef Q_OS_WIN
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.insert(QLatin1String("PATH"),
QDir::toNativeSeparators(dir.absolutePath() % QLatin1String("/bin"))
% QLatin1Char(';') % env.value(QLatin1String("PATH")));
madAdminProc.setProcessEnvironment(env);
arguments.prepend(madAdminCommand);
madAdminCommand = dir.absolutePath() + QLatin1String("/bin/sh.exe");
#endif
madAdminProc.start(madAdminCommand, arguments);
const QStringList arguments(QLatin1String("list"));
MaemoGlobal::callMaddeShellScript(madAdminProc, dir.absolutePath(),
madAdminCommand, arguments);
if (!madAdminProc.waitForStarted() || !madAdminProc.waitForFinished())
return false;
......
......@@ -315,16 +315,11 @@ void MaemoPublisherFremantleFree::runDpkgBuildPackage()
emit progressReport(tr("Building source package..."));
const MaemoToolChain * const tc
= dynamic_cast<MaemoToolChain *>(m_buildConfig->toolChain());
QStringList args = QStringList() << QLatin1String("-t")
const QStringList args = QStringList() << QLatin1String("-t")
<< tc->targetName() << QLatin1String("dpkg-buildpackage")
<< QLatin1String("-S") << QLatin1String("-us") << QLatin1String("-uc");
QString madCommand = tc->maddeRoot() + QLatin1String("/bin/mad");
#ifdef Q_OS_WIN
args.prepend(madCommand);
madCommand = tc->maddeRoot() + QLatin1String("/bin/sh.exe");
#endif
m_process->start(madCommand, args);
const QString madCommand = tc->maddeRoot() + QLatin1String("/bin/mad");
MaemoGlobal::callMaddeShellScript(*m_process, tc->maddeRoot(), madCommand, args);
}
// We have to implement the SCP protocol, because the maemo.org
......
......@@ -29,6 +29,7 @@
#include "maemoqemumanager.h"
#include "maemoglobal.h"
#include "maemorunconfiguration.h"
#include "maemotoolchain.h"
#include "qtversionmanager.h"
......@@ -224,7 +225,7 @@ void MaemoQemuManager::projectChanged(ProjectExplorer::Project *project)
bool targetIsMaemo(const QString &id)
{
return id == QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID);
return id == QLatin1String(Qt4ProjectManager::Constants::MAEMO_DEVICE_TARGET_ID);
}
void MaemoQemuManager::targetAdded(ProjectExplorer::Target *target)
......@@ -680,28 +681,14 @@ QString MaemoQemuManager::runtimeForQtVersion(const QString &qmakeCommand) const
const QString &target = targetRoot(qmakeCommand);
const QString &madRoot = maddeRoot(qmakeCommand);
QString madCommand = madRoot + QLatin1String("/bin/mad");
const QString madCommand = madRoot + QLatin1String("/bin/mad");
if (!QFileInfo(madCommand).exists())
return QString();
QProcess madProc;
QStringList arguments(QLatin1String("info"));
const QStringList arguments(QLatin1String("info"));
#ifdef Q_OS_WIN
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.insert("HOME",
QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
env.insert(QLatin1String("PATH"),
QDir::toNativeSeparators(madRoot % QLatin1String("/bin"))
% QLatin1Char(';') % env.value(QLatin1String("PATH")));
madProc.setProcessEnvironment(env);
arguments.prepend(madCommand);
madCommand = madRoot + QLatin1String("/bin/sh.exe");
#endif
madProc.start(madCommand, arguments);
MaemoGlobal::callMaddeShellScript(madProc, madRoot, madCommand, arguments);
if (!madProc.waitForStarted() || !madProc.waitForFinished())
return QString();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment