Commit 0e8ac9b6 authored by hjk's avatar hjk

android: simplify code, pull out common subexpressions

Change-Id: If3540328c0f2f0af375ccaba2e10c5417e8f1ed9
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 90dae025
......@@ -62,31 +62,50 @@ static const char * const qMakeVariables[] = {
"QT_INSTALL_IMPORTS"
};
static Qt4Project *project(AndroidRunConfiguration *rc)
{ return static_cast<Qt4Project *>(rc->target()->project()); }
static QStringList qtSoPaths(QtSupport::BaseQtVersion *qtVersion)
{
if (!qtVersion)
return QStringList();
QSet<QString> paths;
for (uint i = 0; i < sizeof qMakeVariables / sizeof qMakeVariables[0]; ++i) {
QString path = qtVersion->qmakeProperty(qMakeVariables[i]);
if (path.isNull())
continue;
QDirIterator it(path, QStringList() << QLatin1String("*.so"), QDir::Files, QDirIterator::Subdirectories);
while (it.hasNext()) {
it.next();
paths.insert(it.fileInfo().absolutePath());
}
}
return paths.toList();
}
RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration *runConfig)
{
Target *target = runConfig->target();
Qt4Project *project = static_cast<Qt4Project *>(target->project());
DebuggerStartParameters params;
params.startMode = AttachToRemoteServer;
params.displayName = AndroidManager::packageName(runConfig->target());
params.displayName = AndroidManager::packageName(target);
params.remoteSetupNeeded = true;
if (runConfig->debuggerAspect()->useCppDebugger()) {
params.languages |= CppLanguage;
Profile *profile = runConfig->target()->profile();
Profile *profile = target->profile();
params.sysRoot = SysRootProfileInformation::sysRoot(profile).toString();
params.debuggerCommand = DebuggerProfileInformation::debuggerCommand(profile).toString();
if (ToolChain *tc = ToolChainProfileInformation::toolChain(profile))
params.toolChainAbi = tc->targetAbi();
params.executable = project(runConfig)->rootQt4ProjectNode()->buildDir() + QLatin1String("/app_process");
params.executable = project->rootQt4ProjectNode()->buildDir() + QLatin1String("/app_process");
params.remoteChannel = runConfig->remoteChannel();
params.solibSearchPath.clear();
QList<Qt4ProFileNode *> nodes = project(runConfig)->allProFiles();
QList<Qt4ProFileNode *> nodes = project->allProFiles();
foreach (Qt4ProFileNode *node, nodes)
if (node->projectType() == ApplicationTemplate)
params.solibSearchPath.append(node->targetInformation().buildDir);
QtSupport::BaseQtVersion *version = QtSupport::QtProfileInformation::qtVersion(runConfig->target()->profile());
QtSupport::BaseQtVersion *version = QtSupport::QtProfileInformation::qtVersion(profile);
params.solibSearchPath.append(qtSoPaths(version));
}
if (runConfig->debuggerAspect()->useQmlDebugger()) {
......@@ -94,9 +113,9 @@ RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration *
params.qmlServerAddress = QLatin1String("localhost");
params.qmlServerPort = runConfig->debuggerAspect()->qmlDebugServerPort();
//TODO: Not sure if these are the right paths.
params.projectSourceDirectory = project(runConfig)->projectDirectory();
params.projectSourceFiles = project(runConfig)->files(Qt4Project::ExcludeGeneratedFiles);
params.projectBuildDirectory = project(runConfig)->rootQt4ProjectNode()->buildDir();
params.projectSourceDirectory = project->projectDirectory();
params.projectSourceFiles = project->files(Qt4Project::ExcludeGeneratedFiles);
params.projectBuildDirectory = project->buildDir();
}
DebuggerRunControl * const debuggerRunControl
......@@ -129,10 +148,6 @@ AndroidDebugSupport::AndroidDebugSupport(AndroidRunConfiguration *runConfig,
SLOT(handleRemoteOutput(QByteArray)));
}
AndroidDebugSupport::~AndroidDebugSupport()
{
}
void AndroidDebugSupport::handleRemoteProcessStarted(int gdbServerPort, int qmlPort)
{
disconnect(m_runner, SIGNAL(remoteProcessStarted(int,int)),
......@@ -167,24 +182,5 @@ void AndroidDebugSupport::handleRemoteErrorOutput(const QByteArray &output)
}
}
QStringList AndroidDebugSupport::qtSoPaths(QtSupport::BaseQtVersion *qtVersion)
{
if (!qtVersion)
return QStringList();
QSet<QString> paths;
for (uint i = 0; i < sizeof qMakeVariables / sizeof qMakeVariables[0]; ++i) {
QString path = qtVersion->qmakeProperty(qMakeVariables[i]);
if (path.isNull())
continue;
QDirIterator it(path, QStringList() << QLatin1String("*.so"), QDir::Files, QDirIterator::Subdirectories);
while (it.hasNext()) {
it.next();
paths.insert(it.fileInfo().absolutePath());
}
}
return paths.toList();
}
} // namespace Internal
} // namespace Android
......@@ -33,10 +33,7 @@
#include "androidrunconfiguration.h"
#include <QObject>
namespace Debugger { class DebuggerRunControl; }
namespace QtSupport {class BaseQtVersion; }
namespace ProjectExplorer { class RunControl; }
namespace Android {
......@@ -54,7 +51,6 @@ public:
AndroidDebugSupport(AndroidRunConfiguration *runConfig,
Debugger::DebuggerRunControl *runControl);
~AndroidDebugSupport();
private slots:
void handleRemoteProcessStarted(int gdbServerPort = -1, int qmlPort = -1);
......@@ -63,9 +59,6 @@ private slots:
void handleRemoteOutput(const QByteArray &output);
void handleRemoteErrorOutput(const QByteArray &output);
private:
static QStringList qtSoPaths(QtSupport::BaseQtVersion *qtVersion);
private:
Debugger::DebuggerRunControl* m_runControl;
AndroidRunner * const m_runner;
......
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