From 2b52d3ba58a95e57ee54aeb36bab71af45c26e02 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Wed, 8 Jul 2026 19:02:29 +0800 Subject: [PATCH 1/2] refactor(pkgs): nlohmann.json + compat.eigen generated_files -> Lua long brackets (P3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mechanical migration of the escaped single-line generated_files strings to [==[ ... ]==] long-bracket form (mcpp >= 0.0.85; the P1 floor gates this). Reviewability is the point: module wrapper sources become readable multi-line code instead of multi-KB one-liners. Verified: parity oracle — `mcpp xpkg parse --json` generated_contents byte-identical before/after for both; lua5.4 loadfile green (xim side still executes these); nlohmann.json and eigen member tests pass. --- pkgs/c/compat.eigen.lua | 4 +++- pkgs/n/nlohmann.json.lua | 47 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/pkgs/c/compat.eigen.lua b/pkgs/c/compat.eigen.lua index f48bbb1..2edfc13 100644 --- a/pkgs/c/compat.eigen.lua +++ b/pkgs/c/compat.eigen.lua @@ -108,7 +108,9 @@ package = { include_dirs = { "*" }, -- Header-only: a trivial anchor TU gives mcpp a buildable lib target. generated_files = { - ["mcpp_generated/eigen_anchor.c"] = "int mcpp_compat_eigen_headers_anchor(void) { return 0; }\n", + ["mcpp_generated/eigen_anchor.c"] = [==[ +int mcpp_compat_eigen_headers_anchor(void) { return 0; } +]==], }, sources = { "mcpp_generated/eigen_anchor.c" }, targets = { ["eigen"] = { kind = "lib" } }, diff --git a/pkgs/n/nlohmann.json.lua b/pkgs/n/nlohmann.json.lua index 8d3edd1..31c14c6 100644 --- a/pkgs/n/nlohmann.json.lua +++ b/pkgs/n/nlohmann.json.lua @@ -66,7 +66,52 @@ package = { -- Upstream's official module unit (develop @ src/modules/json.cppm), -- reproduced verbatim. Verdir-relative path, no glob. 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 \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 \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", + ["mcpp_generated/nlohmann.json.cppm"] = [==[ +module; + +// GCC workaround for C++ modules support. +// When using C++20 modules, some compilers (particularly GCC) may have issues +// with template instantiations in the module preamble. If you encounter +// "redefinition" errors when including nlohmann/json.hpp, try one of: +// 1. Include nlohmann/json.hpp in your module preamble BEFORE other #includes +// 2. Or use: import nlohmann.json; instead of #include +// 3. Or upgrade to a newer GCC version with better modules support. +// See: https://github.com/nlohmann/json/issues/5103 + +#include + +export module nlohmann.json; + +export +NLOHMANN_JSON_NAMESPACE_BEGIN + +using NLOHMANN_JSON_NAMESPACE::adl_serializer; +using NLOHMANN_JSON_NAMESPACE::basic_json; +using NLOHMANN_JSON_NAMESPACE::json; +using NLOHMANN_JSON_NAMESPACE::json_pointer; +using NLOHMANN_JSON_NAMESPACE::ordered_json; +using NLOHMANN_JSON_NAMESPACE::ordered_map; +using NLOHMANN_JSON_NAMESPACE::to_string; + +inline namespace literals +{ +inline namespace json_literals +{ + using NLOHMANN_JSON_NAMESPACE::literals::json_literals::operator""_json; + using NLOHMANN_JSON_NAMESPACE::literals::json_literals::operator""_json_pointer; +} // namespace json_literals +} // namespace literals + +// Note: the following nlohmann::detail symbols must be exported due to +// an MSVC bug failing to compile without these symbols visible (ticket #3970) +namespace detail +{ + using NLOHMANN_JSON_NAMESPACE::detail::json_sax_dom_callback_parser; + using NLOHMANN_JSON_NAMESPACE::detail::unknown_size; +} // namespace detail + +NLOHMANN_JSON_NAMESPACE_END +]==], }, sources = { "mcpp_generated/nlohmann.json.cppm" }, targets = { ["nlohmann_json"] = { kind = "lib" } }, From 46efd3de974ab9b54c8d6be8b9a4dca85852e894 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Wed, 8 Jul 2026 19:02:50 +0800 Subject: [PATCH 2/2] docs: live progress on the 0.0.85 adoption plan --- .../docs/2026-07-08-index-side-adoption-plan.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.agents/docs/2026-07-08-index-side-adoption-plan.md b/.agents/docs/2026-07-08-index-side-adoption-plan.md index a938ca6..243637e 100644 --- a/.agents/docs/2026-07-08-index-side-adoption-plan.md +++ b/.agents/docs/2026-07-08-index-side-adoption-plan.md @@ -10,6 +10,21 @@ the pin reaches 0.0.85, new-grammar descriptors cannot merge). --- +## PROGRESS (live) + +| Item | Status | Where | +|---|---|---| +| P0 merge PR #63 | pending maintainer decision (per instruction, PR untouched) | | +| P1 floor + strict lint | ✅ prepared — commit 2523dd9 on `feat/index-floor-0.0.85` (push/PR gated on the v0.0.85 release assets existing, else lint's mcpp download 404s) | index.toml, validate.yml (pin 0.0.85 + xpkg parse step), publish script cp, docs | +| P2 fmt → scan_overrides | ✅ validated locally only; descriptor kept out of tree per instruction | build+test green incl. negative ddi-audit case | +| P3 long-bracket migrations | ✅ prepared — commit 7f1e624 on `feat/long-bracket-migrations` (stacked on P1) | parity-oracle byte-identical; nlohmann.json + eigen member tests green | +| P4 docs | ✅ folded into P1 commit (schema rows + floor section) | docs/repository-and-schema.md | + +Note: the corpus dry-run of strict lint over all 42 descriptors surfaced and +fixed three mcpp-side gaps (single-quoted version keys — real bug hiding +tensorvia's versions; platform sub-table keys; Form A descriptors) — exactly +the bug class D2 exists to catch. + ## P0 — merge PR #63 as-is (pre-train) fmt 12.2.0 via `generated_files` works on today's 0.0.81 (verified locally