forked from qt-creator/qt-creator
Maemo: Move MADDE environment information out of MaemoToolChain class.
The toolchain is not available in all places where we need the respective information, which resulted in duplicated code.
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
#include "maemodeviceconfigurations.h"
|
||||
|
||||
#include <coreplugin/ssh/sshconnection.h>
|
||||
#include <qt4projectmanager/qtversionmanager.h>
|
||||
#include <utils/environment.h>
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
@@ -107,17 +108,42 @@ QString MaemoGlobal::failedToConnectToServerMessage(const Core::SshConnection::P
|
||||
return errorMsg;
|
||||
}
|
||||
|
||||
QString MaemoGlobal::maddeRoot(const QString &qmakePath)
|
||||
QString MaemoGlobal::maddeRoot(const QtVersion *qtVersion)
|
||||
{
|
||||
QDir dir(QDir::cleanPath(qmakePath).remove(binQmake));
|
||||
QDir dir(targetRoot(qtVersion));
|
||||
dir.cdUp(); dir.cdUp();
|
||||
return dir.absolutePath();
|
||||
}
|
||||
|
||||
QString MaemoGlobal::targetName(const QString &qmakePath)
|
||||
QString MaemoGlobal::targetRoot(const QtVersion *qtVersion)
|
||||
{
|
||||
const QString target = QDir::cleanPath(qmakePath).remove(binQmake);
|
||||
return target.mid(target.lastIndexOf(QLatin1Char('/')) + 1);
|
||||
return QDir::cleanPath(qtVersion->qmakeCommand()).remove(binQmake);
|
||||
}
|
||||
|
||||
QString MaemoGlobal::targetName(const QtVersion *qtVersion)
|
||||
{
|
||||
return QDir(targetRoot(qtVersion)).dirName();
|
||||
}
|
||||
|
||||
QString MaemoGlobal::madAdminCommand(const QtVersion *qtVersion)
|
||||
{
|
||||
return maddeRoot(qtVersion) + QLatin1String("/bin/mad-admin");
|
||||
}
|
||||
|
||||
QString MaemoGlobal::madCommand(const QtVersion *qtVersion)
|
||||
{
|
||||
return maddeRoot(qtVersion) + QLatin1String("/bin/mad");
|
||||
}
|
||||
|
||||
MaemoGlobal::MaemoVersion MaemoGlobal::version(const QtVersion *qtVersion)
|
||||
{
|
||||
const QString &name = targetName(qtVersion);
|
||||
if (name.startsWith(QLatin1String("fremantle")))
|
||||
return Maemo5;
|
||||
if (name.startsWith(QLatin1String("harmattan")))
|
||||
return Maemo6;
|
||||
qWarning("Unknown Maemo version!");
|
||||
return static_cast<MaemoVersion>(-1);
|
||||
}
|
||||
|
||||
bool MaemoGlobal::removeRecursively(const QString &filePath, QString &error)
|
||||
@@ -150,9 +176,25 @@ bool MaemoGlobal::removeRecursively(const QString &filePath, QString &error)
|
||||
return true;
|
||||
}
|
||||
|
||||
void MaemoGlobal::callMaddeShellScript(QProcess &proc, const QString &maddeRoot,
|
||||
bool MaemoGlobal::callMad(QProcess &proc, const QStringList &args,
|
||||
const QtVersion *qtVersion)
|
||||
{
|
||||
return callMaddeShellScript(proc, maddeRoot(qtVersion),
|
||||
madCommand(qtVersion), args);
|
||||
}
|
||||
|
||||
bool MaemoGlobal::callMadAdmin(QProcess &proc, const QStringList &args,
|
||||
const QtVersion *qtVersion)
|
||||
{
|
||||
return callMaddeShellScript(proc, maddeRoot(qtVersion),
|
||||
madAdminCommand(qtVersion), args);
|
||||
}
|
||||
|
||||
bool MaemoGlobal::callMaddeShellScript(QProcess &proc, const QString &maddeRoot,
|
||||
const QString &command, const QStringList &args)
|
||||
{
|
||||
if (!QFileInfo(command).exists())
|
||||
return false;
|
||||
QString actualCommand = command;
|
||||
QStringList actualArgs = args;
|
||||
#ifdef Q_OS_WIN
|
||||
@@ -167,6 +209,7 @@ void MaemoGlobal::callMaddeShellScript(QProcess &proc, const QString &maddeRoot,
|
||||
Q_UNUSED(maddeRoot);
|
||||
#endif
|
||||
proc.start(actualCommand, actualArgs);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user