Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn makefile into JSON Compilation Database?

Say we have make files (not cmake/premake/ninja etc) for our project that do work for gcc and clang. We want to generate out from them JSON Compilation Database to feed it into clang-modernize tool. How to do such thing? (is there any parser in clang infrastructure or some script with usage like make CC='cc_args.py gcc' CXX='cc_args.py g++' or some other tool)?

like image 963
DuckQueen Avatar asked Jan 15 '14 09:01

DuckQueen


People also ask

What is Compile_commands json?

The compile_commands. json file is a compilation database that consists of an array of “command objects” , where each command object specifies one way a translation unit is compiled in the project.

Which is a collection and compilation database?

A compilation database is a JSON-formatted file named compile_commands. json that contains structured data about every compilation unit in your project. You can see an array of entries called command objects.

How to create a JSON compilation database in Visual Studio Code?

Right-click on the Visual Studio projectto open the Context Menu. Select the Clang Power Toolsoption. In the opened submenu, choose Export Compilation Database. File Explorer is automatically opened with the JSON Compilation Databaseselected. Watch our video tutorial to see the JSON Compilation Database in action. Conclusion

Is there a tool for generating Clang's JSON compilation database file?

GitHub - nickdiego/compiledb: Tool for generating Clang's JSON Compilation Database files for make-based build systems. Failed to load latest commit information. Tool for generating Clang's JSON Compilation Database file for GNU make -based build systems. It's aimed mainly at non-cmake (cmake already generates compilation database) large codebases.

How do I use NMAKE with a JSON compilation database?

Note that the NMAKE generator creates an incorrect compilation database, which is a known issue. The -Mj option writes a compilation entry per input file. You can use it for each file in the project, and then merge the outputs into a JSON-formatted compilation database (see the procedure example ).

What is the best way to generate a compilation database?

Inspired by projects like YCM-Generator and Bear , but faster (mainly with large projects), since in most cases it doesn't need a clean build (as the mentioned tools do) to generate the compilation database file, to achieve this it uses the make options such as -n / --dry-run and -k / --keep-going to extract the compile commands.


1 Answers

I have no personal experience with it but Bear seems to be targeted to your scenario. (It was linked from the clang-modernize site.)

like image 138
Etan Reisner Avatar answered Oct 05 '22 07:10

Etan Reisner