Skip to content

Commit b974cbb

Browse files
authored
Merge pull request #197 from mcpplibs/fix/capi-lua-exact-dep
fix(capi.lua): make Lua dependency identity exact
2 parents 401461c + 3fea287 commit b974cbb

4 files changed

Lines changed: 42 additions & 3 deletions

File tree

mcpp.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ members = [
1818
"tests/examples/catch2-main",
1919
"tests/examples/catch2-v2",
2020
"tests/examples/catch2-v2-main",
21+
"tests/examples/capi-lua",
2122
"tests/examples/cjson",
2223
"tests/examples/cmdline",
2324
"tests/examples/cli11",

pkgs/m/mcpplibs.capi.lua.lua

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
-- Form A descriptor: the upstream repo ships its own mcpp.toml from
2-
-- 0.0.3 onwards, so we omit the `mcpp` field — mcpp default-look-up
3-
-- finds <verdir>/lua-<tag>/mcpp.toml inside the GitHub tarball wrap.
1+
-- Form B descriptor for the immutable 0.0.3 payload. Its upstream
2+
-- mcpp.toml predates exact package selectors and declares bare `lua`, which
3+
-- now means `(mcpplibs, lua)` and cannot identify the real C library at
4+
-- `(compat, lua)`. Keep the release bytes unchanged and carry the canonical
5+
-- dependency here until a newer upstream release can return to Form A.
46
package = {
57
spec = "1",
68
namespace = "mcpplibs.capi",
@@ -39,4 +41,18 @@ package = {
3941
},
4042
},
4143
},
44+
45+
mcpp = {
46+
schema = "0.1",
47+
language = "c++23",
48+
import_std = false,
49+
modules = { "mcpplibs.capi.lua" },
50+
include_dirs = { "*/src/capi" },
51+
sources = {
52+
"*/src/capi/lua.cppm",
53+
"*/src/capi/lua.cpp",
54+
},
55+
targets = { ["capi-lua"] = { kind = "lib" } },
56+
deps = { ["compat.lua"] = "5.4.7" },
57+
},
4258
}

tests/examples/capi-lua/mcpp.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[indices]
2+
"mcpplibs.capi" = { path = "../../.." }
3+
4+
[package]
5+
name = "capi-lua-tests"
6+
version = "0.1.0"
7+
8+
[dependencies.mcpplibs]
9+
capi.lua = "0.0.3"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import mcpplibs.capi.lua;
2+
3+
namespace lua = mcpplibs::capi::lua;
4+
5+
int main() {
6+
auto* state = lua::L_newstate();
7+
if (state == nullptr) return 1;
8+
9+
const int status = lua::L_dostring(state, "return 6 * 7");
10+
const auto answer = lua::tointeger(state, -1);
11+
lua::close(state);
12+
return status == lua::OK && answer == 42 ? 0 : 1;
13+
}

0 commit comments

Comments
 (0)