{"id":28548197,"url":"https://github.com/freddiehaddad/ms2cc","last_synced_at":"2026-05-07T06:33:31.025Z","repository":{"id":296556108,"uuid":"989424363","full_name":"freddiehaddad/ms2cc","owner":"freddiehaddad","description":"Tool to generate a compile_commands.json database from an msbuild.log file.","archived":false,"fork":false,"pushed_at":"2025-06-05T00:15:41.000Z","size":66,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-28T14:51:35.462Z","etag":null,"topics":["c","clangd","compile-commands-json","cpp","language-server-protocol","lsp","lsp-client","lsp-server","msbuild","vscode","windows"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/freddiehaddad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-24T04:26:28.000Z","updated_at":"2025-06-05T00:13:01.000Z","dependencies_parsed_at":"2025-06-01T02:35:03.047Z","dependency_job_id":"c4e3e043-a70b-42e0-b8c1-f78616c4c7c1","html_url":"https://github.com/freddiehaddad/ms2cc","commit_stats":null,"previous_names":["freddiehaddad/ms2cc"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/freddiehaddad/ms2cc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freddiehaddad%2Fms2cc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freddiehaddad%2Fms2cc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freddiehaddad%2Fms2cc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freddiehaddad%2Fms2cc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/freddiehaddad","download_url":"https://codeload.github.com/freddiehaddad/ms2cc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freddiehaddad%2Fms2cc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263165704,"owners_count":23423996,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","clangd","compile-commands-json","cpp","language-server-protocol","lsp","lsp-client","lsp-server","msbuild","vscode","windows"],"created_at":"2025-06-10T01:09:07.800Z","updated_at":"2026-05-07T06:33:31.019Z","avatar_url":"https://github.com/freddiehaddad.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ms2cc\n\n\u003e Convert MSBuild logs to compile_commands.json for C/C++ language servers\n\n## Table of Contents\n\n- [What is ms2cc?](#what-is-ms2cc)\n- [Why is ms2cc useful?](#why-is-ms2cc-useful)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [Usage](#usage)\n- [Editor Configuration](#editor-configuration)\n  - [Visual Studio Code](#visual-studio-code)\n  - [Other Editors](#other-editors)\n- [Troubleshooting](#troubleshooting)\n- [LSP and AI: Better Together](#lsp-and-ai-better-together)\n- [References](#references)\n- [License](#license)\n\n## What is ms2cc?\n\nms2cc converts MSBuild build logs into [`compile_commands.json`][compile-commands] format. This compilation database is used by [language servers][lsp], and various IDEs for code intelligence features (IntelliSense, navigation, refactoring, linting).\n\n[MSBuild][msbuild-cli] does not generate [`compile_commands.json`][compile-commands]. ms2cc extracts compiler invocations from MSBuild's detailed logs and converts them to the standard format.\n\n## Why is ms2cc Useful?\n\nC and C++ [language servers][lsp] (like [clangd][clangd], ccls, Microsoft C/C++, etc.) need a [`compile_commands.json`][compile-commands] file because they cannot correctly understand or parse your code without the exact compiler flags that are used when building the project.\n\nUnlike languages such as Rust, Go, Python, or Java, C and C++ code is not self-describing. A C/C++ source file:\n\n- depends on preprocessor macros\n- depends on include paths (-I)\n- depends on system headers\n- can change behavior based on platform and compiler\n- may use language extensions (-std=gnu++20, -fms-extensions)\n- may be compiled differently per file\n\nThis means the same `.cpp` file can produce totally different ASTs depending on its flags.\n\nA language server must replicate the exact compiler invocation, or it literally cannot parse the file in the correct configuration.\n\n## Requirements\n\n- **Platform:** Windows (Windows 10/11, Windows Server)\n- **Build System:** MSBuild (Visual Studio 2019, 2022, or Build Tools)\n- **For Building from Source (optional):** Rust toolchain\n\n## Installation\n\n### Option A: Download Pre-built Binary\n\n1. **Download:**\n   - Visit the [releases page](https://github.com/freddiehaddad/ms2cc/releases)\n   - Download the `ms2cc-x.x.x.zip` file\n\n2. **Extract:**\n   - Unzip the file to extract `ms2cc.exe`\n\n3. **Usage:**\n   - Run it from anywhere by adding the directory to your PATH, or\n   - Copy `ms2cc.exe` to your project directory\n\n### Option B: Build from Source\n\n1. **Install [Rust][rust]** (if not already installed):\n\n   ```text\n   # Visit https://rustup.rs and follow the instructions\n   ```\n\n2. **Clone the repository:**\n\n   ```powershell\n   git clone https://github.com/freddiehaddad/ms2cc.git\n   cd ms2cc\n   ```\n\n3. **Build the release version:**\n\n   ```powershell\n   cargo build --release\n   ```\n\n4. **Find the executable:**\n\n   ```text\n   The built executable will be at: target\\release\\ms2cc.exe\n   ```\n\n## Quick Start\n\n### Build with Detailed Logging\n\n```powershell\ncd C:\\path\\to\\your\\project\nmsbuild YourSolution.sln /v:detailed \u003e msbuild.log\n```\n\nThe `/v:detailed` flag is required. Without it, [MSBuild][msbuild-cli] doesn't log enough information.\n\n\u003e **Visual Studio IDE:** In Visual Studio 2019/2022 use **Build \u003e Project Only \u003e Build Only ProjectName**. When the Output window finishes scrolling, right-click inside it, choose [**Save Build Log**][vs-build-logging], and save it as `msbuild.log` with **MSBuild Project Build Log (\\*.log)**.\n\n### Generate compile_commands.json\n\n```powershell\nms2cc -i msbuild.log -o compile_commands.json\n```\n\n### Configure Your Editor\n\nSee the [Editor Configuration](#editor-configuration) section below for your specific editor.\n\n### Verify the Output\n\n```powershell\nTest-Path compile_commands.json\nGet-Content compile_commands.json | Select-Object -First 8\n```\n\nThe file should exist and contain one JSON object per compiler invocation, for example:\n\n```json\n[\n  {\n    \"file\": \"src\\\\main.cpp\",\n    \"directory\": \"C:/path/to/your/project\",\n    \"arguments\": [\"cl.exe\", \"/Iinclude\", \"src/main.cpp\"]\n  }\n]\n```\n\nIf the file is missing or empty, revisit the logging step.\n\n## Usage\n\n### Command-Line Options\n\nms2cc supports several options for customizing behavior:\n\n```powershell\n# Basic usage (uses defaults: msbuild.log → compile_commands.json)\nms2cc\n\n# Specify custom input and output paths\nms2cc -i build\\debug.log -o compile_commands.json\n\n# Pretty-print the JSON output (useful for viewing/debugging)\nms2cc -i msbuild.log -o compile_commands.json -p\n\n# Quiet mode (only show errors)\nms2cc -i msbuild.log -o compile_commands.json -l error\n\n# Disable progress bars (useful for scripting)\nms2cc -i msbuild.log -o compile_commands.json --no-progress\n\n# Overwrite mode (replace instead of merging with existing database)\nms2cc -i msbuild.log -o compile_commands.json --overwrite\n\n# Show all available options\nms2cc --help\n\n# Show version\nms2cc --version\n```\n\n### Available Options\n\n| Option                     | Description                                          | Default                 |\n| -------------------------- | ---------------------------------------------------- | ----------------------- |\n| `-i, --input-file \u003cFILE\u003e`  | Path to MSBuild log file                             | `msbuild.log`           |\n| `-o, --output-file \u003cFILE\u003e` | Path to output compile_commands.json                 | `compile_commands.json` |\n| `-l, --log-level \u003cLEVEL\u003e`  | Logging level (off, error, warn, info, debug, trace) | `info`                  |\n| `-p, --pretty-print`       | Pretty-print JSON output                             | (disabled)              |\n| `--overwrite`              | Replace output file instead of merging               | (merge enabled)         |\n| `--no-progress`            | Disable progress bar output                          | (progress bars enabled) |\n| `-h, --help`               | Display help information                             | -                       |\n| `-V, --version`            | Display version information                          | -                       |\n\n### Incremental Builds\n\nBy default, ms2cc **merges** new entries into an existing `compile_commands.json` rather than replacing it. This means incremental builds work correctly — only the recompiled files are updated while entries for unchanged files are preserved.\n\nEntries are matched by their source file path and project directory. If a file was recompiled, its entry is updated. If a file wasn't recompiled (and therefore not in the new build log), its existing entry is left untouched.\n\nTo start fresh and replace the entire database, use `--overwrite`:\n\n```powershell\nms2cc -i msbuild.log -o compile_commands.json --overwrite\n```\n\n## Editor Configuration\n\nOnce you've generated `compile_commands.json`, configure your editor to use it.\n\n\u003e **Note:** The `compile_commands.json` file should be in your project root directory.\n\n### Visual Studio Code\n\n#### Using Microsoft C/C++ Extension\n\n1. Install the extension\n   1. Open Extensions (`Ctrl+Shift+X`)\n   2. Search for \"C/C++\"\n   3. Install the official [Microsoft C/C++ extension][ms-cpp-ext]\n\n2. Configure\n\n   Create or edit `.vscode/c_cpp_properties.json`:\n\n   ```json\n   {\n     \"configurations\": [\n       {\n         \"name\": \"Win32\",\n         \"compileCommands\": \"${workspaceFolder}/compile_commands.json\",\n         \"intelliSenseMode\": \"windows-msvc-x64\"\n       }\n     ],\n     \"version\": 4\n   }\n   ```\n\n   \u003e **Note:** You can place the `compile_commands.json` file in the `.vscode` directory if you prefer:\n\n   ```json\n   {\n     \"configurations\": [\n       {\n         \"name\": \"Win32\",\n         \"compileCommands\": \"${workspaceFolder}/.vscode/compile_commands.json\",\n         \"intelliSenseMode\": \"windows-msvc-x64\"\n       }\n     ],\n     \"version\": 4\n   }\n   ```\n\n3. Reload VSCode\n\n   Press `Ctrl+Shift+P`, type \"Reload Window\", and press Enter.\n\n4. Confirm the setup by opening a C/C++ file, pressing `Ctrl+Shift+P`, running `C/C++: Log Diagnostics`, and making sure the output reports no parsing or IntelliSense errors.\n\n#### Using clangd\n\n1. Install the [clangd][clangd] extension\n   1. Open VSCode Extensions (`Ctrl+Shift+X`)\n   2. Search for \"clangd\"\n   3. Install the official `llvm-vs-code-extensions.vscode-clangd` extension\n   4. If prompted to download clangd, click \"Download\"\n\n2. Disable Microsoft C++ IntelliSense\n\n   Create or edit `.vscode/settings.json` in your project:\n\n   ```json\n   {\n     \"C_Cpp.intelliSenseEngine\": \"disabled\",\n     \"clangd.arguments\": [\n       \"--compile-commands-dir=${workspaceFolder}\",\n       \"--background-index\",\n       \"--clang-tidy\"\n     ]\n   }\n   ```\n\n3. Reload VSCode\n\n   Press `Ctrl+Shift+P`, type \"Reload Window\", and press Enter.\n\n\u003e **Note for MSVC Projects**: For optimal clangd compatibility with MSVC code, copy `.clangd.template` to `.clangd` in your project root. This configuration suppresses common MSVC-specific warnings. See [Using clangd with MSVC Projects](docs/CLANGD_USAGE.md) for details.\n\n### Other Editors\n\nMost modern editors have excellent clangd support. For detailed setup instructions including:\n\n- **Neovim**\n- **Zed**\n- **Cursor**\n- **Helix**\n- Other LSP-compatible editors\n\nSee the **[Using clangd with MSVC Projects](docs/CLANGD_USAGE.md)** guide for complete configuration examples, compatibility information, and troubleshooting.\n\n**Quick clangd setup:**\n\n1. Generate `compile_commands.json` with ms2cc\n2. (Optional but recommended) Copy `.clangd.template` to `.clangd` in your project root\n3. Configure your editor to use clangd (see guide for editor-specific examples)\n\n## Troubleshooting\n\n### No compile_commands.json generated or file is empty\n\n**Cause:** MSBuild log doesn't have enough detail.\n\n**Solution:** Ensure you used `/v:detailed` when building:\n\n```powershell\nmsbuild YourSolution.sln /v:detailed \u003e msbuild.log\n```\n\n### Some source files are missing from compile_commands.json\n\n**Possible causes:**\n\n- MSBuild verbosity too low\n- Some projects were skipped during build\n\n**Solutions:**\n\n1. Use `/v:detailed` verbosity\n2. Do a clean rebuild and use `--overwrite`: `msbuild YourSolution.sln /t:Rebuild /v:detailed \u003e msbuild.log \u0026\u0026 ms2cc --overwrite`\n\n\u003e **Note:** With incremental builds, ms2cc merges new entries into the existing database by default. If you've done a full rebuild and want a clean database, use `--overwrite` to avoid retaining stale entries from a previous build configuration.\n\n### Editor doesn't recognize compile_commands.json\n\n**Solution:**\n\n1. Ensure `compile_commands.json` is in your **project root directory**\n2. Check your editor configuration (see [Editor Configuration](#editor-configuration))\n3. For clangd, verify it's installed and accessible:\n\n   ```powershell\n   clangd --version\n   ```\n\n4. Reload/restart your editor\n\n### Duplicate symbols or conflicting IntelliSense\n\n**Cause:** Multiple IntelliSense engines running simultaneously.\n\n**Solution (VSCode):** Disable Microsoft C++ IntelliSense when using clangd:\n\nIn `.vscode/settings.json`:\n\n```json\n{\n  \"C_Cpp.intelliSenseEngine\": \"disabled\"\n}\n```\n\n### clangd not found\n\n**Solution:**\n\n1. Download clangd from [https://github.com/clangd/clangd/releases](https://github.com/clangd/clangd/releases)\n2. Add to your PATH, or configure the full path in your editor settings\n\n### clangd shows too many warnings with MSVC code\n\n**Cause:** clangd reports some MSVC-specific warnings that aren't relevant (e.g., `#pragma optimize`, missing field initializers).\n\n**Solution:** Use the provided `.clangd` configuration template:\n\n1. Copy `.clangd.template` to `.clangd` in your project root\n2. Customize as needed (see comments in the template)\n3. For detailed information, see [Using clangd with MSVC Projects](docs/CLANGD_USAGE.md)\n\nThe template suppresses common MSVC-specific warnings while keeping important diagnostics.\n\n## LSP and AI: Better Together\n\nWith the rise of AI-powered coding assistants, some developers believe LSP is antiquated. However, LSP remains essential for high-quality code intelligence for several reasons:\n\n1. They provide deterministic, real-time guarantees\n\n   The [Language Server Protocol][lsp] gives editors fast, reliable, incremental features such as:\n   - autocompletion\n   - hover info and signature help\n   - diagnostics in real time\n   - semantic tokenization\n   - symbol indexing\n   - \"go to definition\" and cross-reference analysis\n\n   These features work because LSP servers maintain an up-to-date AST, symbol tables, type information, and can react within milliseconds.\n\n   LLM-based agents cannot match that determinism or sub-50 ms latency reliably, especially on larger codebases.\n\n2. LSP understands project semantics in a ways LLMs cannot match\n\n   Even with retrieval or agent-based navigation, LLMs still:\n   - lack precise understanding of type systems\n   - can hallucinate unseen functions or APIs\n   - struggle with multi-file, incremental code state\n   - cannot maintain a full AST-level view the way a compiler or language server can\n\n   LSPs plug directly into the compiler toolchain; that precision is not replaceable by probabilistic models alone.\n\n3. Agents build on top of LSP features -- not instead of them\n\n   Modern coding assistants (GitHub Copilot, Cursor AI, Codeium, Windsurf, Zed AI, etc.) typically use:\n   - LLM (reasoning + generation)\n   - LSP (semantic signals, types, diagnostics)\n   - Indexers (global symbol search, embeddings)\n\n   LLMs work best when they are grounded in deterministic data -- and LSP is the grounding layer.\n\n   Agents rely on:\n   - LSP diagnostics to know what's broken\n   - LSP symbol info to find definitions\n   - LSP semantic tokens to reason about structure\n   - LSP type information to provide accurate code suggestions\n\n   If LSP didn’t exist, coding agents would be worse, not better.\n\nThat's why ms2cc exists -- to ensure your C/C++ projects have the LSP foundation that makes both manual coding and AI assistance better. Run ms2cc whenever you regenerate build logs so `compile_commands.json` stays fresh as projects, configurations, or toolchains change.\n\n## References\n\n- [Language Server Protocol (LSP)][lsp]\n- [clangd - C/C++ Language Server][clangd]\n- [clangd Configuration][clangd-config]\n- [Using clangd with MSVC Projects](docs/CLANGD_USAGE.md)\n- [`compile_commands.json` Format][compile-commands]\n- [Microsoft C/C++ Extension for VSCode][ms-cpp-ext]\n- [MSBuild Command-Line Reference][msbuild-cli]\n- [Visual Studio Build Logging][vs-build-logging]\n- [Rust Programming Language][rust]\n\n[lsp]: https://microsoft.github.io/language-server-protocol/\n[clangd]: https://clangd.llvm.org/\n[clangd-config]: https://clangd.llvm.org/config.html\n[compile-commands]: https://clang.llvm.org/docs/JSONCompilationDatabase.html\n[ms-cpp-ext]: https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools\n[msbuild-cli]: https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-command-line-reference\n[vs-build-logging]: https://learn.microsoft.com/en-us/visualstudio/ide/build-log-file-visual-studio\n[rust]: https://www.rust-lang.org/\n[LICENSE]: LICENSE.txt\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE] file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreddiehaddad%2Fms2cc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreddiehaddad%2Fms2cc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreddiehaddad%2Fms2cc/lists"}