Skip to content

Commit c82c95c

Browse files
pack: several programs, none named after the package: the first by name, as before, and said (B3 without a refusal)
The refusal broke an existing `mcpp pack` (mcppls). The program packed is said with the others and the two ways to choose (`mcpp pack <program>`, `--all-programs`). e2e 1043. Co-authored-by: speak-agent <248744407+speak-agent@users.noreply.github.com>
1 parent 8040480 commit c82c95c

4 files changed

Lines changed: 26 additions & 24 deletions

File tree

‎.agents/docs/2026-11-09-target-model-design.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Emscripten SDK。openkal-platform 的 hosted 部分为提供者,服务 `*-linu
124124
| G11 执行宿主 | 运行器协议:传输、运行、输出流、退出码,由 runner 包实现(VM、ssh、设备);无运行器的异系统产物为「已构建,未运行」 |
125125
| B1 | 生成的清单以 TOML 引号书写含 `.` 的目标名 |
126126
| B2 | 平台规定的产物后缀不被宿主后缀规则覆盖;冲突在规划期报告 |
127-
| B3 | 多个程序可打包时拒绝并说明,提供打包一个包的全部程序的写法 |
127+
| B3 | 多个程序可打包时照旧打包(以包命名者,否则按名字的第一个)并说明其余程序与两种选择写法(`mcpp pack <program>`、`--all-programs`) |
128128
| 构建插件(SPEC-007) | SPEC-013 §1.2 的分工不变:行、提供者、层只能声明(解析工具链与依赖图时尚无程序可运行);`build`、`link`、`runner` 可由插件陈述,来源记录;构建程序的 `artifact-name` 不改变平台的产物格式 |
129129

130130
## 9. 多视角自审
@@ -410,3 +410,4 @@ mcpp 的单元测试(`tests/unit/` 166 个文件,以及各成员的 `modules
410410
| 交叉目标的 `[target.<t>] toolchain` | 构建程序取被它替换的规格 | 与行的 pin 同一规则;该段名的是目标的编译器 |
411411
| mcppls 的自启动测试 | mtest `child` 对象;需独立缓存的两个测试放在 `tests/isolated/` | mcpplibs.os 不修改进程自身环境,隔离缓存只能由新进程获得 |
412412
| openkal-run 的实现 | 能力槽加按系统默认(D2,openkal-image 0.5.4) | 图或平台已有的实现优先,FreeBSD 等新系统无需修补该包 |
413+
| B3 无同名程序 | 照旧打包按名字的第一个并说明,不拒绝 | 拒绝曾打破既有工程的 `mcpp pack`(mcppls);问题在于不说明,不在于选择本身 |

‎CHANGELOG.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@
8989
project's spelling and is kept, and a disagreement with the graph's C library
9090
is reported.
9191
- A git dependency names at most one of rev, tag and branch.
92-
- `mcpp pack` with several programs packs the one named after the package and
93-
names the others, and refuses when none is so named.
92+
- `mcpp pack` with several programs packs the one named after the package,
93+
else the first by name as before, and names the others with
94+
`mcpp pack <program>` and `--all-programs`.
9495
- mcpp's own unit tests are mtest cases (mtest 0.5.1, mcpplibs.os 0.4.1); a
9596
skeleton's tests use mtest 0.5.1.
9697

