dtkcore icon indicating copy to clipboard operation
dtkcore copied to clipboard

feat: dplugin

Open black-desk opened this issue 2 years ago • 13 comments
trafficstars

  • build: clean cmakelist
  • feat: start impl dplugin

black-desk avatar Feb 09 '23 10:02 black-desk

Doc Check bot :yellow_circle: some documents missing!

File Line Symbol
include/util/dplugin.h 25 const QScopedPointer<QLibrary> Dtk::Core::DPlugin::library
include/util/dplugin.h 23 static QList< std::shared_ptr< DPlugin > > Dtk::Core::DPlugin::listPlugins
include/util/dplugin.h 26 QString Dtk::Core::DPlugin::name
include/util/dplugin.h 18 Dtk::Core::DPlugin

deepin-bot[bot] avatar Feb 09 '23 10:02 deepin-bot[bot]

@kegechen @zccrs @Groveer @justforlxz

这边希望给 DTK 添加一个通用的插件寻找机制, 方便需要使用插件来加载可选功能的应用编写.

这个机制目前设计如下:

应用会从 QT 给的 AppDataLocation 目录下的 plugins 文件夹中寻找配置文件. 配置文件中记录该插件的名称 版本和库名(也可以是绝对路径). 这些信息被用来初始化一个 QLibrary 对象. 需要加载插件的应用使用这个对象来工作.

这种设计参考了 chrome 以及 fcitx 的设计, 这两个项目都没有采取固定位置直接放置 so 库的做法, 而是采取了如此通过配置文件来寻找真正要使用的插件的做法.

由于 AppDataLocation 尊重 XDG_DATA_DIR 环境变量^1, 如此设计对于需要更改插件实际存放位置的情况来说比较友好.

black-desk avatar Feb 16 '23 13:02 black-desk

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

github-actions[bot] avatar Feb 16 '23 15:02 github-actions[bot]

@kegechen @zccrs @Groveer @justforlxz

这边希望给 DTK 添加一个通用的插件寻找机制, 方便需要使用插件来加载可选功能的应用编写.

这个机制目前设计如下:

应用会从 QT 给的 AppDataLocation 目录下的 plugins 文件夹中寻找配置文件. 配置文件中记录该插件的名称 版本和库名(也可以是绝对路径). 这些信息被用来初始化一个 QLibrary 对象. 需要加载插件的应用使用这个对象来工作.

这种设计参考了 chrome 以及 fcitx 的设计, 这两个项目都没有采取固定位置直接放置 so 库的做法, 而是采取了如此通过配置文件来寻找真正要使用的插件的做法.

由于 AppDataLocation 尊重 XDG_DATA_DIR 环境变量1, 如此设计对于需要更改插件实际存放位置的情况来说比较友好.

Footnotes

  1. https://github.com/qt/qtbase/blob/d7e8d5bb1b5a9c4b21a3d824780c672eaf4e56b1/src/corelib/io/qstandardpaths_unix.cpp#L374 leftwards_arrow_with_hook

为什么不直接使用 QPluginLoader 呢

zccrs avatar Feb 20 '23 03:02 zccrs

为什么不直接使用 QPluginLoader 呢

重点并不在于加载库的具体过程,而在于插件加载的过程需要:

  1. 尊重XDG_DATA_DIRS环境变量
  2. 方便具体的库位置移动

这对nix/flatpak以及玲珑类的打包方式都很有意义。

black-desk avatar Feb 20 '23 07:02 black-desk

想了想好像解决不了插件里面又加载了其他的so的问题, 我再考虑考虑怎么解决 这个先挂着

black-desk avatar Mar 29 '23 08:03 black-desk

TAG Bot

New tag: 5.6.21 DISTRIBUTION: unstable Suggest: synchronizing this PR through rebase #399

deepin-bot[bot] avatar Jan 09 '24 06:01 deepin-bot[bot]

TAG Bot

New tag: 5.6.22 DISTRIBUTION: unstable Suggest: synchronizing this PR through rebase #400

deepin-bot[bot] avatar Jan 12 '24 06:01 deepin-bot[bot]

TAG Bot

New tag: 5.6.25 DISTRIBUTION: unstable Suggest: synchronizing this PR through rebase #406

deepin-bot[bot] avatar Mar 11 '24 07:03 deepin-bot[bot]

TAG Bot

New tag: 5.6.26 DISTRIBUTION: unstable Suggest: synchronizing this PR through rebase #407

deepin-bot[bot] avatar Mar 27 '24 06:03 deepin-bot[bot]

TAG Bot

New tag: 5.6.27 DISTRIBUTION: unstable Suggest: synchronizing this PR through rebase #410

deepin-bot[bot] avatar Apr 23 '24 01:04 deepin-bot[bot]

TAG Bot

New tag: 5.6.28 DISTRIBUTION: unstable Suggest: synchronizing this PR through rebase #411

deepin-bot[bot] avatar Apr 30 '24 07:04 deepin-bot[bot]

TAG Bot

New tag: 5.6.29 DISTRIBUTION: unstable Suggest: synchronizing this PR through rebase #415

deepin-bot[bot] avatar May 16 '24 02:05 deepin-bot[bot]

TAG Bot

New tag: 5.6.30 DISTRIBUTION: unstable Suggest: synchronizing this PR through rebase #424

deepin-bot[bot] avatar May 31 '24 07:05 deepin-bot[bot]