[haiku-development] Re: [linting and autocomplete] How to generate compile_commands.json / alternatives

  • From: "Adrien Destugues" <pulkomandy@xxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sun, 21 Mar 2021 20:19:45 +0000

21 mars 2021 17:32 "Abhay Raj Singh" <abhayofficialone@xxxxxxxxx> a écrit:

I use NeoVim as my primary editor it uses clangd with Language Server 
Protocol in the backend.

It requires compile_commands.json which is generated by cmake.

I also use VScode with "C/C++ intellisense" but it also fails to lint.

Is there any other way to use linting and autocomplete. Thanks!

With recent versions of jam built from our buildtools repository there is a way 
to generate a compile_commads.json file.

However there is a limitation: because Jam is closer to make than cmake, it can 
only know which commands will be run at the time the commands are actually 
executed.

This means you have to generate the compile commands from a clean build, so 
that all compile commands are actually run.
If you do it from a partial rebuild, you will get a much smaller file with only 
the commands that were run.

So, the process would be something like that:

- Run ./configure with correct options
- jam -c -j4 @nightly-anyboot (the -c to generate the compile_commands)

Or if you have already run configure and built some things:

- rm -rf generated/objects (delete all compiled files)
- jam -c -j4 @nightly-anyboot (rebuild all compiled files again and generate 
the compilation database)

-- 
Adrien.


Other related posts: