Giter Site home page Giter Site logo

ikergimenez / msbuildcompilecommandsjson Goto Github PK

View Code? Open in Web Editor NEW

This project forked from 0xabu/msbuildcompilecommandsjson

0.0 0.0 0.0 16 KB

An MSBuild logger that emits compile_commands.json for C++ projects

License: MIT License

C# 100.00%

msbuildcompilecommandsjson's Introduction

MSBuild compile_commands.json logger

This is a simple MSBuild logger that emits a Clang-style compile_commands.json file by observing the MSVC compiler invocations when a C++ project is built. It is particularly useful with Visual Studio Code's C/C++ extension, which can be configured to use compile_commands.json to determine the compiler options (include paths, defines, etc.) for accurate IntelliSense.

Usage

Building the project is straightforward:

dotnet build

Then, invoke MSBuild with the -logger option. For example:

msbuild -logger:/path/to/CompileCommandsJson.dll MyProject

By default, compile_commands.json is written in the current directory. You can control the output path using a parameter, e.g.:

msbuild -logger:/path/to/CompileCommandsJson.dll;my_new_compile_commands.json MyProject

Limitations

There are two significant design limitations:

  1. The logger will only emit entries for compiler invocations that it observes during a build; in particular, for an incremental build, there will be no output for any targets that are considered up to date.

  2. The logger truncates the JSON file at startup, and writes to it incrementally throughout the build.

Thus, for an accurate result you should use this logger only on a completely clean build, and to avoid confusing tools (such as VSCode) that may observe the file as it is written, you should probably write the output to a temporary file and rename it only after the build succeeds. Typical usage is roughly:

rm -r out
msbuild -logger:CompileCommandsLogger.dll;cctmp.json
mv cctmp.json compile_commands.json

Author

Andrew Baumann

msbuildcompilecommandsjson's People

Contributors

0xabu avatar ryanbinnsrv avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.