Phase out plugin macros for specific classes
Open, Needs TriagePublic

Description

Currently lots of projects have dedicated macros to create plugins for a spefici class. Like K_EXPORT_PLASMA_APPLET_WITH_JSON or K_EXPORT_PLASMA_RUNNER_WITH_JSON. During the KF4 times this was necessary, because each class had some string magic involved, for example:

#define K_EXPORT_PLASMA_DATAENGINE(libname, classname) \
K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
K_EXPORT_PLUGIN(factory("plasma_engine_" #libname)) \
K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)

With T14302 we can just use the K_PLUGIN_CLASS_WITH_JSON macro directly and don't have any extra code.

Current usages are:

  • K_EXPORT_PLASMA_RUNNER_WITH_JSON
  • K_EXPORT_PLASMA_APPLET_WITH_JSON
  • K_EXPORT_PLASMA_CONTAINMENTACTIONS_WITH_JSON
  • K_EXPORT_PLASMA_DATAENGINE_WITH_JSON
  • K_EXPORT_PLASMA_PACKAGE_WITH_JSON
  • K_EXPORT_PLASMA_SERVICE_WITH_JSON
  • K_EXPORT_PLASMA_DATAENGINESCRIPTENGINE_WITH_JSON
  • PLAN_SCHEDULERPLUGIN_EXPORT
  • KDB_DRIVER_PLUGIN_FACTORY
  • KEXI_PLUGIN_FACTORY
  • K_EXPORT_KPACKAGE_PACKAGE_WITH_JSON
  • KREPORT_PLUGIN_FACTORY
alex created this task.Jun 3 2021, 9:42 AM

A small correction, which shows how old/ancient some of us are :), there was no KF4, back in those days it was called kdelibs/kdebase, not going to say KDE4 as that makes some people who are more ancient than myself, a bit annoyed; many of the current repos in KF lived in kdelibs, kdebase, kdeworkspace IIUC.

Generally speaking, less macros is a good thing, and if we can replace K_PLUGIN_CLASS_WITH_JSON with a static method of some kind, that would be even better.

alex added a comment.EditedJun 15 2021, 8:23 PM

https://invent.kde.org/plasma/kdeplasma-addons/-/commit/62ac47de80efd68c233ed9b10f2d5f804f3f5de9
https://invent.kde.org/plasma/kdeplasma-addons/-/commit/0a31c9d7075f442e012f80f34c55828381e105fb
https://invent.kde.org/plasma/kdeplasma-addons/-/commit/1c67e2888fdacc81327ea4ca94e584853700d92a

https://invent.kde.org/plasma/plasma-workspace/-/commit/f6e4bb67b0ad36731be079ab112888cc789c1b6d
https://invent.kde.org/plasma/plasma-workspace/-/commit/2f0eb07038770c73b06df9b83f24bb731fd5e81d
https://invent.kde.org/plasma/plasma-workspace/-/commit/90ede05980b47663174594f0ebafddf55d08bef3
https://invent.kde.org/plasma/plasma-workspace/-/commit/b640fbdc3e030a5d8fccfde366e9f8ab9e85aa2a
https://invent.kde.org/plasma/plasma-workspace/-/commit/9a5f5124ea4d1f427883b03ae4a7e1ec3f6d613b
And some custom macro in plasma-workspace: https://invent.kde.org/plasma/plasma-workspace/-/commit/ffcb97c69a876d99ad076ef4e42492d1d86ceba7

https://invent.kde.org/frameworks/plasma-framework/-/commit/8df168592ba10c0edf55e00b571a5ae583e6f8a5
https://invent.kde.org/frameworks/plasma-framework/-/commit/094f82f9b4b03dba80916b1fb9f35fba4bbb1d17
https://invent.kde.org/frameworks/plasma-framework/-/commit/3063e43abd6d8422f0dbee18abfa7db1d62d3e38

https://invent.kde.org/plasma/kscreen/commit/e958e6c2ec4c5a2d43c14f9b871a216fb7faedf0
https://invent.kde.org/libraries/kreport/-/commit/06ecb740021d2b96d5a7ab72d39174c32c1be44d
https://invent.kde.org/plasma/plasma-vault/commit/2b4911828921b86cffa84999b26079181106fc9a
https://invent.kde.org/pim/akonadi-search/commit/28985a5c26f6c153e6dfc675de93733c3cc9f36a
https://invent.kde.org/plasma/plasma-phone-components/-/commit/bacfccd323bfe9c7cdef3800bcafde6ccdc63c76
https://invent.kde.org/plasma/kwin/commit/e170c3be7d88f07f3b71c5959d096e40616e489e
https://invent.kde.org/plasma/plasma-desktop/commit/c0169b610430d1d0a59e5c6eadd1fc5ab36150d8
https://invent.kde.org/plasma/plasma-active-window-control/commit/d4da1b6b74280c2d54a53dafdf2678e0afba5a58#
https://invent.kde.org/plasma/plasma-bigscreen/commit/09d8af1fd739d7cf003504eb09621554dec5cf9b

https://invent.kde.org/office/calligraplan/-/commit/b4efe32acf2f0361667c7e5e4fcea747c21efd52

https://invent.kde.org/libraries/kdb/-/commit/a7ac22045f862875124769caf88d471512d6bdac

The code I look after (KDB_DRIVER_PLUGIN_FACTORY, KEXI_PLUGIN_FACTORY, KREPORT_PLUGIN_FACTORY) uses K_PLUGIN_FACTORY_WITH_JSON, not K_PLUGIN_FACTORY.

That said, assuming we can accept KF >= 5.44 dependency in master branches, then OK.

alex added a comment.Jun 18 2021, 9:00 PM

uses K_PLUGIN_FACTORY_WITH_JSON, not K_PLUGIN_FACTORY.

Yes, that is the modern way of creating plugins, which is also what K_PLUGIN_CLASS_WITH_JSON does

alex added a comment.Jun 19 2021, 6:19 AM

All Plasma or app specific macros were ported/have open MRs.

Some Apps like Kate or KDevelop use plasma-frameworks/krunner macros that have been changed in master or 5.84. For those I would wait a couple of frameworks releases and port those macros when the version is bumped.

After the next frameworks version is released the K_EXPORT* macros should be deprecated.

PLAN_SCHEDULERPLUGIN_EXPORT fixed.

alex added a comment.EditedOct 27 2021, 7:53 AM

Remaining deprecations in the frameworks:
https://invent.kde.org/frameworks/krunner/commit/dd04eb6fd13afd47fe579a1e1f8ca05230a0a30d
https://invent.kde.org/frameworks/plasma-framework/-/commit/8686e878cbefe7e1bde30a373c7ebec25f5534ba

Now this waits for KF6 branching. Then the macros & CMake stuff to set up the macro names for the moc can be removed.

alex moved this task from Backlog to Waiting on KF6 Branching on the KF6 board.Oct 31 2021, 7:34 PM
alex added a comment.Jun 30 2022, 5:46 AM

There was one leftover hidden in kactivitymanagerd: Taken care of with https://invent.kde.org/plasma/kactivitymanagerd/-/merge_requests/26