forked from qt-creator/qt-creator
Maemo: get rid of dependency on madde.conf.
Parse script output instead. Done-with: kh1
This commit is contained in:
@@ -98,22 +98,30 @@ MaemoManager &MaemoManager::instance()
|
|||||||
bool MaemoManager::isValidMaemoQtVersion(const QtVersion *version) const
|
bool MaemoManager::isValidMaemoQtVersion(const QtVersion *version) const
|
||||||
{
|
{
|
||||||
QString path = QDir::cleanPath(version->qmakeCommand());
|
QString path = QDir::cleanPath(version->qmakeCommand());
|
||||||
path = path.remove(QLatin1String("/bin/qmake" EXEC_SUFFIX));
|
path.remove(QLatin1String("/bin/qmake" EXEC_SUFFIX));
|
||||||
|
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
|
const QByteArray target = dir.dirName().toAscii();
|
||||||
dir.cdUp(); dir.cdUp();
|
dir.cdUp(); dir.cdUp();
|
||||||
|
QString madAdminCommand(dir.absolutePath() + QLatin1String("/bin/mad-admin"));
|
||||||
|
if (!QFileInfo(madAdminCommand).exists())
|
||||||
|
return false;
|
||||||
|
|
||||||
QFile file(dir.absolutePath() + QLatin1String("/cache/madde.conf"));
|
QStringList arguments(QLatin1String("list"));
|
||||||
if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
#ifdef Q_OS_WIN
|
||||||
const QString &target = path.mid(path.lastIndexOf(QLatin1Char('/')) + 1);
|
arguments.prepend(madAdminCommand);
|
||||||
QTextStream stream(&file);
|
madAdminCommand = dir.absolutePath() + QLatin1String("/bin/sh.exe");
|
||||||
while (!stream.atEnd()) {
|
#endif
|
||||||
const QString &line = stream.readLine().trimmed();
|
|
||||||
if (line.startsWith(QLatin1String("target"))
|
QProcess madAdminProc;
|
||||||
&& line.endsWith(target)) {
|
madAdminProc.start(madAdminCommand, arguments);
|
||||||
return true;
|
if (!madAdminProc.waitForStarted() || !madAdminProc.waitForFinished())
|
||||||
}
|
return false;
|
||||||
}
|
|
||||||
|
madAdminProc.setReadChannel(QProcess::StandardOutput);
|
||||||
|
while (madAdminProc.canReadLine()) {
|
||||||
|
const QByteArray &line = madAdminProc.readLine();
|
||||||
|
if (line.contains(target) && line.contains("(installed)"))
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,14 +45,18 @@
|
|||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/session.h>
|
#include <projectexplorer/session.h>
|
||||||
|
|
||||||
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
#include <QtCore/QSet>
|
#include <QtCore/QSet>
|
||||||
#include <QtCore/QStringBuilder>
|
#include <QtCore/QStringBuilder>
|
||||||
#include <QtCore/QTextStream>
|
#include <QtCore/QTextStream>
|
||||||
|
|
||||||
#include <QtGui/QMessageBox>
|
|
||||||
#include <QtGui/QAction>
|
#include <QtGui/QAction>
|
||||||
|
#include <QtGui/QDesktopServices>
|
||||||
|
#include <QtGui/QMessageBox>
|
||||||
|
|
||||||
|
#include <QtXml/QXmlStreamReader>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace Qt4ProjectManager;
|
using namespace Qt4ProjectManager;
|
||||||
@@ -663,32 +667,56 @@ 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);
|
||||||
|
|
||||||
QFile file(madRoot + QLatin1String("/cache/madde.conf"));
|
QString madCommand = madRoot + QLatin1String("/bin/mad");
|
||||||
if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if (!QFileInfo(madCommand).exists())
|
||||||
QTextStream stream(&file);
|
return QString();
|
||||||
while (!stream.atEnd()) {
|
|
||||||
QString line = stream.readLine().trimmed();
|
|
||||||
if (!line.startsWith(QLatin1String("target")))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
const QStringList &list = line.split(QLatin1Char(' '));
|
QProcess madProc;
|
||||||
if (list.count() <= 1 || list.at(1) != target)
|
QStringList arguments(QLatin1String("info"));
|
||||||
continue;
|
|
||||||
|
|
||||||
line = stream.readLine().trimmed();
|
#ifdef Q_OS_WIN
|
||||||
while (!stream.atEnd() && line != QLatin1String("end")) {
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||||
if (line.startsWith(QLatin1String("runtime"))) {
|
env.insert("HOME",
|
||||||
const QStringList &list = line.split(QLatin1Char(' '));
|
QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
|
||||||
if (list.count() > 1) {
|
madProc.setProcessEnvironment(env);
|
||||||
return QDir::fromNativeSeparators(madRoot
|
|
||||||
+ QLatin1String("/runtimes/") + list.at(1).trimmed());
|
arguments.prepend(madCommand);
|
||||||
|
madCommand = madRoot + QLatin1String("/bin/sh.exe");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
madProc.start(madCommand, arguments);
|
||||||
|
if (!madProc.waitForStarted() || !madProc.waitForFinished())
|
||||||
|
return QString();
|
||||||
|
|
||||||
|
QStringList installedRuntimes;
|
||||||
|
QString targetRuntime;
|
||||||
|
QXmlStreamReader infoReader(madProc.readAllStandardOutput());
|
||||||
|
while (!infoReader.atEnd() && !installedRuntimes.contains(targetRuntime)) {
|
||||||
|
if (infoReader.readNext() == QXmlStreamReader::StartElement) {
|
||||||
|
if (targetRuntime.isEmpty()
|
||||||
|
&& infoReader.name() == QLatin1String("target")) {
|
||||||
|
const QXmlStreamAttributes &attrs = infoReader.attributes();
|
||||||
|
if (attrs.value(QLatin1String("target_id")) == target)
|
||||||
|
targetRuntime = attrs.value("runtime_id").toString();
|
||||||
|
} else if (infoReader.name() == QLatin1String("runtime")) {
|
||||||
|
const QXmlStreamAttributes attrs = infoReader.attributes();
|
||||||
|
while (!infoReader.atEnd()) {
|
||||||
|
if (infoReader.readNext() == QXmlStreamReader::EndElement
|
||||||
|
&& infoReader.name() == QLatin1String("runtime"))
|
||||||
|
break;
|
||||||
|
if (infoReader.tokenType() == QXmlStreamReader::StartElement
|
||||||
|
&& infoReader.name() == QLatin1String("installed")) {
|
||||||
|
if (infoReader.readNext() == QXmlStreamReader::Characters
|
||||||
|
&& infoReader.text() == QLatin1String("true"))
|
||||||
|
installedRuntimes << attrs.value(QLatin1String("runtime_id")).toString();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
line = stream.readLine().trimmed();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (installedRuntimes.contains(targetRuntime))
|
||||||
|
return madRoot + QLatin1String("/runtimes/") + targetRuntime;
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user