From 64c3d64d21bb693344896f82effa37277af3e82b Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Tue, 27 Oct 2026 17:42:05 +0900 Subject: [PATCH] mcpplibs.os 0.2.0 Co-authored-by: speak-agent <248744407+speak-agent@users.noreply.github.com> --- CHANGELOG.md | 6 ++++++ pkgs/o/os.lua | 12 ++++++++++++ tests/examples/os/mcpp.toml | 5 +++-- tests/examples/os/tests/os.cpp | 19 +++++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d9cc50f..1bd39a08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,12 @@ openkal-macos 0.15.1 与 openkal-windows 0.13.3,以 `KAL_SPAWN_ONE_STRING` 启动命令解释器的 image 在 okrun 下得到该标志的语义;三个包仍为同一版本、同一归档。openkal-musl 随 openkal-windows 0.13.3 与 openkal-ld 0.1.1 移动,openkal-llvm-runtime 随 openkal-musl 移动。测试成员 `openkal`、`openkal-musl`、`openkal-tools` 随之移动。 +- **mcpplibs.os 0.2.0。** mcpp 的操作系统层所承载的内容进入 os:`exec`(本进程成为另一个程序)、 + 一个管道按写入顺序承载输出与错误输出、追加写与持久化、卷的容量、`place` 与 `exchange`、属主、 + 处理器数与可用内存、有界读取输入、发往错误流的输出、保留中断的原始模式,以及 Windows 的事实。 + 基于 openkal 0.17.1(openkal-linux 0.18.2、openkal-macos 0.15.1、openkal-windows 0.13.3);ok image + 形态基于 openkal-llvm-runtime 0.16.3 与 openkal-tools 0.1.1。测试成员 `os` 移到 0.2.0,并观察两个输出 + 经一个管道按序到达。 ### Changed diff --git a/pkgs/o/os.lua b/pkgs/o/os.lua index 6894a784..2afbe13c 100644 --- a/pkgs/o/os.lua +++ b/pkgs/o/os.lua @@ -26,6 +26,10 @@ package = { xpm = { linux = { + ["0.2.0"] = { + url = "https://github.com/mcpplibs/os/archive/refs/tags/0.2.0.tar.gz", + sha256 = "9dc147ad8dca0216549c40dc4dfabaed7394cdf7a7f253c58613ccc226abd04e", + }, ["0.1.2"] = { url = "https://github.com/mcpplibs/os/archive/refs/tags/0.1.2.tar.gz", sha256 = "bf6f5cfb1518b045b693e246ee39306746074586434419d4052e648be111ea34", @@ -43,6 +47,10 @@ package = { }, }, macosx = { + ["0.2.0"] = { + url = "https://github.com/mcpplibs/os/archive/refs/tags/0.2.0.tar.gz", + sha256 = "9dc147ad8dca0216549c40dc4dfabaed7394cdf7a7f253c58613ccc226abd04e", + }, ["0.1.2"] = { url = "https://github.com/mcpplibs/os/archive/refs/tags/0.1.2.tar.gz", sha256 = "bf6f5cfb1518b045b693e246ee39306746074586434419d4052e648be111ea34", @@ -60,6 +68,10 @@ package = { }, }, windows = { + ["0.2.0"] = { + url = "https://github.com/mcpplibs/os/archive/refs/tags/0.2.0.tar.gz", + sha256 = "9dc147ad8dca0216549c40dc4dfabaed7394cdf7a7f253c58613ccc226abd04e", + }, ["0.1.2"] = { url = "https://github.com/mcpplibs/os/archive/refs/tags/0.1.2.tar.gz", sha256 = "bf6f5cfb1518b045b693e246ee39306746074586434419d4052e648be111ea34", diff --git a/tests/examples/os/mcpp.toml b/tests/examples/os/mcpp.toml index 354280df..6bad1b85 100644 --- a/tests/examples/os/mcpp.toml +++ b/tests/examples/os/mcpp.toml @@ -1,12 +1,13 @@ # mcpplibs.os test project: the library over this system's openkal # implementation, on every runner --- a program started and read, a file -# published, a list of directories split, and the platform the build is for. +# published, a list of directories split, the platform the build is for, and a +# program's two outputs on one pipe. [package] name = "os-tests" version = "0.1.0" [dependencies.mcpplibs] -os = "0.1.2" +os = "0.2.0" [indices] mcpplibs = { path = "../../.." } diff --git a/tests/examples/os/tests/os.cpp b/tests/examples/os/tests/os.cpp index 4333e169..647d28e8 100644 --- a/tests/examples/os/tests/os.cpp +++ b/tests/examples/os/tests/os.cpp @@ -10,6 +10,11 @@ int main(int argc, char** argv) { (void)os::stdio::write_output("echoed"); return 0; } + if (argc > 1 && std::string_view(argv[1]) == "--both") { + (void)os::stdio::write_output("out "); + (void)os::stdio::write_error("err"); + return 0; + } int failures = 0; auto check = [&](bool ok, std::string_view what) { if (!ok) { ++failures; std::println(std::cerr, "FAIL: {}", what); } }; @@ -39,6 +44,20 @@ int main(int argc, char** argv) { o.args.push_back("--echo"); auto r = os::process::run(o); check(r && r->status.success() && r->out == "echoed", "a started program's output is read"); + + // 0.2.0: one pipe carries the output and the error output in the order written. + o.args.back() = "--both"; + o.out = os::process::stdio::pipe; + o.err = os::process::stdio::output; + std::string merged; + auto p = os::process::process::spawn(o); + if (p) { + for (;;) { auto c = p->read_output(); if (!c || c->empty()) break; merged += *c; } + auto st = p->wait(); + check(st && st->success() && merged == "out err", "both outputs arrive on one pipe in order"); + } else { + check(false, "a program with both outputs on one pipe starts"); + } } // 0.1.2: a symbol of the program resolves as the loader resolves it. if (os::library::supported())