Skip to content

feat: add mcpp build support and switch Linux CI to mcpp#1

Merged
Sunrisepeak merged 2 commits intomainfrom
feat/mcpp-build-support
May 8, 2026
Merged

feat: add mcpp build support and switch Linux CI to mcpp#1
Sunrisepeak merged 2 commits intomainfrom
feat/mcpp-build-support

Conversation

@Sunrisepeak
Copy link
Copy Markdown
Member

Summary

  • 新增 mcpp.toml,让上游仓库原生支持 mcpp 构建(mcpp build / mcpp test),可以替换 mcpp-index 里那段手写的 mcpp = {} workaround
  • Linux CI 切到 mcpp(通过 xlings 引导安装),macOS / Windows 继续走 xmake(mcpp 在这两平台还是 WIP)
  • 调整测试入口:tests/cmdline_test.cpp 移除自定义 main(),由 gtest_main 提供;对应 tests/xmake.luagtest { configs = { main = true } },两套构建系统行为一致

Changes

File Change
mcpp.toml (new) 包元数据 + [targets.cmdline] kind = "lib" + gtest dev-dep
.github/workflows/ci.yml Linux job 改用 mcpp build + mcpp test,并加 mcpp sandbox / target 缓存
tests/cmdline_test.cpp 删掉手写 int main()(mcpp test 总是链接 gtest_main)
tests/xmake.lua add_requires("gtest", { configs = { main = true } })
README.md 「构建」「集成」两节加上 mcpp 用法
.gitignore 加上 target(mcpp 构建目录)

Local verification

  • mcpp build ✅ — Compiling mcpplibs.cmdline v0.0.2 ... Finished release [optimized] in 1.49s
  • mcpp test ✅ — 37 tests / 7 suites all green
  • xmake 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
  • URL/sha256 是占位符 <TBD>,需要手动补成 https://github.com/mcpplibs/cmdline/archive/refs/tags/v0.0.2.tar.gz + 对应 sha256

会在合并后另开一个 PR 同步 mcpp-index。

Test plan

  • CI Linux job (mcpp build + mcpp test) 通过
  • CI macOS job (xmake) 通过
  • CI Windows job (xmake build + run + smoke) 通过
  • 本地 mcpp build + mcpp test 通过(已验证)
  • 本地 xmake b cmdline + xmake b cmdline_test 通过(已验证)

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.
@Sunrisepeak Sunrisepeak merged commit c49b046 into main May 8, 2026
3 checks passed
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant