diff options
author | hjk <hjk@qt.io> | 2017-11-29 12:28:40 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2017-12-08 11:17:55 +0000 |
commit | 53a151074ad37d12e730fbd85ec0e0675d00f6d0 (patch) | |
tree | 041526d48608270cad2db171696fa6cf7099a852 /src/plugins/projectexplorer/deployconfiguration.h | |
parent | 9d3c5c6ff5ba059f036efae5fd9572fe454b5d84 (diff) |
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src/plugins/projectexplorer/deployconfiguration.h')
-rw-r--r-- | src/plugins/projectexplorer/deployconfiguration.h | 97 |
1 files changed, 52 insertions, 45 deletions
diff --git a/src/plugins/projectexplorer/deployconfiguration.h b/src/plugins/projectexplorer/deployconfiguration.h index db3b37c5c30..4e42e5e00f0 100644 --- a/src/plugins/projectexplorer/deployconfiguration.h +++ b/src/plugins/projectexplorer/deployconfiguration.h @@ -27,12 +27,9 @@ #include "projectexplorer_export.h" +#include "buildsteplist.h" #include "projectconfiguration.h" -#include <QString> - -QT_FORWARD_DECLARE_CLASS(QStringList) - namespace ProjectExplorer { class BuildStepList; @@ -44,11 +41,16 @@ class PROJECTEXPLORER_EXPORT DeployConfiguration : public ProjectConfiguration { Q_OBJECT +protected: + friend class DeployConfigurationFactory; + explicit DeployConfiguration(Target *target, Core::Id id); + public: - // ctors are protected - ~DeployConfiguration() override; + ~DeployConfiguration() override = default; + virtual void initialize(); - BuildStepList *stepList() const; + BuildStepList *stepList(); + const BuildStepList *stepList() const; bool fromMap(const QVariantMap &map) override; QVariantMap toMap() const override; @@ -66,26 +68,8 @@ public: signals: void enabledChanged(); -protected: - DeployConfiguration(Target *target, Core::Id id); - DeployConfiguration(Target *target, DeployConfiguration *source); - - void cloneSteps(DeployConfiguration *source); - private: - void ctor(); - - BuildStepList *m_stepList = nullptr; -}; - -class PROJECTEXPLORER_EXPORT DefaultDeployConfiguration : public DeployConfiguration -{ - Q_OBJECT - friend class DefaultDeployConfigurationFactory; // for the ctors - -protected: - DefaultDeployConfiguration(Target *target, Core::Id id); - DefaultDeployConfiguration(Target *target, DeployConfiguration *source); + BuildStepList m_stepList; }; class PROJECTEXPLORER_EXPORT DeployConfigurationFactory : public QObject @@ -93,43 +77,66 @@ class PROJECTEXPLORER_EXPORT DeployConfigurationFactory : public QObject Q_OBJECT public: - explicit DeployConfigurationFactory(QObject *parent = nullptr); + DeployConfigurationFactory(); // used to show the list of possible additons to a target, returns a list of types - virtual QList<Core::Id> availableCreationIds(Target *parent) const = 0; + QList<Core::Id> availableCreationIds(Target *parent) const; // used to translate the types to names to display to the user - virtual QString displayNameForId(Core::Id id) const = 0; + QString displayNameForId(Core::Id id) const; - virtual bool canCreate(Target *parent, Core::Id id) const = 0; - virtual DeployConfiguration *create(Target *parent, Core::Id id) = 0; + virtual bool canHandle(ProjectExplorer::Target *target) const; + + bool canCreate(Target *parent, Core::Id id) const; + virtual DeployConfiguration *create(Target *parent, Core::Id id); // used to recreate the runConfigurations when restoring settings - virtual bool canRestore(Target *parent, const QVariantMap &map) const = 0; - virtual DeployConfiguration *restore(Target *parent, const QVariantMap &map) = 0; - virtual bool canClone(Target *parent, DeployConfiguration *product) const = 0; - virtual DeployConfiguration *clone(Target *parent, DeployConfiguration *product) = 0; + bool canRestore(Target *parent, const QVariantMap &map) const; + DeployConfiguration *restore(Target *parent, const QVariantMap &map); + bool canClone(Target *parent, DeployConfiguration *product) const; + DeployConfiguration *clone(Target *parent, DeployConfiguration *product); static DeployConfigurationFactory *find(Target *parent, const QVariantMap &map); static QList<DeployConfigurationFactory *> find(Target *parent); static DeployConfigurationFactory *find(Target *parent, DeployConfiguration *dc); + void setSupportedTargetDeviceTypes(const QList<Core::Id> &ids); + void setDefaultDisplayName(const QString &defaultDisplayName); + void setSupportedProjectType(Core::Id id); + +protected: + virtual QList<QString> availableBuildTargets(Target *parent) const; + virtual QString displayNameForBuildTarget(const QString &buildTarget) const; + + using DeployConfigurationCreator = std::function<DeployConfiguration *(Target *)>; + + template <class DeployConfig> + void registerDeployConfiguration(Core::Id deployConfigBaseId) + { + m_creator = [this](Target *t) { + auto dc = new DeployConfig(t); + dc->setDefaultDisplayName(m_defaultDisplayName); + return dc; + }; + m_deployConfigBaseId = deployConfigBaseId; + } + signals: void availableCreationIdsChanged(); + +private: + DeployConfigurationCreator m_creator; + Core::Id m_deployConfigBaseId; + Core::Id m_supportedProjectType; + QList<Core::Id> m_supportedTargetDeviceTypes; + QString m_defaultDisplayName; }; class DefaultDeployConfigurationFactory : public DeployConfigurationFactory { public: - QList<Core::Id> availableCreationIds(Target *parent) const override; - // used to translate the types to names to display to the user - QString displayNameForId(Core::Id id) const override; - bool canCreate(Target *parent, Core::Id id) const override; - DeployConfiguration *create(Target *parent, Core::Id id) override; - bool canRestore(Target *parent, const QVariantMap &map) const override; - DeployConfiguration *restore(Target *parent, const QVariantMap &map) override; - bool canClone(Target *parent, DeployConfiguration *product) const override; - DeployConfiguration *clone(Target *parent, DeployConfiguration *product) override; + DefaultDeployConfigurationFactory(); + private: - bool canHandle(Target *parent) const; + bool canHandle(Target *parent) const override; }; } // namespace ProjectExplorer |