Page MenuHomeFreeBSD

gitignore: Add compile_commands.json
ClosedPublic

Authored by khng on Sep 21 2020, 4:23 PM.

Details

Summary

The purpose of this change is to make sure no one would accidentally
include their own workspace leftover into a commit.

compile_commands.json is a generated file which contains build commands.
The file is consumed by Language Servers such as clangd and ccls.

Sponsored by: The FreeBSD Foundation

Diff Detail

Repository
rG FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

khng requested review of this revision.Sep 21 2020, 4:23 PM
khng created this revision.

Just curious, what tool did you use to generate the compile commands database for FreeBSD? I have a vim linter plugin that is kind of useless for FreeBSD code without one.

Just curious, what tool did you use to generate the compile commands database for FreeBSD? I have a vim linter plugin that is kind of useless for FreeBSD code without one.

I currently use devel/bear for the purpose

What drops this file? I don’t recognize it. No objection in principle.

This revision is now accepted and ready to land.Sep 22 2020, 3:51 PM
In D26514#590312, @cem wrote:

What drops this file? I don’t recognize it. No objection in principle.

compile_commands.json is a JSON flat file containing the compiler invocation arguments. The main consumers of that file has mainly been those using libclang. Usually this file is generated by cmake, meson or ninja -t. Despite currently we do not have an official way to generate compile_commands.json, one could still use devel/bear for the purpose. The simplest example is to invoke the following:

cd freebsd-src;
bear -a make buildworld buildkernel

And after the jobs are finished, you could find compile_commands.json sit in the current directory.
For more you could take a look at https://sarcasm.github.io/notes/dev/compilation-database.html.

khng retitled this revision from Add compile_commands*.json to .gitignore to gitignore: Add compile_commands.json.Jun 4 2021, 8:00 AM
khng edited the summary of this revision. (Show Details)
This revision now requires review to proceed.Jun 4 2021, 8:01 AM
This revision is now accepted and ready to land.Jun 4 2021, 8:02 AM
This revision was automatically updated to reflect the committed changes.

I want to read some rtld-elf and libc code on Linux. I cannot run buildworld but want to generate a compile_commands.json to make my ccls happy. What should I do?