From 3fea2871b3d3ab91f0786345afdfe788bf7d8ee6 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sun, 9 Aug 2026 22:31:22 +0800 Subject: [PATCH] fix(capi.lua): make Lua dependency identity exact Keep the immutable 0.0.3 release bytes, but bridge its legacy bare lua dependency with an inline Form B descriptor that names compat.lua exactly. Add an executable local-index consumer regression.\n\nRefs #196 --- mcpp.toml | 1 + pkgs/m/mcpplibs.capi.lua.lua | 22 +++++++++++++++++++--- tests/examples/capi-lua/mcpp.toml | 9 +++++++++ tests/examples/capi-lua/tests/main.cpp | 13 +++++++++++++ 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 tests/examples/capi-lua/mcpp.toml create mode 100644 tests/examples/capi-lua/tests/main.cpp diff --git a/mcpp.toml b/mcpp.toml index 945fffcd..99511826 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -18,6 +18,7 @@ members = [ "tests/examples/catch2-main", "tests/examples/catch2-v2", "tests/examples/catch2-v2-main", + "tests/examples/capi-lua", "tests/examples/cjson", "tests/examples/cmdline", "tests/examples/cli11", diff --git a/pkgs/m/mcpplibs.capi.lua.lua b/pkgs/m/mcpplibs.capi.lua.lua index 7ed9b8ad..7963f41d 100644 --- a/pkgs/m/mcpplibs.capi.lua.lua +++ b/pkgs/m/mcpplibs.capi.lua.lua @@ -1,6 +1,8 @@ --- Form A descriptor: the upstream repo ships its own mcpp.toml from --- 0.0.3 onwards, so we omit the `mcpp` field — mcpp default-look-up --- finds /lua-/mcpp.toml inside the GitHub tarball wrap. +-- Form B descriptor for the immutable 0.0.3 payload. Its upstream +-- mcpp.toml predates exact package selectors and declares bare `lua`, which +-- now means `(mcpplibs, lua)` and cannot identify the real C library at +-- `(compat, lua)`. Keep the release bytes unchanged and carry the canonical +-- dependency here until a newer upstream release can return to Form A. package = { spec = "1", namespace = "mcpplibs.capi", @@ -39,4 +41,18 @@ package = { }, }, }, + + mcpp = { + schema = "0.1", + language = "c++23", + import_std = false, + modules = { "mcpplibs.capi.lua" }, + include_dirs = { "*/src/capi" }, + sources = { + "*/src/capi/lua.cppm", + "*/src/capi/lua.cpp", + }, + targets = { ["capi-lua"] = { kind = "lib" } }, + deps = { ["compat.lua"] = "5.4.7" }, + }, } diff --git a/tests/examples/capi-lua/mcpp.toml b/tests/examples/capi-lua/mcpp.toml new file mode 100644 index 00000000..b05848fc --- /dev/null +++ b/tests/examples/capi-lua/mcpp.toml @@ -0,0 +1,9 @@ +[indices] +"mcpplibs.capi" = { path = "../../.." } + +[package] +name = "capi-lua-tests" +version = "0.1.0" + +[dependencies.mcpplibs] +capi.lua = "0.0.3" diff --git a/tests/examples/capi-lua/tests/main.cpp b/tests/examples/capi-lua/tests/main.cpp new file mode 100644 index 00000000..5d922402 --- /dev/null +++ b/tests/examples/capi-lua/tests/main.cpp @@ -0,0 +1,13 @@ +import mcpplibs.capi.lua; + +namespace lua = mcpplibs::capi::lua; + +int main() { + auto* state = lua::L_newstate(); + if (state == nullptr) return 1; + + const int status = lua::L_dostring(state, "return 6 * 7"); + const auto answer = lua::tointeger(state, -1); + lua::close(state); + return status == lua::OK && answer == 42 ? 0 : 1; +}