Skip to content

fix: 为模块消费者恢复已有 PCM - #15

Open
helantianshen wants to merge 2 commits into
mcpp-community:mainfrom
helantianshen:fix/restore-missing-module-pcm
Open

fix: 为模块消费者恢复已有 PCM#15
helantianshen wants to merge 2 commits into
mcpp-community:mainfrom
helantianshen:fix/restore-missing-module-pcm

Conversation

@helantianshen

Copy link
Copy Markdown

问题

mcpp 可能为同一项目生成多个兼容的构建上下文。模块接口的 PCM 已在一个上下文中生成,但测试或其他消费者的 compile_commands.json 指向另一个 pcm.cache

插件此前只按 CDB 启动 clangd,不会恢复消费者目录缺少的模块产物,因此一键配置或刷新编译数据库后仍可能出现:

  • Module 'mcpplibs.cmp' not found
  • module file not found
  • clangd 无法加载所需模块产物

修复

  • 解析 CDB 时优先选择项目内的模块消费者,并记录模块源与消费者各自的 PCM 目录。
  • 只在同一项目、同一编译器和同一目标平台的兼容构建上下文之间复制 PCM。
  • 仅恢复消费者缺少或较旧的 PCM,不删除或改写已有的新版本。
  • 在自动协调、一键配置以及手动「检查/重新检查模块支持」之前执行恢复;发生复制时先重启 clangd,再运行模块检查。

插件不自行生成模块映射,也不会跨编译器或跨目标平台复用缓存。

验证

  • npm test:269/269 通过
  • npm run package:成功生成 VSIX
  • Extension Host E2E:1/1 通过
  • VS Code Remote: WSL:模块消费者缺少 PCM 时能够从兼容构建上下文恢复
  • Windows 原生环境:mcpp 2026.8.11.3、LLVM/clangd 22.1.8;mcpp buildmcpp build --configure-only 均成功
  • Windows CDB 参数没有多余双引号;模块检查不再以 module_not_found / ast_file_not_found 作为结果

环境说明

Windows 上 mcpp 2026.8.11.3 检查内置 xlings 时会使用 Linux 重定向写法,cmd.exe 因而输出 The system cannot find the path specified.。本机已按 mcpp 支持的配置改用 xlings.binary = "system",复用版本一致的 xlings 2026.8.11.2;该环境问题不需要由插件绕过。

项目是纯库目标,因此 mcpp run 返回 error: no binary target in this package 属于预期行为。

@helantianshen
helantianshen marked this pull request as ready for review August 12, 2026 08:53
@helantianshen

Copy link
Copy Markdown
Author

@wellwei

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