Skip to content

Conversation

@18202781743
Copy link
Contributor

@18202781743 18202781743 commented Nov 14, 2025

  • feat: add reproducible build parameters
  • fix: resolve duplicate compilation issue by removing redundant install

Summary by Sourcery

Refactor example applications to compute plugin paths dynamically, remove static CHAMELEON_PATH build definitions, streamline plugin installation to avoid duplicates, and update packaging for reproducible builds.

Bug Fixes:

  • Eliminate redundant QML plugin directory install to prevent duplicate compilation

Enhancements:

  • Resolve plugin and style import paths at runtime in example applications instead of using a compile-time CHAMELEON_PATH macro
  • Remove CHAMELEON_PATH definitions from examples’ CMake configuration
  • Refine plugin installation to install only the qmldir file

Build:

  • Add reproducible build parameters in debian packaging rules

Added CMAKE_SKIP_BUILD_RPATH flag to enable reproducible builds
This change ensures consistent binary output across different build
environments
by preventing the inclusion of build-specific paths in the compiled
binaries
The flag is added to DEB_CMAKE_EXTRA_FLAGS which is then passed to the
configure command

Influence:
1. Verify that builds produce identical binaries when built in different
environments
2. Test that the application still functions correctly with the new
build flag
3. Check that RPATH is not embedded in the resulting binaries
4. Validate that the build process completes successfully with the new
parameter

feat: 添加可重复编译参数

添加 CMAKE_SKIP_BUILD_RPATH 标志以启用可重复构建
此更改通过防止在编译的二进制文件中包含特定于构建的路径
确保在不同构建环境中产生一致的二进制输出
该标志被添加到 DEB_CMAKE_EXTRA_FLAGS 中,然后传递给配置命令

Influence:
1. 验证在不同环境中构建时是否产生相同的二进制文件
2. 测试应用程序在使用新构建标志后是否仍能正常运行
3. 检查生成的二进制文件中是否未嵌入 RPATH
4. 验证构建过程在使用新参数后是否成功完成
1. Remove CHAMELEON_PATH definition and usage from CMakeLists.txt
2. Replace compile-time CHAMELEON_PATH with runtime path calculation
using QGuiApplication::applicationDirPath()
3. Change install directive from copying entire plugin directory to only
installing qmldir file
4. This prevents duplicate files during installation and resolves
recompilation issues

The changes address a problem where redundant installation content
was causing repeatable compilation problems. By removing the compile-
time path definition and dynamically calculating the path at runtime,
we eliminate dependency on build-time paths. Additionally, installing
only the qmldir file instead of the entire plugin directory prevents
duplicate file conflicts during installation.

Influence:
1. Verify that examples can still find and load Chameleon plugins at
runtime
2. Test that QML import paths are correctly set in both exhibition and
qml-inspect examples
3. Confirm that plugin installation only includes necessary qmldir file
4. Check that style settings work correctly across different Qt versions
5. Validate that no duplicate files are created during build/install
process

fix: 解决重复编译问题,移除冗余安装内容

1. 从 CMakeLists.txt 中移除 CHAMELEON_PATH 定义和使用
2. 使用 QGuiApplication::applicationDirPath() 运行时路径计算替换编译
时 CHAMELEON_PATH
3. 将安装指令从复制整个插件目录改为仅安装 qmldir 文件
4. 这防止了安装过程中的重复文件问题并解决了重新编译问题

这些更改解决了冗余安装内容导致可重复编译的问题。通过移除编译时路径定义并
在运行时动态计算路径,我们消除了对构建时路径的依赖。此外,仅安装 qmldir
文件而不是整个插件目录可以防止安装过程中的重复文件冲突。

Influence:
1. 验证示例程序在运行时仍能找到并加载 Chameleon 插件
2. 测试 exhibition 和 qml-inspect 示例中的 QML 导入路径是否正确设置
3. 确认插件安装仅包含必要的 qmldir 文件
4. 检查样式设置在不同 Qt 版本中是否正常工作
5. 验证构建/安装过程中不会创建重复文件
@18202781743 18202781743 requested review from BLumia and mhduiy November 14, 2025 03:00
deepin-ci-robot added a commit to linuxdeepin/dtk6declarative that referenced this pull request Nov 14, 2025
Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#549
@sourcery-ai
Copy link

