From 5d37124462ab2787af5336ac149c7435b1ad797d Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Tue, 27 Oct 2026 15:15:37 +0900 Subject: [PATCH] mcpplibs.os 0.1.2: shared libraries at run time (mcpplibs.os.library) mcpplibs/os#5 adds the dynamic loader: open a library by path or name, find one the process already has, look up its symbols, and resolve a symbol of the program as the loader does. openmui's Python binding reaches the interpreter's stable C API this way, without headers or an import library. The consumer test moves to 0.1.2 and resolves a program symbol. --- pkgs/o/os.lua | 12 ++++++++++++ tests/examples/os/mcpp.toml | 2 +- tests/examples/os/tests/os.cpp | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pkgs/o/os.lua b/pkgs/o/os.lua index e7f12c89..6894a784 100644 --- a/pkgs/o/os.lua +++ b/pkgs/o/os.lua @@ -26,6 +26,10 @@ package = { xpm = { linux = { + ["0.1.2"] = { + url = "https://github.com/mcpplibs/os/archive/refs/tags/0.1.2.tar.gz", + sha256 = "bf6f5cfb1518b045b693e246ee39306746074586434419d4052e648be111ea34", + }, ["0.1.1"] = { url = "https://github.com/mcpplibs/os/archive/refs/tags/0.1.1.tar.gz", sha256 = "c5abfb625ded0d5d837b799722c836c302460251d47081fef7a57a2a12e6b2b9", @@ -39,6 +43,10 @@ package = { }, }, macosx = { + ["0.1.2"] = { + url = "https://github.com/mcpplibs/os/archive/refs/tags/0.1.2.tar.gz", + sha256 = "bf6f5cfb1518b045b693e246ee39306746074586434419d4052e648be111ea34", + }, ["0.1.1"] = { url = "https://github.com/mcpplibs/os/archive/refs/tags/0.1.1.tar.gz", sha256 = "c5abfb625ded0d5d837b799722c836c302460251d47081fef7a57a2a12e6b2b9", @@ -52,6 +60,10 @@ package = { }, }, windows = { + ["0.1.2"] = { + url = "https://github.com/mcpplibs/os/archive/refs/tags/0.1.2.tar.gz", + sha256 = "bf6f5cfb1518b045b693e246ee39306746074586434419d4052e648be111ea34", + }, ["0.1.1"] = { url = "https://github.com/mcpplibs/os/archive/refs/tags/0.1.1.tar.gz", sha256 = "c5abfb625ded0d5d837b799722c836c302460251d47081fef7a57a2a12e6b2b9", diff --git a/tests/examples/os/mcpp.toml b/tests/examples/os/mcpp.toml index ba244646..354280df 100644 --- a/tests/examples/os/mcpp.toml +++ b/tests/examples/os/mcpp.toml @@ -6,7 +6,7 @@ name = "os-tests" version = "0.1.0" [dependencies.mcpplibs] -os = "0.1.1" +os = "0.1.2" [indices] mcpplibs = { path = "../../.." } diff --git a/tests/examples/os/tests/os.cpp b/tests/examples/os/tests/os.cpp index 76cdc9d3..4333e169 100644 --- a/tests/examples/os/tests/os.cpp +++ b/tests/examples/os/tests/os.cpp @@ -40,6 +40,9 @@ int main(int argc, char** argv) { auto r = os::process::run(o); check(r && r->status.success() && r->out == "echoed", "a started program's output is read"); } + // 0.1.2: a symbol of the program resolves as the loader resolves it. + if (os::library::supported()) + check(os::library::process_symbol(os::is_windows ? "GetCurrentProcessId" : "getpid") != nullptr, "a program symbol resolves"); std::error_code ec; std::filesystem::remove_all(dir, ec); if (failures == 0) std::println("os-tests: held");