2013-05-03 12:41:58 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2013-05-03 12:41:58 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "androidanalyzesupport.h"
|
|
|
|
|
|
|
|
|
|
#include "androidrunner.h"
|
|
|
|
|
#include "androidmanager.h"
|
|
|
|
|
|
2013-07-22 16:20:04 +02:00
|
|
|
#include <analyzerbase/ianalyzertool.h>
|
|
|
|
|
#include <analyzerbase/analyzermanager.h>
|
|
|
|
|
#include <analyzerbase/analyzerruncontrol.h>
|
|
|
|
|
#include <analyzerbase/analyzerstartparameters.h>
|
2013-05-03 12:41:58 +02:00
|
|
|
|
|
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
|
#include <qtsupport/qtkitinformation.h>
|
|
|
|
|
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QTcpServer>
|
|
|
|
|
|
|
|
|
|
using namespace Analyzer;
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
|
|
namespace Android {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfiguration *runConfig,
|
2013-08-02 15:39:33 +02:00
|
|
|
RunMode runMode)
|
2013-05-03 12:41:58 +02:00
|
|
|
{
|
2013-08-01 15:02:42 +02:00
|
|
|
Target *target = runConfig->target();
|
2013-05-03 12:41:58 +02:00
|
|
|
AnalyzerStartParameters params;
|
2013-07-30 14:08:01 +02:00
|
|
|
params.runMode = runMode;
|
2013-05-03 12:41:58 +02:00
|
|
|
params.displayName = AndroidManager::packageName(target);
|
|
|
|
|
params.sysroot = SysRootKitInformation::sysRoot(target->kit()).toString();
|
|
|
|
|
// TODO: Not sure if these are the right paths.
|
2014-05-02 12:53:36 +02:00
|
|
|
params.workingDirectory = target->project()->projectDirectory().toString();
|
2013-05-03 12:41:58 +02:00
|
|
|
if (runMode == ProjectExplorer::QmlProfilerRunMode) {
|
|
|
|
|
QTcpServer server;
|
|
|
|
|
QTC_ASSERT(server.listen(QHostAddress::LocalHost)
|
|
|
|
|
|| server.listen(QHostAddress::LocalHostIPv6), return 0);
|
|
|
|
|
params.analyzerHost = server.serverAddress().toString();
|
2013-08-02 16:53:48 +02:00
|
|
|
params.startMode = StartLocal;
|
2013-05-03 12:41:58 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-02 15:39:33 +02:00
|
|
|
AnalyzerRunControl *analyzerRunControl = AnalyzerManager::createRunControl(params, runConfig);
|
2013-07-30 14:08:01 +02:00
|
|
|
(void) new AndroidAnalyzeSupport(runConfig, analyzerRunControl);
|
2013-05-03 12:41:58 +02:00
|
|
|
return analyzerRunControl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AndroidAnalyzeSupport::AndroidAnalyzeSupport(AndroidRunConfiguration *runConfig,
|
|
|
|
|
AnalyzerRunControl *runControl)
|
|
|
|
|
: AndroidRunSupport(runConfig, runControl),
|
2013-07-30 14:08:01 +02:00
|
|
|
m_runControl(0),
|
2013-07-22 16:10:27 +02:00
|
|
|
m_qmlPort(0)
|
2013-05-03 12:41:58 +02:00
|
|
|
{
|
|
|
|
|
if (runControl) {
|
2013-07-30 14:08:01 +02:00
|
|
|
m_runControl = runControl;
|
|
|
|
|
connect(m_runControl, SIGNAL(starting(const Analyzer::AnalyzerRunControl*)),
|
|
|
|
|
m_runner, SLOT(start()));
|
2013-05-03 12:41:58 +02:00
|
|
|
}
|
2013-07-22 16:10:27 +02:00
|
|
|
connect(&m_outputParser, SIGNAL(waitingForConnectionOnPort(quint16)),
|
|
|
|
|
SLOT(remoteIsRunning()));
|
2013-05-06 14:16:23 +02:00
|
|
|
connect(m_runner, SIGNAL(remoteProcessStarted(int)),
|
|
|
|
|
SLOT(handleRemoteProcessStarted(int)));
|
2013-05-07 09:58:32 +02:00
|
|
|
connect(m_runner, SIGNAL(remoteProcessFinished(QString)),
|
|
|
|
|
SLOT(handleRemoteProcessFinished(QString)));
|
|
|
|
|
|
|
|
|
|
connect(m_runner, SIGNAL(remoteErrorOutput(QByteArray)),
|
|
|
|
|
SLOT(handleRemoteErrorOutput(QByteArray)));
|
|
|
|
|
connect(m_runner, SIGNAL(remoteOutput(QByteArray)),
|
|
|
|
|
SLOT(handleRemoteOutput(QByteArray)));
|
2013-05-03 12:41:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidAnalyzeSupport::handleRemoteProcessStarted(int qmlPort)
|
|
|
|
|
{
|
2013-07-22 16:10:27 +02:00
|
|
|
m_qmlPort = qmlPort;
|
2013-05-03 12:41:58 +02:00
|
|
|
}
|
|
|
|
|
|
2014-03-18 13:00:21 +01:00
|
|
|
void AndroidAnalyzeSupport::handleRemoteProcessFinished(const QString &errorMsg)
|
|
|
|
|
{
|
|
|
|
|
if (m_runControl)
|
|
|
|
|
m_runControl->notifyRemoteFinished();
|
|
|
|
|
AndroidRunSupport::handleRemoteProcessFinished(errorMsg);
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-03 12:41:58 +02:00
|
|
|
void AndroidAnalyzeSupport::handleRemoteOutput(const QByteArray &output)
|
|
|
|
|
{
|
2013-07-22 16:10:27 +02:00
|
|
|
const QString msg = QString::fromUtf8(output);
|
2013-07-30 14:08:01 +02:00
|
|
|
if (m_runControl)
|
|
|
|
|
m_runControl->logApplicationMessage(msg, Utils::StdOutFormatSameLine);
|
2013-05-03 12:41:58 +02:00
|
|
|
else
|
|
|
|
|
AndroidRunSupport::handleRemoteOutput(output);
|
2013-07-22 16:10:27 +02:00
|
|
|
m_outputParser.processOutput(msg);
|
2013-05-03 12:41:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidAnalyzeSupport::handleRemoteErrorOutput(const QByteArray &output)
|
|
|
|
|
{
|
2014-03-13 14:45:33 +01:00
|
|
|
const QString msg = QString::fromUtf8(output);
|
2013-07-30 14:08:01 +02:00
|
|
|
if (m_runControl)
|
2014-03-13 14:45:33 +01:00
|
|
|
m_runControl->logApplicationMessage(msg, Utils::StdErrFormatSameLine);
|
2013-05-03 12:41:58 +02:00
|
|
|
else
|
|
|
|
|
AndroidRunSupport::handleRemoteErrorOutput(output);
|
2014-03-13 14:45:33 +01:00
|
|
|
m_outputParser.processOutput(msg);
|
2013-05-03 12:41:58 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-22 16:10:27 +02:00
|
|
|
void AndroidAnalyzeSupport::remoteIsRunning()
|
|
|
|
|
{
|
2013-07-30 14:08:01 +02:00
|
|
|
if (m_runControl)
|
|
|
|
|
m_runControl->notifyRemoteSetupDone(m_qmlPort);
|
2013-07-22 16:10:27 +02:00
|
|
|
}
|
|
|
|
|
|
2013-05-03 12:41:58 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Android
|