Skip to content

feat: 新增项目级构建 Hook - #530

Open
helantianshen wants to merge 1 commit into
mcpp-community:mainfrom
helantianshen:feat/project-build-hooks
Open

feat: 新增项目级构建 Hook#530
helantianshen wants to merge 1 commit into
mcpp-community:mainfrom
helantianshen:feat/project-build-hooks

Conversation

@helantianshen

@helantianshen helantianshen commented Aug 29, 2026

Copy link
Copy Markdown

Closes #496

说明

mcpp build 增加项目级构建生命周期 Hook。Hook 在项目的 mcpp.toml 中配置,适用于普通项目和 workspace 成员构建。

配置

[hooks]
build_start = "echo build started"
build_failed = "notify-send 'build failed'"
build_finished = "notify-send 'build finished'"

# 以下配置可省略
timeout_seconds = 10
enabled = true
side_effect = true
  • build_start:项目准备完成、正式构建开始前执行。
  • build_finished:构建成功结束后执行。
  • build_failed:构建失败后执行。
  • timeout_seconds:每条命令的最长执行时间,默认 10 秒。
  • enabled:是否启用本表中的 Hook,默认 true
  • side_effect:Hook 失败是否使本次构建失败,默认 true

执行行为

  • 命令在项目根目录同步执行,使用宿主 Shell(/bin/shcmd.exe),并沿用终端的标准输入、输出和错误。
  • build_finishedbuild_failed 互斥。
  • 命令无法启动、返回非零或超时均视为 Hook 失败。
  • side_effect = false 时仅输出 warning 并保留原构建结果;默认配置下 Hook 失败会使构建返回失败。
  • Hook 自身失败不会触发另一个 Hook。
  • 未配置或已禁用 Hook 的项目保持现有构建路径。

配套示例应用为 mcpp-hooks-audioplayer,对应包索引提交为 openxlings/xim-pkgindex#712

其他修改

  • 增加中英文配置文档。
  • 增加端到端测试,覆盖成功、失败、禁用、超时、side_effect 和非法配置。

验证

  • 从本分支源码构建 mcpp:通过。
  • tests/e2e/314_project_build_hooks.sh:通过。
  • 全量 mcpp test:96 passed,0 failed。

@helantianshen helantianshen changed the title feat: add project-level build hooks feat: 新增项目级构建 Hook Aug 29, 2026
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.

feat/RFC: mcpp 项目级构建 Hook 机制

1 participant