‎src/pack/pipeline.cppm‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -537,19 +537,14 @@ std::optional<Refusal> member_plan(PackRun& run, GroupJob& g, MemberJob& m) {
537537
break;
538538
}
539539
}
540-
// SEVERAL PROGRAMS ARE NOT PACKED BY A GUESS (mcpp#911 B3): the program
541-
// named after the package is the package's, and the others are said; with
542-
// none so named, the command names one or ships them all.
540+
// SEVERAL PROGRAMS ARE NOT PACKED WITHOUT A WORD (mcpp#911 B3): the
541+
// program named after the package is the package's; with none so named,
542+
// the first by name, as before. Either way the others are said, with the
543+
// two ways to choose otherwise.
543544
std::vector<const mcpp::build::LinkUnit*> programs;
544545
for (auto const& lu : ctx.plan.linkUnits)
545546
if (is_program_link_unit(lu)) programs.push_back(&lu);
546-
std::string names;
547-
for (auto const* lu : programs) names += (names.empty() ? "" : ", ") + lu->targetName;
548-
if (mainBinary.empty() && programs.size() > 1 && !opts.allPrograms)
549-
return Refusal{2, about(run, m, std::format(
550-
"the package has several programs ({}) and none is named after it\n"
551-
" name one: mcpp pack <program>\n or ship them together: mcpp pack --all-programs",
552-
names))};
547+
const bool named = !mainBinary.empty();
553548
if (mainBinary.empty() && !programs.empty()) {
554549
mainBinary = ctx.outputDir / programs.front()->output;
555550
chosenLu = programs.front();
@@ -561,8 +556,10 @@ std::optional<Refusal> member_plan(PackRun& run, GroupJob& g, MemberJob& m) {
561556
for (auto const* lu : programs)
562557
if (lu != chosenLu) others += (others.empty() ? "" : ", ") + lu->targetName;
563558
mcpp::ui::note(std::format(
564-
"packing {}, the program named after the package; its other programs are not packed "
565-
"({}): `mcpp pack --all-programs` ships them beside it", chosenLu->targetName, others));
559+
"packing {}, {}; its other programs are not packed ({}): `mcpp pack <program>` names "
560+
"another, `mcpp pack --all-programs` ships them beside it", chosenLu->targetName,
561+
named ? "the program named after the package" : "the first by name, as none is named after the package",
562+
others));
566563
}
567564
// Passed to `make_plan` rather than re-derived from the file: `make_plan`
568565
// has only `mainBinary` and would otherwise have to ask the triple and

‎tests/e2e/1043_several_programs_and_a_dotted_name_are_packed_as_stated.sh‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ source "$(dirname "${BASH_SOURCE[0]}")/_toolchain_env.sh"
44
# 1043 -- several programs are packed as stated, and a program whose name has a dot is packed
55
# (mcpp#911 B1, B3).
66
#
7-
# A package with several programs and none named after it is not packed by a guess: `mcpp pack`
8-
# refuses and names the two forms, `mcpp pack <program>` and `mcpp pack --all-programs`. With
9-
# one named after the package, that one is packed and the others are said. A manifest `mcpp pack`
7+
# A package with several programs is not packed without a word: the one named after the package,
8+
# else the first by name, is packed, and the others are said with the two ways to choose
9+
# otherwise, `mcpp pack <program>` and `mcpp pack --all-programs`. A manifest `mcpp pack`
1010
# generates quotes a target name with a dot (`COMMAND.COM`), so the generated project parses.
1111
#
12-
# Criteria: the refusal lists the programs; `--all-programs` ships both under bin/; a single-file
12+
# Criteria: with none named after the package the first by name is packed and the others are said;
13+
# `--all-programs` ships both under bin/; a single-file
1314
# pack of `COMMAND.COM` builds its launcher and the file runs with the program's exit status.
1415
set -e
1516
t=$(mktemp -d); trap 'rm -rf "$t"' EXIT
@@ -32,11 +33,13 @@ echo 'int main() { return 0; }' > "$t/src/alpha.cpp"
3233
echo 'int main() { return 3; }' > "$t/src/command.cpp"
3334
cd "$t"
3435

35-
set +e; out=$("$MCPP" pack 2>&1); rc=$?; set -e
36-
[ "$rc" != 0 ] || fail "several programs were packed by a guess" "$out"
37-
grep -q "several programs (COMMAND.COM, alpha) and none is named after it" <<<"$out" || fail "the refusal does not list the programs" "$out"
38-
grep -q "mcpp pack --all-programs" <<<"$out" || fail "the refusal does not name --all-programs" "$out"
39-
echo " ok several programs, none named after the package: refused with both forms"
36+
out=$("$MCPP" pack 2>&1) || fail "several programs, none named after the package, were not packed" "$out"
37+
grep -q "packing COMMAND.COM, the first by name, as none is named after the package" <<<"$out" \
38+
|| fail "the program packed is not said" "$out"
39+
grep -q "(alpha)" <<<"$out" && grep -q "mcpp pack --all-programs" <<<"$out" \
40+
|| fail "the others and the ways to choose are not said" "$out"
41+
rm -rf target/dist
42+
echo " ok several programs, none named after the package: the first by name, the others said"
4043

4144
out=$("$MCPP" pack --all-programs 2>&1) || fail "--all-programs did not pack" "$out"
4245
listing=$(tar tzf target/dist/multi-0.1.0-*.tar.gz)

0 commit comments

Comments
 (0)