feat: feature-gated dep sources + mcpp add --dev — fix #168 gtest_main (v0.0.65)#169
Merged
Merged
Conversation
…st_main) #168: gtest as a regular dependency injected gtest_main.o (its own main) into a `mcpp build` app, colliding with the app's main (LNK2005 / duplicate symbol). Generic fix — feature-gated sources: - A dependency descriptor may declare `[mcpp].features.<name>.sources`; a source listed there is EXCLUDED from the default build and only compiled/linked when that feature is active for the dep (`dep = { version, features=["name"] }`). - gtest descriptor (mcpp-index) puts gtest_main.cc behind the `main` feature → default `gtest = "1.15.2"` links framework only (no main collision); opt in with `features=["main"]`. Reuses the existing feature activation; new effect is "feature → sources" (manifest.cppm synthesize + prepare.cppm). - Gating applies only in build mode (!includeDevDeps); `mcpp test` keeps the dev-dependency main-detection track (0.0.64) unchanged — the two tracks stay decoupled. Descriptor keeps gtest_main.cc in base `sources` too, so OLD mcpp (ignores `features`) is unaffected (verified). mcpp add --dev <pkg> → writes [dev-dependencies] (was missing). - unit: SynthesizeFromXpkgLua.FeatureGatedSources - e2e: 79_gtest_regular_dep_feature_main.sh (#168 sentinel + opt-in + add --dev) - release.yml: default xlings 0.4.58 -> 0.4.60 (cache key bumped) - bump 0.0.64 -> 0.0.65 - design: .agents/docs/2026-06-25-gtest-main-feature-and-add-dev-design.md
…printf macOS BSD find lacks -printf → nj came back empty → false 'gtest-all not linked'. Functionality was fine (78 passed, build succeeded). Use find | xargs ls -t.
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.
Fixes #168 —
mcpp add gtest+mcpp build→gtest_main.o : error LNK2005: main already defined.根因
gtest 作为常规依赖时,其
gtest_main.cc(自带 main)被内联进应用,与应用 main 冲突。方案:通用「feature 门控源」(非 gtest 特例)
[mcpp].features.<名>.sources;被某 feature 列出的源默认不编译/链接,仅dep = { version, features=["名"] }请求时纳入。gtest_main.cc归入mainfeature → 默认gtest = "1.15.2"只链框架(不撞 main);features=["main"]显式开启。manifest.cppmsynthesize +prepare.cppm)。!includeDevDeps);mcpp test的 dev 依赖 main 检测(0.0.64)不变 → 两轨解耦。sources→ 旧 mcpp(不认 features)行为不变(实测 0.0.64mcpp test仍正常)。新增
mcpp add --dev <pkg>→ 写[dev-dependencies](原缺失)。测试 / 其它
SynthesizeFromXpkgLua.FeatureGatedSources;e2e79_*(在mcpp.toml的[dependences]添加gtest依赖时,gtest_main与程序入口main函数冲突问题 #168 哨兵 + opt-in + add --dev)。0.4.58 → 0.4.60(缓存键同步)。0.0.64 → 0.0.65。.agents/docs/2026-06-25-gtest-main-feature-and-add-dev-design.md。本机验证
24+ 单测 + e2e 78(dev 轨回归)+ e2e 79(src 轨)全绿;#168 场景 build 不再链 gtest_main。
🤖 Generated with Claude Code