Skip to content

feat(build): allow buildSystems[].run[] to materialize declared runConfigurationTypes - #196

Merged
xiaoyumuxi merged 3 commits into
mainfrom
feat/build-run-configuration-type
Nov 24, 2026
Merged

xiaoyumuxi merged 3 commits into
mainfrom
feat/build-run-configuration-type

Conversation

@xiaoyumuxi

@xiaoyumuxi xiaoyumuxi commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

背景 / Why

目前在 Lithe 中,插件既可以通过 buildSystems[].runConfigurationTypes(runConfigurationTypes: 0)声明运行配置类型(拥有自定义分组、包内 SVG 图标、结构化编辑表单与 build.runConfigurationPlan 启动计划),也可以通过 buildSystems[].run[] 从构建模型目标自动发现运行配置(默认生成 build.provider 或裸命令条目)。

当同一个构建系统插件同时提供“手动新建的配置类型”和“从模型自动发现的运行目标”时,运行/调试配置对话框会拆出两个不同分组与图标(例如声明类型的自定义图标分组与通用扳手图标的构建分组),自动发现的条目也无法直接使用声明类型的结构化编辑表单。

本 PR 在 runConfigurationTypes 0 内做向后兼容补充(API-29,不提升能力版本号):允许任何构建系统插件在 buildSystems[].run[] 中通过可选字段 configurationType 与 values 引用自身声明的 runConfigurationTypes,使自动发现的模型目标直接物化为同一声明类型的 build.run-type 生成层配置,与手动新建配置共用分组、图标、编辑器表单和启动计划。旧宿主 Core 的 RunDeclaration 已带 #[serde(deny_unknown_fields)],会直接以 plugin.manifest.invalid 拒绝未知字段,不会静默忽略。

改动 / Changes

  • 清单声明与校验(runConfigurationTypes: 0 内兼容扩展,不升版):
    • rust/crates/build/src/manifest.rs:校验顺序调整为先校验 runConfigurationTypes 再校验 run。
    • rust/crates/build/src/manifest/run.rs:RunDeclaration 新增可选字段 configurationType 与 values;新增 validate_run_type_values 校验目标类型存在、字段存在与类型匹配、choice 枚举值合法、可见必填字段已提供值或默认值、模板变量合法(${root} / ${project.*} / ${target.*}),并与 source: "provider"、debug、entrypoints、fromTasks、arguments、extension、execution 互斥。
  • 模型解码与模板展开:
    • rust/crates/build/src/commands.rs、detect.rs、outputs.rs、plans.rs:向 run_entries 传入 plugin_id;新增 run_type_entry_parts 展开 run.name 与 run.values 模板,在 model.run[] 输出 provider: "build.run-type" 与 runType: { pluginID, buildSystemID, type, values },并使用 <buildSystemID>.<runID> 命名空间生成无冲突的 id。
  • 生成层、编辑覆盖与层合并:
    • rust/crates/execution/src/provider_runs.rs:ProviderRunConfiguration 扩展为同时支持 Provider(ProviderRunSelector) 与 RunType(GeneratedRunTypeConfiguration),校验路径边界/执行类型/唯一性,物化为确定性 ID generated:run-type:<16hex> 的 build.run-type 配置并纳入快照指纹。
    • rust/crates/execution/src/configuration/form.rs:SavedEntry::find 从 generated -> project -> local 顺序读取并合并,支持 runConfig.editorForm 与 runConfig.saveConfiguration 直接编辑并覆盖生成层 build.run-type 配置;当用户将非 . 的生成工作目录覆盖回 . 时显式写出 "cwd": "."。
    • rust/crates/execution/src/configuration/merge.rs:merge_extensions 对包含 type 键的 extensions.build(完整 RunTypeReference)执行整体替换,避免被清空的可选字段从生成层回渗。
  • 插件契约、Schema 与更新记录:
    • 更新 shared/plugins/contract/v1/plugin-manifest.schema.json、shared/plugins/contract/v1/README.md、shared/plugins/reference/capabilities-and-versions.md(中英)、shared/plugins/reference/domains/build-systems.md(中英)及 shared/plugins/reference/protocol-changelog.md(登记 #196)。
    • 未新增能力版本、宿主方法、宿主通知或 SDK 版本。
  • 测试:
    • rust/crates/core/src/tests/plugin_run_types.rs:使用合成插件 dev.lithe.test.generated-run-types 新增 run_configuration_types_generated_runs_are_validated 与 generated_run_type_decodes_generates_edits_launches_and_copies,覆盖清单校验、build.decodeModel、runConfig.generate、runConfig.resolve、runConfig.editorForm、runConfig.saveConfiguration(含清空可选字段与重置工作目录为 .)、build.runConfigurationPlan 及 runConfig.copyConfiguration。

验证 / Verification

  • cargo fmt --manifest-path rust/Cargo.toml --check:通过
  • node shared/plugins/scripts/verify-docs.mjs:通过
  • scripts/rust-core/verify-rust-core-comments.sh:通过
  • node scripts/rust-core/verify-platform-tests.mjs:通过(52 crates)
  • cargo test --manifest-path rust/Cargo.toml -p lithe-plugin-model -p lithe-plugin-manifest -p lithe-build -p lithe-execution:通过
  • cargo test --manifest-path rust/Cargo.toml -p lithe-core --lib plugin_run_types:12 passed, 0 failed
  • cargo test --manifest-path rust/Cargo.toml -p lithe-core --lib api_command_table:1 passed, 0 failed
  • LIBSQLITE3_SYS_USE_PKG_CONFIG=1 cargo clippy --manifest-path rust/Cargo.toml --workspace --all-targets --target x86_64-pc-windows-msvc -- -D warnings:通过

@xiaoyumuxi xiaoyumuxi changed the title feat(build): support runConfigurationTypes 1 for model-generated declared run configurations feat(build): allow buildSystems[].run[] to materialize declared runConfigurationTypes Nov 24, 2026
@xiaoyumuxi
xiaoyumuxi marked this pull request as ready for review November 24, 2026 08:31
@xiaoyumuxi
xiaoyumuxi merged commit 0d79e17 into main Nov 24, 2026
8 of 11 checks passed
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.

1 participant