Skip to content

build(ci): Select build mode and artifact suffix by version#65

Merged
qzhhhi merged 2 commits into
mainfrom
dev/auto-debug
Jul 6, 2026
Merged

build(ci): Select build mode and artifact suffix by version#65
qzhhhi merged 2 commits into
mainfrom
dev/auto-debug

Conversation

@qzhhhi

@qzhhhi qzhhhi commented Jul 6, 2026

Copy link
Copy Markdown
Member

Make CI SDK and firmware packaging choose release or debug automatically from the generated project version. Stable numeric versions use release presets with no artifact suffix, while prerelease or dirty versions use debug presets and append -debug to packaged outputs.

Keep debug builds optimized with -O3 and control debug assertions with LIBRMCS_DEBUG_ASSERTS so assertion behavior matches the selected build mode.

本次变更将 CI SDK 与固件打包流程从固定的 release 模式,改为根据项目版本自动选择构建模式:

  • 纯数字/点分版本会走 release 预设,产物保持无后缀命名
  • 预发布或 dirty 版本会走 debug 预设,产物统一追加 -debug

同时将调试断言控制从 NDEBUG 迁移到显式的 LIBRMCS_DEBUG_ASSERTS,并把该配置贯穿到 SDK、host、rmcs_board 与 c_board 的 CMake/编译定义中。相关断言实现、栈分配器以及固件/bootloader 构建逻辑都随之切换到新的开关。

另外,debug 构建保持 -O3 优化,并同步调整了相关打包文件名规则,使发布包与调试包命名更清晰一致。

Make CI SDK and firmware packaging choose release or debug automatically from the generated project version. Stable numeric versions use release presets with no artifact suffix, while prerelease or dirty versions use debug presets and append -debug to packaged outputs.

Keep debug builds optimized with -O3 and control debug assertions with LIBRMCS_DEBUG_ASSERTS so assertion behavior matches the selected build mode.
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@qzhhhi, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 25 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 63523705-1447-459f-9598-d9871697458b

📥 Commits

Reviewing files that changed from the base of the PR and between c0adaf3 and f9234e9.

📒 Files selected for processing (1)
  • host/CMakeLists.txt

Walkthrough

该 PR 将调试断言开关从 NDEBUG 迁移为显式的 LIBRMCS_DEBUG_ASSERTS,贯穿 core 工具库、c_board/rmcs_board 固件、host 打包以及 Docker 构建脚本。同时调整了 debug 构建的编译优化级别,并根据版本号格式动态切换 CMake 预设与产物文件名后缀。

Changes

核心断言逻辑迁移

Layer / File(s) Summary
core 断言宏与分配器切换
core/src/utility/assert.hpp, core/src/utility/stack_allocator.hpp
断言宏存在性校验及 assert_failed_debug/assert_debug/assert_debug_lazy 分支、StackAllocator 类型选择均从 NDEBUG 切换为 LIBRMCS_DEBUG_ASSERTS。

固件端调试断言接入

Layer / File(s) Summary
通用 CMake 上下文推导
firmware/common/cmake/librmcs_firmware.cmake
新增基于 LIBRMCS_DEBUG_ASSERTS 或 CMAKE_BUILD_TYPE 推导并校验 debug_asserts 值,导出到 PARENT_SCOPE。
c_board 断言与优化选项
firmware/c_board/CMakeLists.txt, firmware/c_board/bootloader/src/utility/assert.hpp, firmware/c_board/cmake/gcc-arm-none-eabi.cmake
新增编译定义传递、断言头文件宏校验与分支切换,以及 debug/release 优化级别调整。
rmcs_board 传参、断言与优化选项
firmware/rmcs_board/CMakeLists.txt, firmware/rmcs_board/app/CMakeLists.txt, firmware/rmcs_board/bootloader/CMakeLists.txt, firmware/rmcs_board/bootloader/src/utility/assert.hpp
子构建透传 LIBRMCS_DEBUG_ASSERTS,app/bootloader 新增编译定义并将 -Og 改为 -O3,断言头文件切换判断宏。

host 打包与 Docker 构建流水线

Layer / File(s) Summary
host CMake 断言定义与打包命名
host/CMakeLists.txt
新增 LIBRMCS_DEBUG_ASSERTS 校验/推导并注入编译定义,release 模式下打包文件名不再追加构建模式后缀。
Docker 固件构建动态预设
Dockerfile.build_firmware
依据版本号格式判断动态设置 debug 断言、CMake 预设与产物后缀,应用于 rmcs_board 与 c_board 的构建及产物命名。
Docker SDK 构建动态预设
Dockerfile.build_sdk
新增 LIBRMCS_DEBUG_ASSERTS 占位符,运行时根据版本号动态设置调试断言、CMake 预设及产物后缀,写入 env.sh 并用于源码打包与最终构建。

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • Alliance-Algorithm/librmcs#14: 均修改 Dockerfile.build_firmware / Dockerfile.build_sdk 以基于 LIBRMCS_PROJECT_VERSION 进行版本化构建/预设/产物命名。
  • Alliance-Algorithm/librmcs#24: 均修改 Dockerfile.build_firmware 中固件构建变体选择及 ELF 文件命名逻辑。
  • Alliance-Algorithm/librmcs#39: 均改动 firmware/rmcs_board/bootloader/src/utility/assert.hpp 中 assert_debug/assert_always 的条件编译逻辑。

Poem

