2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +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:58:39 +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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:58:39 +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.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include "pluginspec.h"
|
|
|
|
|
|
2016-02-11 11:53:31 +01:00
|
|
|
#include <utils/algorithm.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QSet>
|
|
|
|
|
#include <QStringList>
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QScopedPointer>
|
2013-08-29 15:00:46 +02:00
|
|
|
#include <QReadWriteLock>
|
2010-03-02 12:33:51 +01:00
|
|
|
|
2019-05-27 14:12:11 +02:00
|
|
|
#include <queue>
|
|
|
|
|
|
2010-03-02 12:33:51 +01:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QTime;
|
2012-02-02 10:47:33 +01:00
|
|
|
class QTimer;
|
2010-10-25 16:57:58 +02:00
|
|
|
class QSettings;
|
2011-01-20 14:03:07 +01:00
|
|
|
class QEventLoop;
|
2010-03-02 12:33:51 +01:00
|
|
|
QT_END_NAMESPACE
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
namespace ExtensionSystem {
|
|
|
|
|
|
|
|
|
|
class PluginManager;
|
|
|
|
|
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class PluginSpecPrivate;
|
|
|
|
|
|
2016-05-31 22:36:33 +03:00
|
|
|
class EXTENSIONSYSTEM_EXPORT PluginManagerPrivate : public QObject
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-07-13 13:36:47 +02:00
|
|
|
Q_OBJECT
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
|
|
|
|
PluginManagerPrivate(PluginManager *pluginManager);
|
2018-07-19 23:19:33 +02:00
|
|
|
~PluginManagerPrivate() override;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// Object pool operations
|
|
|
|
|
void addObject(QObject *obj);
|
|
|
|
|
void removeObject(QObject *obj);
|
|
|
|
|
|
|
|
|
|
// Plugin operations
|
|
|
|
|
void loadPlugins();
|
2010-07-13 13:36:47 +02:00
|
|
|
void shutdown();
|
2008-12-02 12:01:29 +01:00
|
|
|
void setPluginPaths(const QStringList &paths);
|
2019-05-27 14:12:11 +02:00
|
|
|
QVector<ExtensionSystem::PluginSpec *> loadQueue();
|
2008-12-02 12:01:29 +01:00
|
|
|
void loadPlugin(PluginSpec *spec, PluginSpec::State destState);
|
|
|
|
|
void resolveDependencies();
|
2017-08-16 13:50:24 +02:00
|
|
|
void enableDependenciesIndirectly();
|
2010-03-02 12:33:51 +01:00
|
|
|
void initProfiling();
|
2013-02-06 13:53:51 +01:00
|
|
|
void profilingSummary() const;
|
2019-05-27 14:12:11 +02:00
|
|
|
void profilingReport(const char *what, const PluginSpec *spec = nullptr);
|
2010-10-25 16:57:58 +02:00
|
|
|
void setSettings(QSettings *settings);
|
2011-10-26 14:46:29 +02:00
|
|
|
void setGlobalSettings(QSettings *settings);
|
2010-10-25 16:57:58 +02:00
|
|
|
void readSettings();
|
2010-03-12 16:02:23 +01:00
|
|
|
void writeSettings();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-01-22 12:54:22 +01:00
|
|
|
class TestSpec {
|
|
|
|
|
public:
|
Plugin Tests: Support additional test objects/classes
So far tests running within Qt Creator could be implemented with a
private slot in the plugin class starting with "test".
Binding the test functions to the plugin object/class is fine for test
functions without side effects. But as soon as side effects come into
play we need proper initialization and cleanup as it's provided by
init(), cleanup(), initTestCase() and cleanupTestCase(). However,
implementing these functions in the plugin class is not appropriate
since they would affect (potentially quite diverse) test functions.
This patch enables us to provide 'ordinary' test classes in which we can
handle initialization and clean up the usual way.
In addition to the current test invocations, e.g.:
# (1) Run all test functions of the plugin
./qtcreator -test CppTools
# (2) Run selected test functions of the plugin by stating them
./qtcreator -test CppTools,test_completion,test_builtinsymbolsearcher
# (3) Run selected test functions of the plugin by a wild card
# expression
./qtcreator -test "CppTools,*pointerdeclaration*"
# (4) Run a test function of the plugin with certain test data
./qtcreator -test CppTools,test_completion:template_1
it's now also possible to state the test class in order to execute all
test functions of that class:
# Run all test functions of a certain class:
./qtcreator -test CppTools,SomeClassWithTests
As long as the test class does not start with "test", there should not
be any problems.
Further, an invocation like (1) now additionally execute all test
functions of all test classes. For invocations of type (2), (3) and (4)
all test functions of all test classes are considered, too.
Change-Id: Ief08a6e9e451c599fd0109b8b8e57f92e3ee19f2
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2015-01-15 13:14:35 +01:00
|
|
|
TestSpec(PluginSpec *pluginSpec, const QStringList &testFunctionsOrObjects = QStringList())
|
2019-05-27 14:12:11 +02:00
|
|
|
: pluginSpec(pluginSpec)
|
|
|
|
|
, testFunctionsOrObjects(testFunctionsOrObjects)
|
|
|
|
|
{}
|
|
|
|
|
PluginSpec *pluginSpec = nullptr;
|
Plugin Tests: Support additional test objects/classes
So far tests running within Qt Creator could be implemented with a
private slot in the plugin class starting with "test".
Binding the test functions to the plugin object/class is fine for test
functions without side effects. But as soon as side effects come into
play we need proper initialization and cleanup as it's provided by
init(), cleanup(), initTestCase() and cleanupTestCase(). However,
implementing these functions in the plugin class is not appropriate
since they would affect (potentially quite diverse) test functions.
This patch enables us to provide 'ordinary' test classes in which we can
handle initialization and clean up the usual way.
In addition to the current test invocations, e.g.:
# (1) Run all test functions of the plugin
./qtcreator -test CppTools
# (2) Run selected test functions of the plugin by stating them
./qtcreator -test CppTools,test_completion,test_builtinsymbolsearcher
# (3) Run selected test functions of the plugin by a wild card
# expression
./qtcreator -test "CppTools,*pointerdeclaration*"
# (4) Run a test function of the plugin with certain test data
./qtcreator -test CppTools,test_completion:template_1
it's now also possible to state the test class in order to execute all
test functions of that class:
# Run all test functions of a certain class:
./qtcreator -test CppTools,SomeClassWithTests
As long as the test class does not start with "test", there should not
be any problems.
Further, an invocation like (1) now additionally execute all test
functions of all test classes. For invocations of type (2), (3) and (4)
all test functions of all test classes are considered, too.
Change-Id: Ief08a6e9e451c599fd0109b8b8e57f92e3ee19f2
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2015-01-15 13:14:35 +01:00
|
|
|
QStringList testFunctionsOrObjects;
|
2013-01-22 12:54:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool containsTestSpec(PluginSpec *pluginSpec) const
|
|
|
|
|
{
|
2016-02-11 11:53:31 +01:00
|
|
|
return Utils::contains(testSpecs, [pluginSpec](const TestSpec &s) { return s.pluginSpec == pluginSpec; });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void removeTestSpec(PluginSpec *pluginSpec)
|
|
|
|
|
{
|
|
|
|
|
testSpecs = Utils::filtered(testSpecs, [pluginSpec](const TestSpec &s) { return s.pluginSpec != pluginSpec; });
|
2013-01-22 12:54:22 +01:00
|
|
|
}
|
|
|
|
|
|
2019-05-27 14:12:11 +02:00
|
|
|
QHash<QString, QVector<PluginSpec *>> pluginCategories;
|
|
|
|
|
QVector<PluginSpec *> pluginSpecs;
|
|
|
|
|
std::vector<TestSpec> testSpecs;
|
2008-12-02 12:01:29 +01:00
|
|
|
QStringList pluginPaths;
|
2014-08-26 17:29:38 +02:00
|
|
|
QString pluginIID;
|
2019-05-27 14:12:11 +02:00
|
|
|
QVector<QObject *> allObjects; // ### make this a QVector<QPointer<QObject> > > ?
|
2013-11-14 15:57:37 +01:00
|
|
|
QStringList defaultDisabledPlugins; // Plugins/Ignored from install settings
|
|
|
|
|
QStringList defaultEnabledPlugins; // Plugins/ForceEnabled from install settings
|
2010-03-30 14:18:15 +02:00
|
|
|
QStringList disabledPlugins;
|
2010-03-30 16:54:29 +02:00
|
|
|
QStringList forceEnabledPlugins;
|
2012-02-02 10:47:33 +01:00
|
|
|
// delayed initialization
|
2018-07-19 23:19:33 +02:00
|
|
|
QTimer *delayedInitializeTimer = nullptr;
|
2019-05-27 14:12:11 +02:00
|
|
|
std::queue<PluginSpec *> delayedInitializeQueue;
|
2012-02-02 10:47:33 +01:00
|
|
|
// ansynchronous shutdown
|
2019-05-27 14:12:11 +02:00
|
|
|
QSet<PluginSpec *> asynchronousPlugins; // plugins that have requested async shutdown
|
2018-07-19 23:19:33 +02:00
|
|
|
QEventLoop *shutdownEventLoop = nullptr; // used for async shutdown
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QStringList arguments;
|
2010-03-02 12:33:51 +01:00
|
|
|
QScopedPointer<QTime> m_profileTimer;
|
2013-02-06 13:53:51 +01:00
|
|
|
QHash<const PluginSpec *, int> m_profileTotal;
|
2018-07-19 23:19:33 +02:00
|
|
|
int m_profileElapsedMS = 0;
|
|
|
|
|
unsigned m_profilingVerbosity = 0;
|
|
|
|
|
QSettings *settings = nullptr;
|
|
|
|
|
QSettings *globalSettings = nullptr;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// Look in argument descriptions of the specs for the option.
|
|
|
|
|
PluginSpec *pluginForOption(const QString &option, bool *requiresArgument) const;
|
|
|
|
|
PluginSpec *pluginByName(const QString &name) const;
|
|
|
|
|
|
|
|
|
|
// used by tests
|
|
|
|
|
static PluginSpec *createSpec();
|
|
|
|
|
static PluginSpecPrivate *privateSpec(PluginSpec *spec);
|
2010-07-13 13:36:47 +02:00
|
|
|
|
2013-08-29 15:00:46 +02:00
|
|
|
mutable QReadWriteLock m_lock;
|
|
|
|
|
|
2016-05-02 15:39:52 +02:00
|
|
|
bool m_isInitializationDone = false;
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
|
|
|
|
PluginManager *q;
|
|
|
|
|
|
2016-05-31 22:36:33 +03:00
|
|
|
void nextDelayedInitialize();
|
|
|
|
|
void asyncShutdownFinished();
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void readPluginPaths();
|
|
|
|
|
bool loadQueue(PluginSpec *spec,
|
2019-05-27 14:12:11 +02:00
|
|
|
QVector<ExtensionSystem::PluginSpec *> &queue,
|
|
|
|
|
QVector<ExtensionSystem::PluginSpec *> &circularityCheckQueue);
|
2008-12-02 12:01:29 +01:00
|
|
|
void stopAll();
|
2010-07-13 13:36:47 +02:00
|
|
|
void deleteAll();
|
2015-01-05 10:26:52 +01:00
|
|
|
|
2015-01-16 07:38:59 +01:00
|
|
|
#ifdef WITH_TESTS
|
2015-01-05 10:26:52 +01:00
|
|
|
void startTests();
|
2015-01-16 07:38:59 +01:00
|
|
|
#endif
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace ExtensionSystem
|