Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
> Each `## [<version>]` section is that release's notes. Entries are written in English
> from 2026.9.28.3 on; earlier entries remain as written.

## [2026.11.24.1] - 2026-11-24

### Fixed

- `mcpp pack --pkg-format <provided format> -o <directory>/` writes the distributable together
with the outputs it consumed that lie below its own directory, at their places relative to it.
Before, it wrote the distributable alone, so a web page (`--pkg-format web`) arrived without its
`.js`, its `.wasm` and its deployed files and loaded nothing. Each destination is replaced, and
nothing else in the directory is touched (SPEC-014 §6, v2.8).

## [2026.11.23.1] - 2026-11-23

### Added
Expand Down
8 changes: 8 additions & 0 deletions docs/30-build-mcpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,14 @@ second pass, the refusal lists the warnings it stated there (`mcpp::warning`,
`mcpp::report`) as its reasons, so a provider explains a decline with either and
not with its standard error, which mcpp shows only for a program that fails.

**`-o <directory>/` writes what the distributable reads beside it.** The
distributable is the output no other action consumes. With `-o <directory>/`, it
is written into that directory under its own name. The outputs it consumed that
lie below its own directory are written with it, at their places relative to it
(2026.11.24.1). For `web`, the page arrives with its `.js`, its `.wasm` and the
deployed files. Each destination is replaced, and nothing else in the directory
is touched.

