dtkcore
dtkcore copied to clipboard
feat: dplugin
- build: clean cmakelist
- feat: start impl dplugin
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 |
@kegechen @zccrs @Groveer @justforlxz
这边希望给 DTK 添加一个通用的插件寻找机制, 方便需要使用插件来加载可选功能的应用编写.
这个机制目前设计如下:
应用会从 QT 给的 AppDataLocation 目录下的 plugins 文件夹中寻找配置文件. 配置文件中记录该插件的名称 版本和库名(也可以是绝对路径). 这些信息被用来初始化一个 QLibrary 对象. 需要加载插件的应用使用这个对象来工作.
这种设计参考了 chrome 以及 fcitx 的设计, 这两个项目都没有采取固定位置直接放置 so 库的做法, 而是采取了如此通过配置文件来寻找真正要使用的插件的做法.
由于 AppDataLocation 尊重 XDG_DATA_DIR 环境变量^1, 如此设计对于需要更改插件实际存放位置的情况来说比较友好.
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅
@kegechen @zccrs @Groveer @justforlxz
这边希望给 DTK 添加一个通用的插件寻找机制, 方便需要使用插件来加载可选功能的应用编写.
这个机制目前设计如下:
应用会从 QT 给的 AppDataLocation 目录下的 plugins 文件夹中寻找配置文件. 配置文件中记录该插件的名称 版本和库名(也可以是绝对路径). 这些信息被用来初始化一个 QLibrary 对象. 需要加载插件的应用使用这个对象来工作.
这种设计参考了 chrome 以及 fcitx 的设计, 这两个项目都没有采取固定位置直接放置 so 库的做法, 而是采取了如此通过配置文件来寻找真正要使用的插件的做法.
由于 AppDataLocation 尊重 XDG_DATA_DIR 环境变量1, 如此设计对于需要更改插件实际存放位置的情况来说比较友好.
Footnotes
- https://github.com/qt/qtbase/blob/d7e8d5bb1b5a9c4b21a3d824780c672eaf4e56b1/src/corelib/io/qstandardpaths_unix.cpp#L374 leftwards_arrow_with_hook
为什么不直接使用 QPluginLoader 呢
为什么不直接使用 QPluginLoader 呢
重点并不在于加载库的具体过程,而在于插件加载的过程需要:
- 尊重XDG_DATA_DIRS环境变量
- 方便具体的库位置移动
这对nix/flatpak以及玲珑类的打包方式都很有意义。
想了想好像解决不了插件里面又加载了其他的so的问题, 我再考虑考虑怎么解决 这个先挂着
TAG Bot
New tag: 5.6.21 DISTRIBUTION: unstable Suggest: synchronizing this PR through rebase #399
TAG Bot
New tag: 5.6.22 DISTRIBUTION: unstable Suggest: synchronizing this PR through rebase #400
TAG Bot
New tag: 5.6.25 DISTRIBUTION: unstable Suggest: synchronizing this PR through rebase #406
TAG Bot
New tag: 5.6.26 DISTRIBUTION: unstable Suggest: synchronizing this PR through rebase #407
TAG Bot
New tag: 5.6.27 DISTRIBUTION: unstable Suggest: synchronizing this PR through rebase #410
TAG Bot
New tag: 5.6.28 DISTRIBUTION: unstable Suggest: synchronizing this PR through rebase #411
TAG Bot
New tag: 5.6.29 DISTRIBUTION: unstable Suggest: synchronizing this PR through rebase #415
TAG Bot
New tag: 5.6.30 DISTRIBUTION: unstable Suggest: synchronizing this PR through rebase #424