From e794486161b1a8d8796a9e94bd1624ca436af043 Mon Sep 17 00:00:00 2001 From: Cloud_Yun <1770669041@qq.com> Date: Wed, 8 Jul 2026 00:33:14 +0900 Subject: [PATCH 1/2] feat: Add compat.tomlplusplus v3.4.0 Add toml++ as a C++23 module package (import tomlplusplus). - Add pkgs/c/compat.tomlplusplus.lua (module wrapper, MIT) - Add tests/examples/tomlplusplus with import-based test - Declares modules = { "tomlplusplus" } for import support - Uses fork's src/modules/tomlplusplus.cppm as source - SHA256: cefd81c09ae8eade62f254ba0903e4585944cc86e84c320a92116a95cb725862 toml++ is a TOML v1.0.0 config file parser and serializer for C++17+. Fork: https://github.com/yspbwx2010/tomlplusplus @ v3.4.0-mcpp --- pkgs/c/compat.tomlplusplus.lua | 73 ++++++++++++++++++++++++ tests/examples/tomlplusplus/mcpp.toml | 12 ++++ tests/examples/tomlplusplus/src/main.cpp | 22 +++++++ 3 files changed, 107 insertions(+) create mode 100644 pkgs/c/compat.tomlplusplus.lua create mode 100644 tests/examples/tomlplusplus/mcpp.toml create mode 100644 tests/examples/tomlplusplus/src/main.cpp diff --git a/pkgs/c/compat.tomlplusplus.lua b/pkgs/c/compat.tomlplusplus.lua new file mode 100644 index 0000000..edc803f --- /dev/null +++ b/pkgs/c/compat.tomlplusplus.lua @@ -0,0 +1,73 @@ +-- Form B inline descriptor for toml++ — a TOML config file parser and +-- serializer for C++17 (and later), exposed as the C++23 module +-- `tomlplusplus` so users can write `import tomlplusplus;` out of the box +-- (no opt-in, no `#include` needed). +-- +-- Why the fork: upstream's released v3.4.0 tarball is header-only and ships +-- NO module interface unit at a release tag. Upstream HAS authored an official +-- one at `src/modules/tomlplusplus.cppm` (`export module tomlplusplus;`), but +-- it lives on the master branch only and is not in the v3.4.0 release. So this +-- package uses a fork (yspbwx2010/tomlplusplus @ v3.4.0-mcpp) that carries the +-- module unit plus mcpp packaging (mcpp.toml, tests, docs) at a reproducible tag. +-- +-- The module unit (`src/modules/tomlplusplus.cppm`) does `#include +-- ` in its global-module fragment then re-exports the `toml` +-- namespace, so `include_dirs` exposes `include/` for that include to resolve +-- (and `#include ` remains available to users who want it). +-- +-- All upstream paths are GLOBS relative to the verdir; the leading `*` absorbs +-- the GitHub archive's `tomlplusplus-/` wrap layer. +package = { + spec = "1", + namespace = "compat", + name = "compat.tomlplusplus", + description = "TOML config file parser and serializer, exposed as C++23 module tomlplusplus", + licenses = {"MIT"}, + repo = "https://github.com/yspbwx2010/tomlplusplus", + type = "package", + + xpm = { + linux = { + ["3.4.0"] = { + url = { + GLOBAL = "https://github.com/yspbwx2010/tomlplusplus/archive/refs/tags/v3.4.0-mcpp.tar.gz", + CN = "https://github.com/yspbwx2010/tomlplusplus/archive/refs/tags/v3.4.0-mcpp.tar.gz", + }, + sha256 = "cefd81c09ae8eade62f254ba0903e4585944cc86e84c320a92116a95cb725862", + }, + }, + macosx = { + ["3.4.0"] = { + url = { + GLOBAL = "https://github.com/yspbwx2010/tomlplusplus/archive/refs/tags/v3.4.0-mcpp.tar.gz", + CN = "https://github.com/yspbwx2010/tomlplusplus/archive/refs/tags/v3.4.0-mcpp.tar.gz", + }, + sha256 = "cefd81c09ae8eade62f254ba0903e4585944cc86e84c320a92116a95cb725862", + }, + }, + windows = { + ["3.4.0"] = { + url = { + GLOBAL = "https://github.com/yspbwx2010/tomlplusplus/archive/refs/tags/v3.4.0-mcpp.tar.gz", + CN = "https://github.com/yspbwx2010/tomlplusplus/archive/refs/tags/v3.4.0-mcpp.tar.gz", + }, + sha256 = "cefd81c09ae8eade62f254ba0903e4585944cc86e84c320a92116a95cb725862", + }, + }, + }, + + mcpp = { + schema = "0.1", + language = "c++23", + import_std = false, + modules = { "tomlplusplus" }, + -- Tarball's include/ subdirectory: the module unit's global-module + -- fragment does `#include `, resolved from here. + include_dirs = { "*/include" }, + -- Upstream's official module unit (fork @ src/modules/tomlplusplus.cppm). + sources = { "*/src/modules/tomlplusplus.cppm" }, + targets = { ["tomlplusplus"] = { kind = "lib" } }, + features = {}, + deps = {}, + }, +} diff --git a/tests/examples/tomlplusplus/mcpp.toml b/tests/examples/tomlplusplus/mcpp.toml new file mode 100644 index 0000000..32f67f7 --- /dev/null +++ b/tests/examples/tomlplusplus/mcpp.toml @@ -0,0 +1,12 @@ +[package] +name = "test-tomlplusplus" + +[targets.test-tomlplusplus] +kind = "bin" +main = "src/main.cpp" + +[indices] +compat = { path = "../../.." } + +[dependencies] +"compat.tomlplusplus" = "3.4.0" diff --git a/tests/examples/tomlplusplus/src/main.cpp b/tests/examples/tomlplusplus/src/main.cpp new file mode 100644 index 0000000..855a229 --- /dev/null +++ b/tests/examples/tomlplusplus/src/main.cpp @@ -0,0 +1,22 @@ +import tomlplusplus; +import std; + +int main() { + // Parse TOML from string + auto config = toml::parse(R"( + [server] + port = 8080 + host = "localhost" + )"); + + // Access values + auto port = config["server"]["port"].value(); + auto host = config["server"]["host"].value(); + + // Verify + bool ok = (port.value_or(0) == 8080) && + (host.value_or("") == "localhost"); + + std::println("toml++ test: {}", ok ? "OK" : "FAILED"); + return ok ? 0 : 1; +} From 0f1601d5c2574d2cb8a213ae53e9a2e2693b4e72 Mon Sep 17 00:00:00 2001 From: Cloud_Yun <1770669041@qq.com> Date: Wed, 8 Jul 2026 00:40:59 +0900 Subject: [PATCH 2/2] fix: Add required version field to test mcpp.toml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mcpp 0.0.81 (CI version) requires package.version field. Successfully tested with mcpp 0.0.81: - Build: ✓ Downloaded compat.tomlplusplus v3.4.0 from GitHub - Compile: ✓ C++23 module + test binary (5.78s) - Run: ✓ Output 'toml++ test: OK' --- tests/examples/tomlplusplus/mcpp.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/examples/tomlplusplus/mcpp.toml b/tests/examples/tomlplusplus/mcpp.toml index 32f67f7..9165208 100644 --- a/tests/examples/tomlplusplus/mcpp.toml +++ b/tests/examples/tomlplusplus/mcpp.toml @@ -1,5 +1,6 @@ [package] name = "test-tomlplusplus" +version = "0.1.0" [targets.test-tomlplusplus] kind = "bin"