**`mcpp pack --pkg-format <name>` prepares twice.** An `artifact` action is a ninja
edge and the staged tree is produced by mcpp *after* the link, so the tree
cannot be an input of the pass that built it. The first pass collects the
Expand Down
12 changes: 8 additions & 4 deletions docs/specs/packaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
|---|---|
| 规范编号 | SPEC-014 |
| 标题 | 打包与分发:链接、闭包、容器三个维度与构建腿,腿的合并,暂存树与包元数据,运行覆盖、单文件、容器列表、签名、压缩、合并与分发描述 |
| 状态 | 评审中 v2.7 |
| 版本 | 2.7 |
| 最后修改 | 2026-11-23 |
| 对应实现 | mcpp >= 2026.10.31.1;v2.2 条款 mcpp >= 2026.11.10.1;v2.3 条款 mcpp >= 2026.11.12.1;v2.4 条款 mcpp >= 2026.11.13.1;v2.5 条款 mcpp >= 2026.11.16.1;v2.6 条款 mcpp >= 2026.11.17.1;v2.7 条款 mcpp >= 2026.11.23.1 |
| 状态 | 评审中 v2.8 |
| 版本 | 2.8 |
| 最后修改 | 2026-11-24 |
| 对应实现 | mcpp >= 2026.10.31.1;v2.2 条款 mcpp >= 2026.11.10.1;v2.3 条款 mcpp >= 2026.11.12.1;v2.4 条款 mcpp >= 2026.11.13.1;v2.5 条款 mcpp >= 2026.11.16.1;v2.6 条款 mcpp >= 2026.11.17.1;v2.7 条款 mcpp >= 2026.11.23.1;v2.8 条款 mcpp >= 2026.11.24.1 |
| 相关设计文档 | `.agents/docs/2026-11-15-ecosystem-gap-supplement-design.md`(§5)、`.agents/docs/2026-10-30-ecosystem-part2-ide-and-language-service-design.md`(§19.6)、`.agents/docs/2026-10-29-ecosystem-target-sets-packaging-and-editors-design.md`(§4、§13)、`.agents/docs/2026-10-28-platforms-part2-packaging-and-distribution-design.md`(§2–§7、§14)、`.agents/docs/2026-10-28-platforms-design.md`(§4.7)、`.agents/docs/2026-10-29-openkal-run-test-pack-design.md`(§2.2、§2.6) |
| 相关 issue | mcpp#847、mcpp#849、mcpp#860 |
| 相关规范 | [SPEC-007](build-plugins.md)(包格式提供者、artifact action)、[SPEC-011](concurrency.md)(原子发布)、[SPEC-013](platforms.md)(平台、运行器、载体)、[SPEC-015](target-sets.md)(目标集合与腿) |
Expand Down Expand Up @@ -422,6 +422,9 @@ openkal 目标的单文件:载体携带一条腿的映像本身(映像不引用
(`mcpp::pack_stage_dir()`、`${mcpp.stage_dir}`)、其中的 `mcpp-package.json`、`MCPP_PACK_*` 环境;它报告的终端
输出即产物。未知的名字被拒绝,消息列出图中可用的格式。

`-o <目录>/` 时,产物以其名字写入该目录,它消费的同一提供者的输出中位于产物所在目录之下的,按相对产物的位置一并写入
(v2.8):产物在运行时从其旁读取的文件(网页的脚本与模块)随它交付。每个目标位置被替换,该目录中的其他内容不变。

提供者**可以**以 `mcpp::pack_program("<program>")` 陈述它从被打包的包的哪个程序组装产物(构建程序协议 19,
2026.11.16.1)。陈述与 `provides_pack_format` 一样无条件给出:程序在打包的第二遍之前选定。未指名程序的
`--pkg-format <name>` 打包该程序;命令行指名的程序优先;所请求格式的提供者陈述了不同的程序时拒绝并列出各项;
Expand Down Expand Up @@ -526,3 +529,4 @@ openkal 目标的单文件:载体携带一条腿的映像本身(映像不引用
| 2.6 | 2026-11-17 | mcpp 2026.11.17.1(设计 2026-11-16 §4.3):新增 §4.5.1 许可证文件,全部打包方式按包放置并报告缺失,取代只在 `self-contained` 中按固定文件名查找且不报告的做法。 |
| 2.5 | 2026-11-16 | mcpp 2026.11.16.1(设计 2026-11-15 N11、N20):§4.3 携带运行器的包不回落到 `PATH`,本机没有时以 126 退出并写出所含各项;`<os>` 取系统表的 `uname`;`--all-programs` 的树中每个程序有自己的启动器;§6 `mcpp::pack_program` 与提供者不提交的原因(N30)。 |
| 2.7 | 2026-11-23 | mcpp 2026.11.23.1(mcpp#1011):§1.2 部署的对象是闭包的根,其需求按程序的规则解析与携带。 |
| 2.8 | 2026-11-24 | mcpp 2026.11.24.1:§6 `-o <目录>/` 写入提供者的产物及其在产物目录下消费的输出。 |
4 changes: 4 additions & 0 deletions docs/zh/30-build-mcpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,10 @@ mcpp::pack_program("app"); // 协议 19,mcpp 2026.11.16.1
拒绝消息指名提供者。提供者在第二遍中什么也没有提交时,拒绝消息列出它在这一遍中陈述的警告(`mcpp::warning`、
`mcpp::report`)作为原因。因此提供者以这两者说明为何不提交,而不写标准错误:mcpp 只在程序失败时显示标准错误。

**`-o <目录>/` 写入产物在其旁读取的文件。** 产物是没有被其他 action 消费的输出。`-o <目录>/` 时产物以其名字写入该
目录;它消费的输出中位于产物所在目录之下的,按相对产物的位置一并写入(2026.11.24.1)。`web` 的页面因此与其 `.js`、
`.wasm` 和部署的文件一同到达。每个目标位置被替换,目录中的其他内容不变。

**`mcpp pack --pkg-format <name>` 会 prepare 两次。** 一条 `artifact` action 是一条
ninja 边,而那棵暂存树是 mcpp 在链接**之后**产出的,所以这棵树不可能成为构建出它自己
那一次 pass 的输入。第一次 pass 收集声明,并在任何东西被编译之前拒绝未知的格式;随后
Expand Down
2 changes: 1 addition & 1 deletion mcpp.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mcpp"
version = "2026.11.23.1"
version = "2026.11.24.1"
description = "Modern C++ build & package management tool"
license = "Apache-2.0"
authors = ["mcpp-community"]
Expand Down
2 changes: 1 addition & 1 deletion modules/versioning/src/version.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ import std;

export namespace mcpp {

inline constexpr std::string_view MCPP_VERSION = "2026.11.23.1";
inline constexpr std::string_view MCPP_VERSION = "2026.11.24.1";

} // namespace mcpp
37 changes: 32 additions & 5 deletions src/pack/pipeline.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,31 @@ std::optional<Refusal> stage_member(PackRun& run, GroupJob& g, MemberJob& m) {
return std::nullopt;
}

// Copy a provider's distributable `product` into `dir` under its own name, with
// those of `beside` (outputs the product consumed) below the product's own
// directory, at their places relative to it. Each destination is replaced, and
// nothing else in `dir` is touched. Returns why it failed, or nothing.
std::string copy_distributable(const std::filesystem::path& product,
const std::vector<std::filesystem::path>& beside,
const std::filesystem::path& dir) {
namespace fs = std::filesystem;
const auto base = product.parent_path().lexically_normal();
std::vector<std::pair<fs::path, fs::path>> copies{{product, dir / product.filename()}};
for (auto const& b : beside) {
const auto rel = b.lexically_normal().lexically_relative(base);
if (rel.empty() || *rel.begin() == "..") continue;
copies.emplace_back(b, dir / rel);
}
std::error_code ec;
for (auto const& [from, to] : copies) {
fs::remove_all(to, ec);
if (to.has_parent_path()) fs::create_directories(to.parent_path(), ec);
fs::copy(from, to, fs::copy_options::recursive, ec);
if (ec) return std::format("cannot write {}: {}", to.string(), ec.message());
}
return {};
}

// ─── The dispatch pass ───────────────────────────────────────────────
//
// A `role = "artifact"` action is a ninja edge, and the staged tree is
Expand Down Expand Up @@ -1637,18 +1662,20 @@ std::optional<Refusal> dispatch_group(PackRun& run, GroupJob& g, mcpp::build::Ba
reported.push_back(std::move(abs));
}
if (!produced) continue;
// `-o <directory>/`: the distributable below it, under its own name.
// `-o <directory>/`: the distributable below it, under its own name,
// with the outputs it consumed that lie in its own directory, at their
// places relative to it. A page reads its script and module from beside
// it (dist-web's index.html, web-consumer.js, web-consumer.wasm); copied
// alone it loads nothing (2026.11.23.1 wrote dist/pack/index.html only).
if (!run.opts.outputDir.empty())
for (auto& r : reported) {
const auto into = std::filesystem::absolute(run.opts.outputDir / r.filename(), ec).lexically_normal();
// A provider may have written it there already (the okb is
// written beside the staged tree, in target/dist/): removing
// the destination would remove the product.
if (into == r.lexically_normal()) continue;
std::filesystem::remove_all(into, ec);
std::filesystem::copy(r, into, std::filesystem::copy_options::recursive, ec);
if (ec) {
mcpp::ui::error(about(run, m, std::format("cannot write {}: {}", into.string(), ec.message())));
if (auto why = copy_distributable(r, intermediate, into.parent_path()); !why.empty()) {
mcpp::ui::error(about(run, m, why));
m.result.rc = 1;
break;
}
Expand Down
52 changes: 51 additions & 1 deletion tests/e2e/pack/formats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// pack, stripping what the graph built, the JSON report and the profile shorthands, a summary
// of many outputs, the build a pack states and its job count, the three axes of a package,
// the compression a provided format is told (formerly tests/e2e/638, 689, 722, 723, 841, 871,
// 954, 1008).
// 954, 1008), and what `-o <directory>/` writes of a provided format's distributable.
import std;
import mcpplibs.mtest;
import mcpp.test.support;
Expand Down Expand Up @@ -926,6 +926,56 @@ int main() {
expect(fatal(failed(r))) << "D: a directory was compressed\n" << s::text(r);
expect(e2e::contains(s::text(r), "writes none")) << "D: the refusal\n" << s::text(r);
};

"1160 a provided format's distributable is written to -o with what it reads beside it"_test[s::pack] = [] {
// A provider's distributable is the output no other action consumes; a page is one, and
// it reads the files it consumed from beside it. `-o <directory>/` writes the page with
// those files at their places relative to it, and leaves the directory's other contents
// (2026.11.23.1 wrote the page alone: dist-web's index.html without its .js and .wasm).
const auto tmp = s::case_dir();
s::project app{tmp / "app", {{"mcpp.toml", R"cpp([package]
name = "app"
version = "0.1.0"
standard = "c++20"

[targets.app]
kind = "bin"
main = "src/main.cpp"
)cpp"}, {"src/main.cpp", "int main() { return 0; }\n"}, {"build.mcpp", R"cpp(import mcpp;
#include <string>
#include <string_view>
int main() {
mcpp::provides_pack_format("site");
if (std::string_view(mcpp::pack_format()) != "site") return 0;
const std::string dir = std::string(mcpp::out_dir()) + "/site";
const std::string data = dir + "/assets/data.txt", page = dir + "/page.txt";
mcpp::action d;
d.id = "data";
d.role = "artifact";
d.description = "data";
d.arg("/bin/sh").arg("-c").arg(("mkdir -p " + dir + "/assets && printf data > " + data).c_str())
.input("${mcpp.target_file:app}")
.output(data.c_str())
.submit();
mcpp::action p;
p.id = "page";
p.role = "artifact";
p.description = "page";
p.arg("/bin/sh").arg("-c").arg(("printf page > " + page).c_str())
.input(data.c_str())
.output(page.c_str())
.submit();
return 0;
}
)cpp"}}};
app.write("dist/other/keep.txt", "keep");
auto r = app.mcpp({"pack", "--pkg-format", "site", "-o", "dist/site/"});
expect(fatal(e2e::succeeded(r))) << "pack failed\n" << s::text(r);
expect(fatal(s::read_file(app.at("dist/site/page.txt")) == "page")) << "the page\n" << s::text(r);
expect(fatal(s::read_file(app.at("dist/site/assets/data.txt")) == "data"))
<< "the file the page reads beside it was not written\n" << s::text(r);
expect(fatal(s::read_file(app.at("dist/other/keep.txt")) == "keep")) << "another directory's file was touched";
};
}};

} // namespace
Loading