断言不再看 NDEBUG,
换个开关叫 DEBUG_ASSERTS,
固件、host、Docker 都跟上,
-O3 飞快,后缀不留痕,
兔子啃着配置文件,
蹦蹦跳跳发新版本 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了按版本自动选择构建模式并调整产物后缀这一主要变更。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev/auto-debug

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
firmware/c_board/cmake/gcc-arm-none-eabi.cmake (1)

30-33: 🚀 Performance & Scalability | 🔵 Trivial

Debug 构建改用 -O3,符合 PR 目标;提醒潜在调试体验影响。

调整符合本 PR "keeps debug builds optimized with -O3" 的目标。需注意 -O3 会导致部分变量被优化掉或代码重排,调试时单步执行、变量查看可能与源码行为不完全对应,建议在文档或提交说明中提示使用者该权衡。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@firmware/c_board/cmake/gcc-arm-none-eabi.cmake` around lines 30 - 33, The
CMAKE debug flag changes in gcc-arm-none-eabi.cmake already match the PR goal,
but the debug-optimized behavior should be documented. Update the relevant
user-facing note or build documentation to mention that CMAKE_C_FLAGS_DEBUG and
CMAKE_CXX_FLAGS_DEBUG now use -O3 -g3, and briefly call out the expected
tradeoff that variables may be optimized away and stepping may not exactly match
source; reference the debug/release flag definitions in the
gcc-arm-none-eabi.cmake configuration when updating the description.
firmware/c_board/bootloader/src/utility/assert.hpp (1)

3-6: 📐 Maintainability & Code Quality | 🔵 Trivial

断言分支切换逻辑正确,但与 rmcs_board 版本完全重复。

#if LIBRMCS_DEBUG_ASSERTS/#error 逻辑正确,且用 assert_always/[[assume(...)]] 区分调试与发布行为符合预期。但此文件与 firmware/rmcs_board/bootloader/src/utility/assert.hpp 内容完全一致,两处需要同步维护,后续若断言逻辑再变更容易遗漏其中一处。可考虑将该断言实现提取到 firmware/common 下的共享头文件,供两个 bootloader 复用。

Also applies to: 16-22

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@firmware/c_board/bootloader/src/utility/assert.hpp` around lines 3 - 6,
此处的断言实现与 rmcs_board 版本完全重复,需要避免两处同步维护带来的遗漏风险。请把 assert.hpp 中的断言分支逻辑抽到
firmware/common 下的共享头文件,并让 bootloader 的 assert.hpp 通过该共享实现复用;保留现有
LIBRMCS_DEBUG_ASSERTS、assert_always 和 [[assume(...)]] 的行为不变。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@host/CMakeLists.txt`:
- Around line 175-186: `CPACK_PACKAGE_FILE_NAME` in `host/CMakeLists.txt` uses a
suffix rule based only on an exact "release" match, which is inconsistent with
how `LIBRMCS_DEBUG_ASSERTS` treats Release-like builds. Update the packaging
logic around the `PACKAGE_BUILD_MODE` / `CPACK_PACKAGE_FILE_NAME` block so
`Release`, `RelWithDebInfo`, and `MinSizeRel` are all treated as non-debug and
generate the same no-suffix package name, while only debug-style build modes
keep a build-mode suffix.

---

Nitpick comments:
In `@firmware/c_board/bootloader/src/utility/assert.hpp`:
- Around line 3-6: 此处的断言实现与 rmcs_board 版本完全重复,需要避免两处同步维护带来的遗漏风险。请把 assert.hpp
中的断言分支逻辑抽到 firmware/common 下的共享头文件,并让 bootloader 的 assert.hpp 通过该共享实现复用;保留现有
LIBRMCS_DEBUG_ASSERTS、assert_always 和 [[assume(...)]] 的行为不变。

In `@firmware/c_board/cmake/gcc-arm-none-eabi.cmake`:
- Around line 30-33: The CMAKE debug flag changes in gcc-arm-none-eabi.cmake
already match the PR goal, but the debug-optimized behavior should be
documented. Update the relevant user-facing note or build documentation to
mention that CMAKE_C_FLAGS_DEBUG and CMAKE_CXX_FLAGS_DEBUG now use -O3 -g3, and
briefly call out the expected tradeoff that variables may be optimized away and
stepping may not exactly match source; reference the debug/release flag
definitions in the gcc-arm-none-eabi.cmake configuration when updating the
description.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ae82d4be-d917-422b-a448-dab2485829ad

📥 Commits

Reviewing files that changed from the base of the PR and between ee674bd and c0adaf3.

📒 Files selected for processing (13)
  • Dockerfile.build_firmware
  • Dockerfile.build_sdk
  • core/src/utility/assert.hpp
  • core/src/utility/stack_allocator.hpp
  • firmware/c_board/CMakeLists.txt
  • firmware/c_board/bootloader/src/utility/assert.hpp
  • firmware/c_board/cmake/gcc-arm-none-eabi.cmake
  • firmware/common/cmake/librmcs_firmware.cmake
  • firmware/rmcs_board/CMakeLists.txt
  • firmware/rmcs_board/app/CMakeLists.txt
  • firmware/rmcs_board/bootloader/CMakeLists.txt
  • firmware/rmcs_board/bootloader/src/utility/assert.hpp
  • host/CMakeLists.txt

Comment thread host/CMakeLists.txt
@qzhhhi qzhhhi merged commit 446649b into main Jul 6, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in RMCS Slave SDK Jul 6, 2026
@qzhhhi qzhhhi deleted the dev/auto-debug branch July 6, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant