Skip to content

feat: add marzer.tomlplusplus 3.4.0 (official source + CN mirror + generated_files cppm)#64

Merged
Sunrisepeak merged 4 commits into
mcpplibs:mainfrom
yspbwx2010:main
Jul 15, 2026
Merged

feat: add marzer.tomlplusplus 3.4.0 (official source + CN mirror + generated_files cppm)#64
Sunrisepeak merged 4 commits into
mcpplibs:mainfrom
yspbwx2010:main

Conversation

@yspbwx2010

@yspbwx2010 yspbwx2010 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

添加 toml++ —— C++17 的 TOML 解析/序列化库,以 C++23 模块形式提供,可直接 import tomlplusplus;

信息

  • 包名marzer.tomlpluspluspkgs/m/marzer.tomlplusplus.lua
  • 版本:3.4.0
  • 许可证:MIT
  • 来源:官方上游 marzer/tomlplusplus @ v3.4.0 release tarball

按 review 意见重做(#64 comment)

参考 nlohmann.json.lua 的做法,本次改动:

  1. 去掉 fork:不再依赖 yspbwx2010/tomlplusplus,直接用上游官方 v3.4.0 release tarball。信任链上没有 fork。
  2. 文件命名compat.tomlplusplusmarzer.tomlplusplus,放到 pkgs/m/ 下,与 nlohmann.json命名空间.库 约定一致。
  3. generated_files 机制:官方模块单元 src/modules/tomlplusplus.cppm 只在 master 分支、不在任何 release tag 里,改用 generated_files + [==[ ]==] 多行字符串内嵌,因此无需 fork 即可拿到 module unit。
  4. 真实 CN 镜像:新建 gitcode mcpp-res/tomlplusplus @ 3.4.0,替换原来 CN = GLOBAL 的占位。资产与 GLOBAL 逐字节相同(sha256 一致)。
  5. 测试改为 workspace member:原来的 bin 例子换成 tests/examples/marzer.tomlplusplus/,已注册进 [workspace].members,由 mcpp test --workspace 覆盖。

⚠️ 与上游 cppm 的唯一一处差异

内嵌的 cppm 与上游 master 逐行一致,只删了一行

using TOML_NAMESPACE::get_line;

get_line 是 v3.4.0 之后才加进 impl/source_region.hpp 的,pinned 的 v3.4.0 头文件里不存在,re-export 会直接编译失败:

error: 'get_line' has not been declared in 'toml'

已在 descriptor 注释里写明。等上游发 >3.4.0 且带上 src/modules/tomlplusplus.cppm 时,可切回 sources = { "*/src/modules/tomlplusplus.cppm" }、删掉 generated_filesget_line 会随之回归。

用法

mcpp add marzer.tomlplusplus@3.4.0
import tomlplusplus;
auto config = toml::parse("port = 8080");

本地验证

检查 结果
mcpp test(GLOBAL 源) parse ... ok — 1 passed
mcpp testMCPP_INDEX_MIRROR=CN,清缓存后真实重新下载) parse ... ok — 1 passed
CN 镜像 vs GLOBAL 字节比对 ✅ byte-identical,sha256 8517f659…d25155
全量 lint(46 个 descriptor,含 check_mirror_urls.lua ✅ all valid
mcpp xpkg parse(CI pin 0.0.91 + 本地 0.0.93) ✅ OK
内嵌 cppm vs 上游 master(减 get_line) ✅ 逐字节一致

注:本分支已 rebase 到最新 main(原分支落后 10 个提交)。

Comment thread pkgs/c/compat.tomlplusplus.lua Outdated
Comment thread pkgs/c/compat.tomlplusplus.lua Outdated
package = {
spec = "1",
namespace = "compat",
name = "compat.tomlplusplus",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    namespace   = "marzer",
    name             = "tomlplusplus",

@Sunrisepeak

Sunrisepeak commented Jul 7, 2026

Copy link
Copy Markdown
Member

cppm 只在master分支可以参考 这个 json库的做法

generated_files = {
["mcpp_generated/nlohmann.json.cppm"] = "module;\n\n// GCC workaround for C++ modules support.\n// When using C++20 modules, some compilers (particularly GCC) may have issues\n// with template instantiations in the module preamble. If you encounter\n// \"redefinition\" errors when including nlohmann/json.hpp, try one of:\n// 1. Include nlohmann/json.hpp in your module preamble BEFORE other #includes\n// 2. Or use: import nlohmann.json; instead of #include <nlohmann/json.hpp>\n// 3. Or upgrade to a newer GCC version with better modules support.\n// See: https://github.com/nlohmann/json/issues/5103\n\n#include <nlohmann/json.hpp>\n\nexport module nlohmann.json;\n\nexport\nNLOHMANN_JSON_NAMESPACE_BEGIN\n\nusing NLOHMANN_JSON_NAMESPACE::adl_serializer;\nusing NLOHMANN_JSON_NAMESPACE::basic_json;\nusing NLOHMANN_JSON_NAMESPACE::json;\nusing NLOHMANN_JSON_NAMESPACE::json_pointer;\nusing NLOHMANN_JSON_NAMESPACE::ordered_json;\nusing NLOHMANN_JSON_NAMESPACE::ordered_map;\nusing NLOHMANN_JSON_NAMESPACE::to_string;\n\ninline namespace literals\n{\ninline namespace json_literals\n{\n using NLOHMANN_JSON_NAMESPACE::literals::json_literals::operator\"\"_json;\n using NLOHMANN_JSON_NAMESPACE::literals::json_literals::operator\"\"_json_pointer;\n} // namespace json_literals\n} // namespace literals\n\n// Note: the following nlohmann::detail symbols must be exported due to\n// an MSVC bug failing to compile without these symbols visible (ticket #3970)\nnamespace detail\n{\n using NLOHMANN_JSON_NAMESPACE::detail::json_sax_dom_callback_parser;\n using NLOHMANN_JSON_NAMESPACE::detail::unknown_size;\n} // namespace detail\n\nNLOHMANN_JSON_NAMESPACE_END\n",
},

可以使用 [[ ]] 多行字符串 直接包含

        generated_files = {
            ["mcpp_generated/nlohmann.json.cppm"] = [[
// L1
// L2
// ....
            ]],
        },

yspbwx2010 and others added 3 commits July 16, 2026 01:39
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
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'
…ted_files

Reworks the package per review feedback (mcpplibs#64 review comment), following the
nlohmann.json precedent.

- Rename compat.tomlplusplus -> marzer.tomlplusplus (pkgs/m/), matching the
  `<namespace>.<lib>` convention used by nlohmann.json.
- Drop the fork from the trust path: sources now come from upstream's own
  v3.4.0 release tarball (marzer/tomlplusplus), not yspbwx2010/tomlplusplus.
- Add a real CN mirror: gitcode mcpp-res/tomlplusplus @ 3.4.0, byte-identical
  to the GLOBAL asset (same sha256), replacing the CN=GLOBAL placeholder.
- Carry upstream's master-only src/modules/tomlplusplus.cppm via the
  `generated_files` mechanism as a [==[ ]==] multi-line string, so no fork is
  needed to obtain the module unit.
- Replace the ad-hoc bin example with a `mcpp test --workspace` member under
  tests/examples/marzer.tomlplusplus/, registered in [workspace].members.

The embedded cppm is byte-identical to upstream master except for one dropped
line: `using TOML_NAMESPACE::get_line;`. get_line was added to
impl/source_region.hpp after v3.4.0 and does not exist in the pinned headers
('get_line' has not been declared in 'toml'), so re-exporting it cannot
compile. Documented in the descriptor.
@Sunrisepeak Sunrisepeak changed the title feat: add compat.tomlplusplus 3.4.0 (C++ toml parse library) feat: add marzer.tomlplusplus 3.4.0 (official source + CN mirror + generated_files cppm) Jul 15, 2026
@Sunrisepeak

Copy link
Copy Markdown
Member

已按建议重做 👍 参考 nlohmann.json.lua

  • 文件命名pkgs/c/compat.tomlplusplus.luapkgs/m/marzer.tomlplusplus.lua(命名空间.库)
  • generated_files 机制:master-only 的 src/modules/tomlplusplus.cppm[==[ ]==] 多行字符串内嵌(跟 nlohmann 一样用 [==[,因为内容里有 [[/]] 风险时更稳妥)
  • 顺带去掉了 fork:既然 cppm 已经内嵌,就不需要 fork 了,源码直接指向上游官方 v3.4.0 release tarball
  • 补了 CN 镜像:gitcode mcpp-res/tomlplusplus @ 3.4.0,与 GLOBAL 逐字节相同

一处需要注意的坑:上游 master 的 cppm 不能原样内嵌。里面的 using TOML_NAMESPACE::get_line; 是 v3.4.0 之后才加到 impl/source_region.hpp 的,对着 v3.4.0 头文件会编译失败:

error: 'get_line' has not been declared in 'toml'

所以内嵌版本删了这一行(其余逐字节一致),并在 descriptor 注释里写明了原因和后续恢复条件。

本地验证:GLOBAL / CN 两条路径 mcpp test 均通过,46 个 descriptor 全量 lint 通过(含 0.0.91 pin 的 mcpp xpkg parse)。详见 PR 描述。

分支已 rebase 到最新 main

…age skill

Steps 8/9 of the repo's add-mcpp-index-package SOP: register the package in
the README's 'C++23 module wrapper' row alongside nlohmann.json, and record
the shape decision, the CN mirror, the feature evaluation (none — header-only,
options are compile-time defines that the features table cannot carry), and
the get_line deviation with its negative-verification evidence.
@Sunrisepeak Sunrisepeak merged commit 2be5893 into mcpplibs:main Jul 15, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants