fix(build): use DTKCORE_CLASS_DConfigFile macro instead of find_path - #217
Conversation
There was a problem hiding this comment.
Sorry @tianming-1996, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR replaces custom DConfig presence detection with DtkCore’s built-in DTKCORE_CLASS_DConfigFile feature macro and makes DConfig schema installation conditional on DSG_DATA_DIR, aligning build behavior with other projects (e.g., deepin-compressor). Flow diagram for build-time DConfig detection and schema installationflowchart TD
A[Configure CMake] --> B[find_package DtkCore REQUIRED]
B --> C{DTKCORE_CLASS_DConfigFile available?}
C -->|yes| D[Compile DeviceStorage.cpp with DConfig support
#ifdef DTKCORE_CLASS_DConfigFile]
C -->|no| E[Compile DeviceStorage.cpp without DConfig support]
A --> F{DSG_DATA_DIR defined?}
F -->|yes| G[install FILES APP_DCONFIG_SCHEMA
DESTINATION share/dsg/configs/com.deepin.diskmanager/]
F -->|no| H[Skip DConfig schema installation]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
76d9064 to
22739bf
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: max-lvs, tianming-1996 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Use DTK feature detection and explicitly include its configuration header. 使用 DTK 特性检测并显式引入配置头,兼容不支持 DConfig 的旧版本。 Log: 修复老版本 DTK 的 DConfig 编译兼容问题 Bug: https://pms.uniontech.com/bug-view-372777.html Influence: 1030等旧版本可正常打包,新版本继续使用DConfig配置。
22739bf to
3513072
Compare
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 # 当前代码已足够优秀,以下为保持一致性的最佳实践展示
# service/CMakeLists.txt
find_package(DtkCore REQUIRED)
find_package(DtkGui REQUIRED)
# 确保所有可能受环境变量影响的安装操作都有守卫
if(DEFINED DSG_DATA_DIR)
install(FILES ${APP_DCONFIG_SCHEMA} DESTINATION share/dsg/configs/com.deepin.diskmanager/)
endif()// service/diskoperation/DeviceStorage.cpp
#include <dtkcore_config.h>
#ifdef DTKCORE_CLASS_DConfigFile
#include <DConfig>
#endif
static QStringList ufsSpecVersions()
{
const QStringList fallback{"300", "310", "400", "410"};
#ifdef DTKCORE_CLASS_DConfigFile
QScopedPointer<Dtk::Core::DConfig> cfg(
Dtk::Core::DConfig::create("com.deepin.diskmanager", "com.deepin.diskmanager.storage"));
if (cfg && cfg->isValid()) {
// 使用官方宏进行安全隔离,避免链接期找不到符号
QStringList versions = cfg->value("ufsSpecVersions").toStringList();
if (!versions.isEmpty()) {
return versions;
}
}
#endif
return fallback;
} |
|
/merge |
Replace hand-written find_path + HAVE_DCONFIG with dtkcore built-in
feature detection macro DTKCORE_CLASS_DConfigFile, matching the approach
used by deepin-compressor. Also guard dconfig schema install with
DSG_DATA_DIR.
用 DTKCORE_CLASS_DConfigFile 宏替代手写 find_path 检测,与归档管理器
方案保持一致;CMake 用 DSG_DATA_DIR 条件安装 schema。
Bug: https://pms.uniontech.com/bug-view-372777.html
Summary by Sourcery
Switch DConfig usage to rely on DtkCore’s DTKCORE_CLASS_DConfigFile feature macro and tighten installation conditions for the DConfig schema.
Enhancements:
Build: