MS2CC is a Rust CLI that turns msbuild.log
files into a compile_commands.json
compliant 1 database for C and C++ language servers. Point it at the build log from a full MSBuild build and you get an IDE-ready compilation database in seconds.
- Built for clangd, the Microsoft C/C++ extension, and other LSP clients that consume
compile_commands.json
. - Iterator-driven pipeline that keeps memory use low while scanning logs and indexing source trees.
- Friendly CLI with sensible defaults for exclusions, extensions, and thread counts.
MS2CC enables full IDE-like support for C/C++ Language Server Protocol (LSP) clients. It ingests msbuild.log
output from a complete MSBuild build and restructures each compile invocation into a compile_commands.json
entry that language servers can understand. The database works seamlessly with tooling such as clangd and the Microsoft C/C++ Extension for Visual Studio Code.
The compile_commands.json
file is a database that lists all source files in your project along with the exact commands needed to compile each one. Each entry follows this structure:
[
{
"file": "main.cpp",
"directory": "C:\\projects\\example",
"arguments": ["cl.exe", "/EHsc", "/Zi", "/D", "DEBUG", "main.cpp"]
}
]
Grab a prebuilt release from GitHub or build the binary locally with the Rust toolchain.
Since MS2CC is written in Rust, install the toolchain first:
- Follow the Rust installation page to set up
rustup
. - Clone the repository.
- Run
cargo build
for a debug build orcargo build --release
for an optimized binary. - Pick up the resulting executable from
target/debug/
ortarget/release/
.
-
Complete a full build of your C/C++ MSBuild project so the
msbuild.log
contains every compile command. -
Run
ms2cc.exe
(the default output iscompile_commands.json
; override it with--output-file
if you prefer another path). Usems2cc.exe --help
to review every flag:ms2cc.exe --input-file <PATH_TO_MSBUILD.LOG> --source-directory <PATH_TO_PROJECT_SOURCE>
$ ms2cc.exe --help
Tool to generate a compile_commands.json database from an msbuild.log file.
Usage: ms2cc.exe [OPTIONS] --input-file <INPUT_FILE> --source-directory <SOURCE_DIRECTORY>
Options:
-i, --input-file <INPUT_FILE>
Path to msbuild.log
-o, --output-file <OUTPUT_FILE>
Output JSON file [default: compile_commands.json]
-p, --pretty-print
Pretty print output JSON file
-d, --source-directory <SOURCE_DIRECTORY>
Path to source code
-x, --exclude-directories <EXCLUDE_DIRECTORIES>
Directories to exclude during traversal (comma-separated) [default: .git]
-e, --file-extensions <FILE_EXTENSIONS>
File extensions to process (comma-separated) [default: c cc cpp cxx c++ h hh hpp hxx h++ inl]
-c, --compiler-executable <EXE>
Name of compiler executable [default: cl.exe]
-t, --max-threads <MAX_THREADS>
Max number of threads per task [default: 8]
-h, --help
Print help
-V, --version
Print version
Regenerate the database whenever you add, delete, move, or reconfigure source files so the language server stays in sync.
To hook MS2CC into your editor:
- Install a C/C++ language server.
- Configure your editor of choice.
- Point the language server at the generated database.
In VSCode, install the Microsoft C/C++ Extension to enable language support. It creates a .vscode/c_cpp_properties.json
file that stores per-project settings. For each configuration, add a compileCommands
entry like this:
{
"configurations": [
{
"compileCommands": "${workspaceFolder}/.vscode/compile_commands.json"
}
]
}
NOTE: Update the path to match the location of your
compile_commands.json
file.
For most other editors, clangd is a great companion. It automatically walks up the directory tree (including build/
subdirectories) to locate a compile_commands.json
. For example, editing $SRC/gui/window.cpp
prompts clangd to check $SRC/gui/
, $SRC/gui/build/
, $SRC/
, $SRC/build/
, and so on. You can also pin the path explicitly in your clangd configuration:
CompileFlags:
# Directory to compile_commands.json (omit the file name)
CompilationDatabase: c:\\path\\to\\your\\compile_commands.json
TIP: The clangd configuration documentation covers additional options.
cargo fmt
cargo test
cargo bench
Run a quick smoke test against a representative msbuild.log
to confirm end-to-end parsing. This command writes the database to compile_commands.json
and pretty-prints the result:
cargo run -- --input-file path\to\msbuild.log --source-directory path\to\src --pretty-print
Projects that reuse file names can confuse MSBuild logs when the compiler omits absolute paths. MS2CC tries to disambiguate entries with the /Fo
flag, but if the emitted object file lives outside the source directory the lookup may still fail. In those cases MS2CC reports a descriptive error so you can adjust the build.
Contributions are welcome. Simply open a PR!
For questions or comments, start a discussion on GitHub.