chore: clangd compile-db generator + upstream-sync directive#136
Conversation
|
Warning Review limit reached
More reviews will be available in 59 minutes and 59 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds a PowerShell tool to generate a clangd compile_commands.json (handling subst drives and MSVC env), documents IDE/setup and upstream sync rules, and ignores the generated database in git. Changesclangd IDE integration and project tooling
🎯 2 (Simple) | ⏱️ ~12 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR improves developer experience by (1) adding a PowerShell utility to generate a compile_commands.json for clangd when using Visual Studio CMake presets, and (2) documenting a repeatable upstream-sync workflow that preserves ancestry to reduce future merge conflicts.
Changes:
- Add
tools/gen-clangd-db.ps1to generate a clangd compile database via a throwaway Ninja configure using existing vcpkg artifacts. - Gitignore the generated root-level
compile_commands.json(machine-specific absolute paths). - Extend
.claude/CLAUDE.mdwith clangd setup instructions and explicit “merge-only” upstream sync guidance (no cherry-picks / no squash).
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| tools/gen-clangd-db.ps1 | New script to generate compile_commands.json by configuring with Ninja and reusing vcpkg from an existing build dir. |
| .gitignore | Ignore generated /compile_commands.json. |
| .claude/CLAUDE.md | Add clangd setup steps and codify upstream sync rules to keep merge history intact. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tools/gen-clangd-db.ps1`:
- Around line 101-104: The script hides CMake errors by piping the external
cmake invocation ("& cmake `@cmakeArgs` | Out-Null") to Out-Null; remove the "|
Out-Null" or, if you must suppress stdout, check $LASTEXITCODE immediately after
the "& cmake `@cmakeArgs`" call and throw a descriptive error that includes
CMake's exit code and any captured output; update the block around the cmake
invocation (where cmakeArgs is used) so failures are detected and reported
before the Test-Path check for $dbSrc (compile_commands.json).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 035ce9d5-992c-48bd-b898-58b6aa2f7427
📒 Files selected for processing (3)
.claude/CLAUDE.md.gitignoretools/gen-clangd-db.ps1
The shipped CMake presets use the Visual Studio generator, which does not emit compile_commands.json (Ninja/Makefile generators only). Without a compile database clangd parses every TU with the .clangd fallback flags and floods the editor with false "unknown include / undefined symbol" diagnostics. tools/gen-clangd-db.ps1 stands up a throwaway Ninja configure (no build, reusing the ALL preset's installed vcpkg packages) purely to emit an accurate DB, then drops it at the repo root where clangd auto-discovers it. It auto-detects the MSVC dev environment and, when the build runs under a subst drive (MAX_PATH workaround), rewrites the emitted paths back to the real checkout. Builds in-place when no subst drive is mapped. The generated compile_commands.json is machine-specific (absolute paths) and gitignored; re-run the script when the include graph or CMake options change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a "Syncing from upstream Community Shaders" section codifying the rule that kept biting: sync by merge, never cherry-pick (cherry-pick rewrites SHAs so upstream commits never become ancestors and the next merge re-conflicts forever), and land the sync PR as a merge commit, never squash (squash re-collapses the ancestry). Includes the merge-base ancestry check and keep-VR conflict guidance. Also document the clangd compile-db helper under a new IDE setup section. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
efd47d0 to
2e37f09
Compare
Address review feedback: - subst-drive detection: the regex assumed "Z:\ => path" but subst prints "Z:\: => path"; tolerate the trailing colon so the MAX_PATH workaround actually engages on setups that map a subst drive. - cmake configure: stop swallowing output via Out-Null and check $LASTEXITCODE. $ErrorActionPreference='Stop' does not trip on a native exe's exit code, so a configure failure previously surfaced only as the generic "did not produce compile_commands.json". - vswhere: throw an explicit error when no VS install is found instead of the misleading "vcvars64.bat not found under " (empty path). - CLAUDE.md: reword the ungrammatical "Resolve conflicts keep-VR" bullet.
What
Two developer-experience hardening changes that came out of the #135 upstream sync:
1. clangd compile database (
build:)The shipped CMake presets use the Visual Studio generator, which doesn't emit
compile_commands.json(only Ninja/Makefile generators do). Without a compile DB, clangd parses every TU with the hand-maintained.clangdfallback flags and floods the editor with false "unknown include / undefined symbol" diagnostics.tools/gen-clangd-db.ps1stands up a throwaway Ninja configure (no build, reuses theALLpreset's installed vcpkg packages) to emit an accurate per-file DB, then drops it at the repo root where clangd auto-discovers it.vswhere, reads the vcpkg toolchain/triplet from the existingALLcache, and builds in-place — or under asubstdrive when one is mapped (MAX_PATH workaround), rewriting the emitted paths back to the real checkout.compile_commands.jsonis machine-specific (absolute paths) and gitignored..clangdis left intact so contributors without a generated DB keep the fallback (notably the-std=c++23flag the DB lacks).2. Upstream-sync directive (
docs:)New "Syncing from upstream Community Shaders" section in CLAUDE.md codifying the rule that keeps biting:
git merge-base --is-ancestorverification and keep-VR conflict guidance.Release impact
None —
build:tooling +docs:only. No runtime/shader code touched.Test
tools/gen-clangd-db.ps1generated a 792-entry DB (787 undersrc/) with full per-file defines and include dirs; clangd resolves the include graph with it.Summary by CodeRabbit
Documentation
Chores