Skip to content

Commit 5087d3a

Browse files
committed
docs: 新键在旧引擎上的行为(实测),并补上被我改得不准的那条消息
## 旧引擎怎么读这个键 —— 实测,不是推断 在 **2026.8.26.2** 上跑: * 出现在**依赖**清单里 ⇒ 静默接受,退 0 * 出现在**根**清单里 ⇒ `warning: [build] has unsupported key 'private_include_dirs' (ignored)`,退 0 ⇒ 包可以先用上它,不必等消费者升级。这条写进中英两份文档,因为它决定了 openkal-musl 现在能不能发 —— 能。 ⚠️ **唯一不成立的地方**:已发布 `xim` 描述符的 `target_cfg` 块里,不认识的子键是 **硬错误**(那段代码自己的注释就写着 "Unknown sub-keys stay a HARD ERROR here"), 会让整份清单加载失败。文档明说:索引下限指向认识它的引擎之前别写进那里。 ## 消息是承诺,而我把它改得不准了 `target_cfg` 的未知键报错列出「期望哪些键」,我加了 `private_include_dirs` 却没有 把它加进那份列表 —— 于是错误信息会把一个**已经被接受**的键说成不存在。补上。
1 parent 4ed7511 commit 5087d3a

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

docs/05-mcpp-toml.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,16 @@ after expansion — so a glob may name exactly the directories it expands to. An
219219
entry that is not among this package's `include_dirs` withholds nothing and is
220220
reported as such rather than passing in silence.
221221

222+
**On an older engine the key is ignored, never fatal.** Measured on 2026.8.26.2:
223+
in a dependency's manifest it is accepted silently, and in a root manifest it
224+
warns — `[build] has unsupported key 'private_include_dirs' (ignored)` — and the
225+
build continues. So a package may adopt the key without waiting for its
226+
consumers to upgrade; those on an older engine simply keep receiving the
227+
directory as they did before. The one place this does **not** hold is a
228+
published `xim` descriptor's `target_cfg` block, where an unrecognised sub-key
229+
is a hard error that fails the whole manifest — do not put this key there until
230+
the index floor names an engine that knows it.
231+
222232
`include_dirs_after` (#249) lists header directories that are searched **after**
223233
the toolchain's system directories (emitted as `-idirafter` on GCC/Clang, as
224234
trailing `/I` under the MSVC dialect, and as plain `-I` for NASM

docs/zh/05-mcpp-toml.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,13 @@ private_include_dirs = ["musl/src/include"]
201201
所以一个 glob 可以恰好指名它展开出的那些目录。若某条目不在本包的 `include_dirs`
202202
里,它什么也没扣下,mcpp 会把这件事说出来而不是让它悄悄通过。
203203

204+
**旧引擎会忽略这个键,而不会因此失败。** 在 2026.8.26.2 上实测:出现在依赖的清单里
205+
时被静默接受;出现在根清单里时给一条警告 —— `[build] has unsupported key
206+
'private_include_dirs' (ignored)` —— 构建照常继续。所以一个包可以先用上这个键,
207+
不必等消费者升级;还在旧引擎上的消费者只是像以前一样继续收到那个目录。**唯一不成立
208+
的地方**是已发布的 `xim` 描述符的 `target_cfg` 块:那里不认识的子键是硬错误,会让
209+
整份清单加载失败 —— 在索引下限指向认识它的引擎之前,不要把这个键写进那里。
210+
204211
`include_dirs_after`(#249)列出**排在工具链系统目录之后**搜索的头文件目录
205212
(GCC/Clang 发射为 `-idirafter`;MSVC 方言退化为排在末尾的 `/I`,NASM 汇编
206213
单元退化为普通 `-I`——两者都没有对应 flag,也都没有需要保护的系统头搜索链)。当目录是解压后的源码 tarball 根目录、且其中的文件名会与标准头冲突时,

src/manifest/xpkg.cppm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,8 @@ synthesize_from_xpkg_lua(std::string_view luaContent,
14111411
return std::unexpected(ManifestError{
14121412
std::format("unknown target_cfg key '{}' (expected "
14131413
"cflags/cxxflags/ldflags/sources/defines/"
1414-
"flags/include_dirs/include_dirs_after)", sub),
1414+
"flags/include_dirs/private_include_dirs/"
1415+
"include_dirs_after)", sub),
14151416
m.sourcePath, 0, 0});
14161417
}
14171418
if (!cur.consume('=') || !cur.consume('{')) {

0 commit comments

Comments
 (0)