sourcery-ai bot commented Nov 14, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR replaces hardcoded CHAMELEON_PATH macros with dynamic, applicationDirPath-based resolution in the example apps, removes obsolete path definitions, refines CMake install rules to prevent duplicate compilation, and adds reproducible build parameters to the Debian packaging.

Class diagram for main.cpp changes (dynamic chameleonPath resolution)

classDiagram
    class main {
        +int main(int argc, char **argv)
        -CHAMELEON_PATH : macro (removed)
        +chameleonPath : QString (added)
    }
    main --> QQmlApplicationEngine : uses
    main --> QQuickStyle : uses
    main --> QGuiApplication : uses
Loading

Class diagram for qml-inspect/main.cpp changes (dynamic chameleonPath resolution)

classDiagram
    class main {
        +int main(int argc, char *argv[])
        -CHAMELEON_PATH : macro (removed)
        +chameleonPath : QString (added)
    }
    main --> QQmlApplicationEngine : uses
    main --> QQuickStyle : uses
    main --> QGuiApplication : uses
Loading

File-Level Changes

Change Details Files
Replaced static CHAMELEON_PATH macro with dynamic runtime path resolution
  • Introduced QStringLiteral to build chameleonPath from QGuiApplication::applicationDirPath
  • Updated engine.addImportPath to use the new chameleonPath
  • Replaced QQuickStyle::addStylePath calls to reference chameleonPath
  • Swapped CHAMELEON_PATH usage in QQuickStyle::setStyle with runtime chameleonPath
examples/exhibition/main.cpp
examples/qml-inspect/main.cpp
Removed obsolete CHAMELEON_PATH definitions in examples CMakeLists
  • Deleted CHAMELEON_PATH variable assignment
  • Removed corresponding -DCHAMELEON_PATH define
examples/CMakeLists.txt
Refined plugin installation to avoid duplicate compilation
  • Replaced install(DIRECTORY ...) with install(FILES …/qmldir)
qt6/src/CMakeLists.txt
Added reproducible build parameters in Debian packaging
  • Inserted environment variables and flags for deterministic builds
  • Refactored dh_* calls to enforce reproducibility
debian/rules

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot
Copy link
Contributor

deepin pr auto review

我来对这个diff进行详细审查:

  1. debian/rules 的修改:
+DEB_CMAKE_EXTRA_FLAGS += -DCMAKE_SKIP_BUILD_RPATH=ON
  • 优点:添加了reproducible编译参数,有助于提高构建的可重现性
  • 建议:这个修改是好的,但建议添加注释说明这个参数的具体作用
  1. examples/CMakeLists.txt 的修改:
-set(CHAMELEON_PATH "${PROJECT_BINARY_DIR}/plugins")
-    -DCHAMELEON_PATH="${CHAMELEON_PATH}"
  • 优点:移除了硬编码的路径定义,改用运行时动态计算路径
  • 安全性:提高了安全性,避免了构建时路径泄露
  1. examples/exhibition/main.cpp 和 examples/qml-inspect/main.cpp 的修改:
+    const QString chameleonPath = QStringLiteral("%1/../../../plugins").arg(QGuiApplication::applicationDirPath());
  • 优点:
    • 使用QStringLiteral提高了字符串处理效率
    • 使用QGuiApplication::applicationDirPath()动态获取路径,更加灵活
    • 路径计算更加规范和安全
  • 建议:
    • 可以考虑添加路径存在性检查
    • 建议将路径计算逻辑封装成单独的函数,避免代码重复
  1. qt6/src/CMakeLists.txt 的修改:
