1 | /**************************************************************************** |
---|---|
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the test suite of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
21 | ** included in the packaging of this file. Please review the following |
22 | ** information to ensure the GNU General Public License requirements will |
23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
24 | ** |
25 | ** $QT_END_LICENSE$ |
26 | ** |
27 | ****************************************************************************/ |
28 | |
29 | #include <QtCore/qcoreapplication.h> |
30 | #include <QtCore/qlibraryinfo.h> |
31 | #include <QtCore/qdebug.h> |
32 | #include <QtQml/qqmldebug.h> |
33 | #include <QtQml/qqmlengine.h> |
34 | |
35 | int main(int argc, char *argv[]) |
36 | { |
37 | QQmlDebuggingEnabler::StartMode block = QQmlDebuggingEnabler::DoNotWaitForClient; |
38 | int portFrom = 0; |
39 | int portTo = 0; |
40 | |
41 | QCoreApplication app(argc, argv); |
42 | QStringList arguments = app.arguments(); |
43 | arguments.removeFirst(); |
44 | QString connector = QLatin1String("QQmlDebugServer"); |
45 | |
46 | if (arguments.size() && arguments.first() == QLatin1String("-block")) { |
47 | block = QQmlDebuggingEnabler::WaitForClient; |
48 | arguments.removeFirst(); |
49 | } |
50 | |
51 | if (arguments.size() >= 2 && arguments.first() == QLatin1String("-connector")) { |
52 | arguments.removeFirst(); |
53 | connector = arguments.takeFirst(); |
54 | } |
55 | |
56 | if (arguments.size() >= 2) { |
57 | portFrom = arguments.takeFirst().toInt(); |
58 | portTo = arguments.takeFirst().toInt(); |
59 | } |
60 | |
61 | if (arguments.size() && arguments.takeFirst() == QLatin1String("-services")) |
62 | QQmlDebuggingEnabler::setServices(arguments); |
63 | |
64 | if (connector == QLatin1String("QQmlDebugServer")) { |
65 | if (!portFrom || !portTo) |
66 | qFatal(msg: "Port range has to be specified."); |
67 | |
68 | while (portFrom <= portTo) |
69 | QQmlDebuggingEnabler::startTcpDebugServer(port: portFrom++, mode: block); |
70 | } else if (connector == QLatin1String("QQmlNativeDebugConnector")) { |
71 | QVariantHash configuration; |
72 | configuration[QLatin1String("block")] = (block == QQmlDebuggingEnabler::WaitForClient); |
73 | QQmlDebuggingEnabler::startDebugConnector(pluginName: connector, configuration); |
74 | } |
75 | |
76 | QQmlEngine engine; |
77 | qDebug() << "QQmlEngine created\n"; |
78 | Q_UNUSED(engine); |
79 | return app.exec(); |
80 | } |
81 | |
82 |