我们目前使用 Conan 2 profile 的 [replace_requires] 作为产品定制替换机制。
当前现象是:Conan graph 本身可以正确解析,lockfile 里也已经是替换后的组件版本。但在 graph/lockfile 生成之后,构建流程还会做一层 manifest/lock 版本一致性校验。
issue如下:
这个后置校验当前只比较:
manifest 中的原始组件 name/version
lockfile 中最终解析出来的组件 name/version
因此,当 [replace_requires] 有意把社区组件替换成产品定制组件版本时,Conan graph 是正确的,但后置校验会失败。
最小示例
manifest:
component_a/1.2.3@upstream/stable
profile:
[replace_requires]
component_a/*@upstream/stable: component_a/1.2.5@product/stable
Conan graph / lockfile:
component_a/1.2.5@product/stable
当前后置校验:
manifest component_a/1.2.3 != lockfile component_a/1.2.5
=> fail
这里 profile 并没有失效,Conan 也已经正确应用了 replacement。失败原因是后置版本校验没有理解 [replace_requires] 的替换语义。
已验证的 replacement 类型
1. 只替换 user/channel
component/*@upstream/stable: component/*@product/stable
这种方式版本号不变。如果 product channel 里存在相同版本,后置版本校验通常可以通过。
2. 精确替换到指定版本
component/*@upstream/stable: component/1.2.5@product/stable
Conan graph 可以正确解析,但如果最终版本和 manifest 中的版本不同,后置校验会失败。
3. 范围替换
component/*@upstream/stable: component/[>=1.2.0 <1.3.0]@product/stable
Conan graph 可以正确解析到满足范围的实际版本,但如果最终版本和 manifest 中的版本不同,后置校验也会失败。
期望行为
1. 读取 manifest 中的原始组件 ref。
2. 读取 lockfile 中最终解析出来的组件 ref。
3. 如果 name/version 一致,保持原逻辑,直接通过。
4. 如果 name/version 不一致,读取最终生效 profile。
5. 解析 profile 中的 [replace_requires]。
6. 判断 lockfile 中的 ref 是否是 manifest 原始 ref 按 replacement 规则替换后的合法结果。
7. 如果 replacement 规则允许这个结果,则通过。
8. 如果没有对应 replacement 规则支撑,则仍然失败。
这样不会放松原有 manifest/lock 一致性校验,只是让校验逻辑兼容 Conan 2 [replace_requires] 的语义。
相关问题:profile overlay
我们希望 [replace_requires] 作为产品侧的小型 overlay 叠加在默认生成的 profile 上,而不是维护一份完整 profile。
现在如果显式传入自定义 profile,它更像是完整 profile,需要复制 settings/options/toolchain 等默认配置。这样后续默认 profile 变化时,产品侧 profile 容易漂移。
想确认是否有推荐的 profile 组合方式,例如:
默认生成 profile
+ 产品定制 replace_requires overlay
目标是只维护产品差异,也就是 [replace_requires] 白名单,而不需要复制整份默认 profile。
需要社区确认的问题
-
bmcgo/bingo 的 manifest/lock 后置版本校验是否应该理解 Conan 2
[replace_requires]。 -
当 replacement 明确允许版本变化时,lockfile 中的最终版本是否应被认为是合法结果。
-
是否支持 profile overlay,只追加
[replace_requires],其余 settings/options/toolchain 继承默认 profile。 -
如果当前不支持 overlay,产品季度反合是否只能维护完整 profile,或者由工具层合成最终 profile。