-install(DIRECTORY "${PLUGIN_OUTPUT_DIR}/${URI_PATH}/" DESTINATION "${QML_INSTALL_DIR}/${URI_PATH}")
+install(FILES "${PLUGIN_OUTPUT_DIR}/${URI_PATH}/qmldir" DESTINATION "${QML_INSTALL_DIR}/${URI_PATH}")
  • 优点:从安装整个目录改为只安装qmldir文件,更加精确和安全
  • 建议:这个修改是好的,但建议确保其他必要的文件也通过其他规则正确安装

总体改进建议:

  1. 路径处理:

    • 建议添加路径有效性检查
    • 考虑使用QDir::toNativeSeparators()确保路径格式正确
  2. 代码复用:

    • 建议将路径计算逻辑提取到公共函数中
    • 可以考虑创建一个工具类来处理路径相关操作
  3. 错误处理:

    • 建议添加适当的错误处理机制
    • 考虑添加日志记录,便于调试
  4. 安全性:

    • 建议对路径进行规范化处理,防止路径遍历攻击
    • 可以添加权限检查
  5. 性能优化:

    • 可以考虑缓存计算后的路径
    • 使用QFile::exists()检查文件存在性

这些修改总体上是积极的,提高了代码的可维护性和安全性,但还可以进一步完善。

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and found some issues that need to be addressed.

  • Refactor the duplicated chameleonPath computation in both example mains into a shared helper to reduce copy-paste.
  • Use QLibraryInfo::path(QLibraryInfo::PluginsPath) (or QStandardPaths) instead of a hardcoded relative path for locating the QML plugin directory.
  • Update the CMake install rule to include the plugin binaries/resources in addition to qmldir so nothing is missing at runtime.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Refactor the duplicated chameleonPath computation in both example mains into a shared helper to reduce copy-paste.
- Use QLibraryInfo::path(QLibraryInfo::PluginsPath) (or QStandardPaths) instead of a hardcoded relative path for locating the QML plugin directory.
- Update the CMake install rule to include the plugin binaries/resources in addition to qmldir so nothing is missing at runtime.

## Individual Comments

### Comment 1
<location> `examples/exhibition/main.cpp:84` </location>
<code_context>

 #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) && defined(QT_NO_DEBUG)
-    QQuickStyle::setStyle(CHAMELEON_PATH"/Chameleon");
+    QQuickStyle::setStyle(chameleonPath"/Chameleon");
 #else
     QQuickStyle::setStyle("Chameleon");
</code_context>

<issue_to_address>
**issue (bug_risk):** String concatenation with chameleonPath may not work as intended.

Use chameleonPath + "/Chameleon" for correct QString concatenation in C++.
</issue_to_address>

### Comment 2
<location> `examples/qml-inspect/main.cpp:33` </location>
<code_context>

 #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) && defined(QT_NO_DEBUG)
-    QQuickStyle::setStyle(CHAMELEON_PATH"/Chameleon");
+    QQuickStyle::setStyle(chameleonPath"/Chameleon");
 #else
     QQuickStyle::setStyle("Chameleon");
</code_context>

<issue_to_address>
**issue (bug_risk):** Invalid string concatenation for style path.

Use chameleonPath + "/Chameleon" to concatenate the path correctly.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.


#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) && defined(QT_NO_DEBUG)
QQuickStyle::setStyle(CHAMELEON_PATH"/Chameleon");
QQuickStyle::setStyle(chameleonPath"/Chameleon");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): String concatenation with chameleonPath may not work as intended.

Use chameleonPath + "/Chameleon" for correct QString concatenation in C++.


#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) && defined(QT_NO_DEBUG)
QQuickStyle::setStyle(CHAMELEON_PATH"/Chameleon");
QQuickStyle::setStyle(chameleonPath"/Chameleon");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Invalid string concatenation for style path.

Use chameleonPath + "/Chameleon" to concatenate the path correctly.

@deepin-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, BLumia, mhduiy

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@18202781743 18202781743 merged commit 6c2b689 into linuxdeepin:master Nov 17, 2025
18 of 21 checks passed
18202781743 pushed a commit to linuxdeepin/dtk6declarative that referenced this pull request Nov 17, 2025
Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#549
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants