feat: add mcpp build support and switch Linux CI to mcpp#1
Merged
Sunrisepeak merged 2 commits intomainfrom May 8, 2026
Merged
Conversation
Add `mcpp.toml` at the project root so mcpp can build the library
natively, dropping the hand-written `mcpp = {}` workaround in
mcpp-index. The Linux CI job now bootstraps mcpp via xlings and runs
`mcpp build` + `mcpp test`; macOS and Windows continue to use xmake
since mcpp's support on those platforms is still WIP.
Tests no longer define their own `main()` — `mcpp test` always links
`gtest_main`, so `tests/xmake.lua` is updated to request gtest with
`main = true` to keep both build systems consistent.
README adds a mcpp section under "构建" and "集成到构建工具".
xmake's gtest package defaults to `gmock = true`, so with `main = true` it links `gmock_main.lib` (not `gtest_main.lib`). On Windows, MSVC's linker doesn't scan inside static libs for the entry point, so it reports `LNK1561: entry point must be defined`. - Disable gmock — we don't use it; this switches the linked main archive to `gtest_main.lib`. - Add `/WHOLEARCHIVE:gtest_main.lib` on Windows to force the entry point object into the link, side-stepping MSVC's lazy lib resolution.
2 tasks
Sunrisepeak
added a commit
to Sunrisepeak/mcpp-index
that referenced
this pull request
May 8, 2026
Upstream mcpplibs/cmdline tagged v0.0.2 and now ships an upstream mcpp.toml (mcpplibs/cmdline#1). Since the `mcpp` field in xpkg.lua is package-level (not per-version), we keep the existing Form B inline table to stay compatible with 0.0.1 — the src layout is identical across both versions, so a single descriptor covers both. When 0.0.1 is dropped, the inline `mcpp = { ... }` block can be replaced with `mcpp = "*/mcpp.toml"` to source build info directly from the upstream manifest. - linux/macosx/windows xpm: add 0.0.2 entry url: https://github.com/mcpplibs/cmdline/archive/refs/tags/v0.0.2.tar.gz sha256: 4f3e2b8dc4d9f11bdd9a784a9914e889234ac305e1020282ffa03f506b75d52a - Refresh the comment header explaining why Form B stays.
Sunrisepeak
added a commit
to mcpplibs/mcpp-index
that referenced
this pull request
May 8, 2026
Upstream mcpplibs/cmdline tagged v0.0.2 and now ships an upstream mcpp.toml (mcpplibs/cmdline#1). Since the `mcpp` field in xpkg.lua is package-level (not per-version), we keep the existing Form B inline table to stay compatible with 0.0.1 — the src layout is identical across both versions, so a single descriptor covers both. When 0.0.1 is dropped, the inline `mcpp = { ... }` block can be replaced with `mcpp = "*/mcpp.toml"` to source build info directly from the upstream manifest. - linux/macosx/windows xpm: add 0.0.2 entry url: https://github.com/mcpplibs/cmdline/archive/refs/tags/v0.0.2.tar.gz sha256: 4f3e2b8dc4d9f11bdd9a784a9914e889234ac305e1020282ffa03f506b75d52a - Refresh the comment header explaining why Form B stays.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mcpp.toml,让上游仓库原生支持 mcpp 构建(mcpp build/mcpp test),可以替换mcpp-index里那段手写的mcpp = {}workaroundtests/cmdline_test.cpp移除自定义main(),由 gtest_main 提供;对应tests/xmake.lua用gtest { configs = { main = true } },两套构建系统行为一致Changes
mcpp.toml(new)[targets.cmdline] kind = "lib"+gtestdev-dep.github/workflows/ci.ymlmcpp build+mcpp test,并加 mcpp sandbox / target 缓存tests/cmdline_test.cppint main()(mcpp test 总是链接 gtest_main)tests/xmake.luaadd_requires("gtest", { configs = { main = true } })README.md.gitignoretarget(mcpp 构建目录)Local verification
mcpp build✅ —Compiling mcpplibs.cmdline v0.0.2 ... Finished release [optimized] in 1.49smcpp test✅ — 37 tests / 7 suites all greenxmake b cmdline_test✅ —build ok, spent 8.997s(清缓存 +xrepo install -f main=true gtest之后)mcpp-index follow-up
mcpp emit xpkg可以从这份mcpp.toml自动生成mcpplibs.cmdline.lua。和当前mcpp-index/pkgs/m/mcpplibs.cmdline.lua的主要差别:mcpp = {}段从 workaround(自带 sources/targets)变成 stub:{ schema = "0.1", language, import_std, modules, deps, manifest = "mcpp.toml" }—— 改成指向上游 manifest 而不是在索引里重复构建信息0.0.1升到0.0.2<TBD>,需要手动补成https://github.com/mcpplibs/cmdline/archive/refs/tags/v0.0.2.tar.gz+ 对应 sha256会在合并后另开一个 PR 同步 mcpp-index。
Test plan
mcpp build+mcpp test通过(已验证)xmake b cmdline+xmake b cmdline_test通过(已验证)