Skip to content

Commit 5af9906

Browse files
committed
feat: M6.x glob-aware schema (mcpp field) — migrate cmdline + templates + gtest
Aligns with mcpp's M6.x descriptor schema where the `mcpp` field is optional and accepts three shapes: - Absent: mcpp default-looks-up <verdir>/mcpp.toml then <verdir>/*/mcpp.toml. - String: glob-resolvable path to the project's mcpp.toml. - Table: inline Form B descriptor (paths are globs relative to verdir). All paths inside the descriptor are now interpreted as globs (* matches single segment, ** any number) to robustly handle the GitHub tarball <repo>-<tag>/ wrap layer without depending on mcpp's old "single-subdir auto-strip" heuristic (which broke when xlings dropped unrelated extracted artifacts in the same verdir). Changes: - mcpplibs.templates.lua: Form A; mcpp field removed (default lookup handles <verdir>/<repo>-<tag>/mcpp.toml). - mcpplibs.cmdline.lua: Form B; sources `src/**/*.cppm` → `*/src/**/*.cppm`. - gtest.lua: NEW. Form B descriptor for gtest 1.15.2; ships the amalgamated gtest-all.cc + gtest_main.cc as a static lib via: mcpp = { sources = { "*/googletest/src/gtest-all.cc", "*/googletest/src/gtest_main.cc" }, include_dirs = { "*/googletest/include", "*/googletest" }, targets = { ["gtest"] = { kind = "lib" } }, } This unblocks `[dev-dependencies] gtest = "1.15.2"` in user projects.
1 parent 9fccdba commit 5af9906

3 files changed

Lines changed: 59 additions & 5 deletions

File tree

pkgs/g/gtest.lua

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
-- M6.x glob-aware Form B descriptor for gtest.
2+
-- All paths inside `mcpp = {}` are GLOBS relative to the verdir
3+
-- (~/.mcpp/registry/data/xpkgs/<idx>-x-gtest/<ver>/). `*` matches any
4+
-- single path segment (so it absorbs the GitHub `<repo>-<tag>/` wrap).
5+
6+
package = {
7+
spec = "1",
8+
name = "gtest",
9+
description = "Google's C++ test framework",
10+
licenses = {"BSD-3-Clause"},
11+
repo = "https://github.com/google/googletest",
12+
type = "package",
13+
14+
xpm = {
15+
linux = {
16+
["1.15.2"] = {
17+
url = "https://github.com/google/googletest/archive/refs/tags/v1.15.2.tar.gz",
18+
sha256 = "7b42b4d6ed48810c5362c265a17faebe90dc2373c885e5216439d37927f02926",
19+
},
20+
},
21+
macosx = {
22+
["1.15.2"] = {
23+
url = "https://github.com/google/googletest/archive/refs/tags/v1.15.2.tar.gz",
24+
sha256 = "7b42b4d6ed48810c5362c265a17faebe90dc2373c885e5216439d37927f02926",
25+
},
26+
},
27+
windows = {
28+
["1.15.2"] = {
29+
url = "https://github.com/google/googletest/archive/refs/tags/v1.15.2.tar.gz",
30+
sha256 = "7b42b4d6ed48810c5362c265a17faebe90dc2373c885e5216439d37927f02926",
31+
},
32+
},
33+
},
34+
35+
mcpp = {
36+
language = "c++23",
37+
sources = {
38+
"*/googletest/src/gtest-all.cc",
39+
"*/googletest/src/gtest_main.cc",
40+
},
41+
include_dirs = {
42+
"*/googletest/include",
43+
"*/googletest",
44+
},
45+
targets = { ["gtest"] = { kind = "lib" } },
46+
deps = { },
47+
},
48+
}

pkgs/m/mcpplibs.cmdline.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ package = {
3232
},
3333

3434
-- Workaround: upstream repo has no mcpp.toml. Drop this segment when it does.
35+
-- M6.x: Form B paths are globs relative to the verdir (the untouched
36+
-- xlings extract dir). The leading `*/` absorbs the GitHub tarball's
37+
-- `cmdline-<tag>/` wrap layer.
3538
mcpp = {
3639
language = "c++23",
3740
import_std = true,
3841
modules = { "mcpplibs.cmdline" },
39-
sources = { "src/**/*.cppm" },
42+
sources = { "*/src/**/*.cppm" },
4043
targets = { ["cmdline"] = { kind = "lib" } },
4144
deps = { },
4245
},

pkgs/m/mcpplibs.templates.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
-- AUTO-GENERATED by `mcpp emit xpkg`-equivalent (manual seed).
2-
-- Source: https://github.com/mcpp-community/templates @ v0.0.1
3-
-- Form A descriptor: the source repo has its own mcpp.toml, so no
4-
-- `mcpp = {}` workaround segment is needed.
1+
-- Form A descriptor: the source repo has its own mcpp.toml. We omit the
2+
-- `mcpp` field entirely — mcpp will default-look-up <verdir>/mcpp.toml
3+
-- and <verdir>/*/mcpp.toml, which catches the GitHub tarball's
4+
-- `<repo>-<tag>/mcpp.toml` layout. Add `mcpp = "<glob>"` only if the
5+
-- default lookup is ambiguous or wrong for your tarball.
56
package = {
67
spec = "1",
78
name = "mcpplibs.templates",
@@ -30,4 +31,6 @@ package = {
3031
},
3132
},
3233
},
34+
35+
-- (no `mcpp` field — default lookup will find <verdir>/*/mcpp.toml)
3336
}

0 commit comments

Comments
 (0)