forked from qt-creator/qt-creator
Maemo: Get rid of some environment setting redundancies.
Reviewed-by: kh1
This commit is contained in:
@@ -29,8 +29,12 @@
|
|||||||
|
|
||||||
#include "maemoglobal.h"
|
#include "maemoglobal.h"
|
||||||
|
|
||||||
|
#include <utils/environment.h>
|
||||||
|
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
|
#include <QtGui/QDesktopServices>
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
|
#include <QtCore/QProcess>
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
|
|
||||||
#define TR(text) QCoreApplication::translate("Qt4ProjectManager::Internal::MaemoGlobal", text)
|
#define TR(text) QCoreApplication::translate("Qt4ProjectManager::Internal::MaemoGlobal", text)
|
||||||
@@ -104,5 +108,24 @@ bool MaemoGlobal::removeRecursively(const QString &filePath, QString &error)
|
|||||||
return true;
|
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 Internal
|
||||||
} // namespace Qt4ProjectManager
|
} // namespace Qt4ProjectManager
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
MaemoGlobal::assertState<State>(expected, actual, Q_FUNC_INFO)
|
MaemoGlobal::assertState<State>(expected, actual, Q_FUNC_INFO)
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QProcess;
|
||||||
class QString;
|
class QString;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
@@ -58,6 +59,8 @@ public:
|
|||||||
static QString remoteSourceProfilesCommand();
|
static QString remoteSourceProfilesCommand();
|
||||||
|
|
||||||
static bool removeRecursively(const QString &filePath, QString &error);
|
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)
|
template<class T> static T *buildStep(const ProjectExplorer::DeployConfiguration *dc)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "maemoconstants.h"
|
#include "maemoconstants.h"
|
||||||
#include "maemodeploystepfactory.h"
|
#include "maemodeploystepfactory.h"
|
||||||
#include "maemodeviceconfigurations.h"
|
#include "maemodeviceconfigurations.h"
|
||||||
|
#include "maemoglobal.h"
|
||||||
#include "maemopackagecreationfactory.h"
|
#include "maemopackagecreationfactory.h"
|
||||||
#include "maemopublishingwizardfactories.h"
|
#include "maemopublishingwizardfactories.h"
|
||||||
#include "maemoqemumanager.h"
|
#include "maemoqemumanager.h"
|
||||||
@@ -106,25 +107,14 @@ bool MaemoManager::isValidMaemoQtVersion(const QtVersion *version) const
|
|||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
const QByteArray target = dir.dirName().toAscii();
|
const QByteArray target = dir.dirName().toAscii();
|
||||||
dir.cdUp(); dir.cdUp();
|
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())
|
if (!QFileInfo(madAdminCommand).exists())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QProcess madAdminProc;
|
QProcess madAdminProc;
|
||||||
QStringList arguments(QLatin1String("list"));
|
const QStringList arguments(QLatin1String("list"));
|
||||||
|
MaemoGlobal::callMaddeShellScript(madAdminProc, dir.absolutePath(),
|
||||||
#ifdef Q_OS_WIN
|
madAdminCommand, arguments);
|
||||||
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);
|
|
||||||
if (!madAdminProc.waitForStarted() || !madAdminProc.waitForFinished())
|
if (!madAdminProc.waitForStarted() || !madAdminProc.waitForFinished())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -315,16 +315,11 @@ void MaemoPublisherFremantleFree::runDpkgBuildPackage()
|
|||||||
emit progressReport(tr("Building source package..."));
|
emit progressReport(tr("Building source package..."));
|
||||||
const MaemoToolChain * const tc
|
const MaemoToolChain * const tc
|
||||||
= dynamic_cast<MaemoToolChain *>(m_buildConfig->toolChain());
|
= dynamic_cast<MaemoToolChain *>(m_buildConfig->toolChain());
|
||||||
QStringList args = QStringList() << QLatin1String("-t")
|
const QStringList args = QStringList() << QLatin1String("-t")
|
||||||
<< tc->targetName() << QLatin1String("dpkg-buildpackage")
|
<< tc->targetName() << QLatin1String("dpkg-buildpackage")
|
||||||
<< QLatin1String("-S") << QLatin1String("-us") << QLatin1String("-uc");
|
<< QLatin1String("-S") << QLatin1String("-us") << QLatin1String("-uc");
|
||||||
QString madCommand = tc->maddeRoot() + QLatin1String("/bin/mad");
|
const QString madCommand = tc->maddeRoot() + QLatin1String("/bin/mad");
|
||||||
|
MaemoGlobal::callMaddeShellScript(*m_process, tc->maddeRoot(), madCommand, args);
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
args.prepend(madCommand);
|
|
||||||
madCommand = tc->maddeRoot() + QLatin1String("/bin/sh.exe");
|
|
||||||
#endif
|
|
||||||
m_process->start(madCommand, args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have to implement the SCP protocol, because the maemo.org
|
// We have to implement the SCP protocol, because the maemo.org
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include "maemoqemumanager.h"
|
#include "maemoqemumanager.h"
|
||||||
|
|
||||||
|
#include "maemoglobal.h"
|
||||||
#include "maemorunconfiguration.h"
|
#include "maemorunconfiguration.h"
|
||||||
#include "maemotoolchain.h"
|
#include "maemotoolchain.h"
|
||||||
#include "qtversionmanager.h"
|
#include "qtversionmanager.h"
|
||||||
@@ -224,7 +225,7 @@ void MaemoQemuManager::projectChanged(ProjectExplorer::Project *project)
|
|||||||
|
|
||||||
bool targetIsMaemo(const QString &id)
|
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)
|
void MaemoQemuManager::targetAdded(ProjectExplorer::Target *target)
|
||||||
@@ -680,28 +681,14 @@ QString MaemoQemuManager::runtimeForQtVersion(const QString &qmakeCommand) const
|
|||||||
const QString &target = targetRoot(qmakeCommand);
|
const QString &target = targetRoot(qmakeCommand);
|
||||||
const QString &madRoot = maddeRoot(qmakeCommand);
|
const QString &madRoot = maddeRoot(qmakeCommand);
|
||||||
|
|
||||||
QString madCommand = madRoot + QLatin1String("/bin/mad");
|
const QString madCommand = madRoot + QLatin1String("/bin/mad");
|
||||||
if (!QFileInfo(madCommand).exists())
|
if (!QFileInfo(madCommand).exists())
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
QProcess madProc;
|
QProcess madProc;
|
||||||
QStringList arguments(QLatin1String("info"));
|
const QStringList arguments(QLatin1String("info"));
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
MaemoGlobal::callMaddeShellScript(madProc, madRoot, madCommand, arguments);
|
||||||
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);
|
|
||||||
if (!madProc.waitForStarted() || !madProc.waitForFinished())
|
if (!madProc.waitForStarted() || !madProc.waitForFinished())
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user