2013-07-19 16:08:54 +02:00
|
|
|
/****************************************************************************
|
2011-12-27 22:41:31 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 Kläralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-12-27 22:41:31 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-12-27 22:41:31 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2011-12-27 22:41:31 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2011-12-27 22:41:31 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-12-27 22:41:31 +01:00
|
|
|
|
2013-07-19 16:08:54 +02:00
|
|
|
#include "qmlprofilerruncontrolfactory.h"
|
2015-07-01 18:11:54 +02:00
|
|
|
#include "qmlprofilerruncontrol.h"
|
2015-08-28 12:50:46 +02:00
|
|
|
#include "qmlprofilerrunconfigurationaspect.h"
|
2011-12-27 22:41:31 +01:00
|
|
|
|
2016-02-26 14:14:49 +01:00
|
|
|
#include <debugger/analyzer/analyzermanager.h>
|
2016-02-24 14:42:52 +01:00
|
|
|
#include <debugger/analyzer/analyzerstartparameters.h>
|
2013-07-30 11:33:03 +02:00
|
|
|
#include <debugger/debuggerrunconfigurationaspect.h>
|
|
|
|
|
|
|
|
|
|
#include <projectexplorer/environmentaspect.h>
|
2013-07-19 16:08:54 +02:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2016-01-25 15:00:20 +01:00
|
|
|
#include <projectexplorer/runnables.h>
|
2013-07-30 11:33:03 +02:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
|
#include <projectexplorer/session.h>
|
2013-07-19 16:08:54 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2015-11-17 16:42:21 +01:00
|
|
|
#include <qtsupport/baseqtversion.h>
|
|
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2011-12-27 22:41:31 +01:00
|
|
|
|
2013-07-19 16:08:54 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2011-12-27 22:41:31 +01:00
|
|
|
|
2016-03-02 13:57:37 +01:00
|
|
|
using namespace Debugger;
|
2011-12-27 22:41:31 +01:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
2013-07-19 16:08:54 +02:00
|
|
|
namespace QmlProfiler {
|
2011-12-27 22:41:31 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2016-01-25 15:00:20 +01:00
|
|
|
static bool isLocal(RunConfiguration *runConfiguration)
|
|
|
|
|
{
|
|
|
|
|
Target *target = runConfiguration ? runConfiguration->target() : 0;
|
|
|
|
|
Kit *kit = target ? target->kit() : 0;
|
|
|
|
|
return DeviceTypeKitInformation::deviceTypeId(kit) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-19 16:08:54 +02:00
|
|
|
QmlProfilerRunControlFactory::QmlProfilerRunControlFactory(QObject *parent) :
|
2011-12-27 22:41:31 +01:00
|
|
|
IRunControlFactory(parent)
|
|
|
|
|
{
|
2017-05-29 16:04:31 +02:00
|
|
|
RunControl::registerWorkerCreator(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE,
|
|
|
|
|
[this](RunControl *runControl) { return new QmlProfilerRunner(runControl); });
|
2011-12-27 22:41:31 +01:00
|
|
|
}
|
|
|
|
|
|
2015-06-29 10:36:29 +03:00
|
|
|
bool QmlProfilerRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const
|
2011-12-27 22:41:31 +01:00
|
|
|
{
|
2016-01-25 15:00:20 +01:00
|
|
|
return mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE && isLocal(runConfiguration);
|
2011-12-27 22:41:31 +01:00
|
|
|
}
|
|
|
|
|
|
2017-05-29 16:04:31 +02:00
|
|
|
RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfiguration, Core::Id mode, QString *)
|
2013-07-30 11:33:03 +02:00
|
|
|
{
|
2016-01-19 17:25:18 +01:00
|
|
|
QTC_ASSERT(canRun(runConfiguration, mode), return 0);
|
2016-01-25 15:00:20 +01:00
|
|
|
QTC_ASSERT(runConfiguration->runnable().is<StandardRunnable>(), return 0);
|
2016-01-27 16:02:28 +01:00
|
|
|
|
2016-01-25 15:00:20 +01:00
|
|
|
Kit *kit = runConfiguration->target()->kit();
|
2016-01-19 17:25:18 +01:00
|
|
|
AnalyzerConnection connection;
|
|
|
|
|
const QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit);
|
2015-11-17 16:42:21 +01:00
|
|
|
if (version) {
|
2016-02-09 10:46:36 +01:00
|
|
|
if (version->qtVersion() >= QtSupport::QtVersionNumber(5, 6, 0))
|
2017-05-29 16:04:31 +02:00
|
|
|
connection.analyzerSocket = QmlProfilerRunner::findFreeSocket();
|
2015-11-17 16:42:21 +01:00
|
|
|
else
|
2017-05-29 16:04:31 +02:00
|
|
|
connection.analyzerPort = QmlProfilerRunner::findFreePort(connection.analyzerHost);
|
2015-11-17 16:42:21 +01:00
|
|
|
} else {
|
|
|
|
|
qWarning() << "Running QML profiler on Kit without Qt version??";
|
2017-05-29 16:04:31 +02:00
|
|
|
connection.analyzerPort = QmlProfilerRunner::findFreePort(connection.analyzerHost);
|
2015-11-17 16:42:21 +01:00
|
|
|
}
|
2013-10-11 11:32:50 +02:00
|
|
|
|
2017-05-29 13:14:16 +02:00
|
|
|
auto runControl = new RunControl(runConfiguration, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
2016-01-19 17:25:18 +01:00
|
|
|
runControl->setConnection(connection);
|
|
|
|
|
|
2017-05-29 16:04:31 +02:00
|
|
|
QmlProfilerRunner::Configuration conf;
|
2016-01-19 17:25:18 +01:00
|
|
|
conf.socket = connection.analyzerSocket;
|
|
|
|
|
conf.port = connection.analyzerPort;
|
|
|
|
|
|
2017-05-29 16:04:31 +02:00
|
|
|
auto runner = new QmlProfilerRunner(runControl);
|
|
|
|
|
runner->setLocalConfiguration(conf);
|
2016-01-19 17:25:18 +01:00
|
|
|
return runControl;
|
2011-12-27 22:41:31 +01:00
|
|
|
}
|
|
|
|
|
|
2015-08-28 12:50:46 +02:00
|
|
|
ProjectExplorer::IRunConfigurationAspect *
|
|
|
|
|
QmlProfilerRunControlFactory::createRunConfigurationAspect(ProjectExplorer::RunConfiguration *rc)
|
|
|
|
|
{
|
|
|
|
|
return new QmlProfilerRunConfigurationAspect(rc);
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-27 22:41:31 +01:00
|
|
|
} // namespace Internal
|
2013-07-19 16:08:54 +02:00
|
|
|
} // namespace QmlProfiler
|