Skip to content

fix: honor DISABLE_DRIVER in CMake - #739

Open
felixonmars wants to merge 1 commit into
linuxdeepin:masterfrom
felixonmars:fix-disable-driver-build-option
Open

fix: honor DISABLE_DRIVER in CMake#739
felixonmars wants to merge 1 commit into
linuxdeepin:masterfrom
felixonmars:fix-disable-driver-build-option

Conversation

@felixonmars

@felixonmars felixonmars commented Aug 30, 2026

Copy link
Copy Markdown
Member

The top-level option defines DISABLE_DRIVER for source code, but the build still required QApt and built driver-only sources. Make the option skip QApt/kmod discovery and driver-control sources, and ignore direct requests for the driver page when the feature is disabled.

Summary by Sourcery

Make DISABLE_DRIVER fully control driver support in both the build configuration and application behavior.

Bug Fixes:

  • Honor DISABLE_DRIVER consistently by preventing driver-page navigation when driver support is disabled.

Enhancements:

  • Allow driver-disabled builds to omit driver-control sources and avoid unnecessary QApt and kmod dependencies across applications, services, and tests.

Build:

  • Expose DISABLE_DRIVER as a standard CMake option and conditionally configure driver-related dependencies and linkage.

Tests:

  • Update test builds to exclude driver sources and dependencies when driver support is disabled.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: felixonmars

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

@sourcery-ai

sourcery-ai Bot commented Aug 30, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR makes DISABLE_DRIVER effective across configuration, compilation, dependency discovery, and runtime navigation by excluding driver-only sources, avoiding QApt/kmod requirements, and blocking access to the driver page when disabled.

Sequence diagram for disabled driver page navigation

sequenceDiagram
    participant Caller
    participant MainWindow
    Caller->>MainWindow: slotSetPage(page)
    alt page is driver and DISABLE_DRIVER is defined
        MainWindow-->>Caller: return
    else driver support enabled or another page
        MainWindow->>MainWindow: slotSetPage(page)
    end
Loading

Flow diagram for DISABLE_DRIVER build configuration

flowchart TD
    A[DISABLE_DRIVER option] --> B{DISABLE_DRIVER enabled?}
    B -->|Yes| C[Define DISABLE_DRIVER]
    C --> D[Exclude drivercontrol sources]
    C --> E[Skip QApt and kmod discovery]
    C --> F[Omit QApt link libraries]
    B -->|No| G[Discover QApt and kmod]
    G --> H[Build driver-control sources]
    G --> I[Link QApt libraries]
Loading

File-Level Changes

Change Details Files
Make DISABLE_DRIVER a standard CMake option and use it to remove driver-only source files and dependencies from builds.
  • Define DISABLE_DRIVER with option(...), preserving the compile definition when enabled.
  • Exclude drivercontrol sources from the device-control target.
  • Conditionally discover and link QApt and kmod only when driver support is enabled.
  • Remove unconditional QApt include and link requirements from server and client targets, while retaining conditional QApt linkage where needed.
CMakeLists.txt
deepin-devicemanager-server/deepin-devicecontrol/CMakeLists.txt
deepin-devicemanager-server/deepin-deviceinfo/CMakeLists.txt
deepin-devicemanager/CMakeLists.txt
Prevent navigation to the driver management page when driver support is disabled.
  • Reject direct requests for the driver page under the DISABLE_DRIVER compile guard and log that driver management is unavailable.
  • Allow existing driver-page initialization and navigation logic to run only when the feature is enabled.
deepin-devicemanager/src/Page/MainWindow.cpp

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="CMakeLists.txt" line_range="9" />
<code_context>

-set(DISABLE_DRIVER false CACHE BOOL "disable driver")
-if (DISABLE_DRIVER)
+option(DISABLE_DRIVER "Disable driver support" OFF)
+if(DISABLE_DRIVER)
     add_definitions(-DDISABLE_DRIVER)
</code_context>
<issue_to_address>
**issue (broader_impact):** Enabling `DISABLE_DRIVER` still makes a coverage/test configuration require QApt and libkmod because `deepin-devicemanager-server/tests/CMakeLists.txt` unconditionally calls `find_package(QApt...)` and `PKG_SEARCH_MODULE(kmod REQUIRED ...)`. The disabled build therefore fails at CMake configuration when those driver dependencies are absent.

**Triggers:** When `CMAKE_COVERAGE_ARG=CMAKE_COVERAGE_ARG_ON` and QApt or libkmod is not installed.

**Suggested fix:** Guard the test dependency discovery and driver-specific test sources/link libraries with `if(NOT DISABLE_DRIVER)`, or disable the driver tests when the option is enabled.
</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.

Comment thread CMakeLists.txt
@felixonmars
felixonmars force-pushed the fix-disable-driver-build-option branch 3 times, most recently from 05214b0 to 662f2f5 Compare August 30, 2026 10:14
@BLumia
BLumia requested a review from lzwind August 31, 2026 05:40
The top-level option defines DISABLE_DRIVER for source code, but the build still required QApt and built driver-only sources. Make the option skip QApt/kmod discovery and driver-control sources in normal and coverage/test builds, and ignore direct requests for the driver page when the feature is disabled.
@lzwind
lzwind force-pushed the fix-disable-driver-build-option branch from 662f2f5 to a3abe53 Compare August 31, 2026 06:23
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 99 分 (通过阈值: 70分)

Fail


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交修复了 DISABLE_DRIVER 选项在 CMake 构建系统中的完整性问题,使该选项能够正确控制 QApt/kmod 依赖发现、驱动相关源文件编译以及运行时驱动页面导航。变更涉及6个文件(5个 CMakeLists.txt 和1个 C++ 源文件),共52行新增、40行删除。语法正确,逻辑清晰,无安全漏洞。代码质量良好,仅在 C++ 条件编译结构和 CMake 模式重复方面有轻微优化空间。性能无影响。建议合并。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


2. 代码质量 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['可考虑在 C++ 代码中使用单一条件路径优化 #ifdef 块结构,例如将 DISABLE_DRIVER 的早返回逻辑与其他页面检查合并']


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: []


💡 改进建议代码示例

// 暂无代码示例

本报告由 AI 代码审查工具自动生成

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.

2 participants