Makefiles on Windows

Though the methods in this page work both on Linux and Windows, on Linux you may rely on integrated Bear process to generate the compilation database, and therefore use your usual build process flawlessly.

When using make command to build your project, beLow is able to generate a compilation database file using below-make-intercept tool, also available to you as a CLI tool when installing beLow.

To do that, a fake make command is injected while running your build script, which instruments all calls to make to run them in dry-run mode, parse the log and inject new log to be able to generate a compilation database out of it.

To work with make, the only thing you need to do is give your make command as a Build script when asked to.

There is a limitation to this method: if your call to make is wrapped by a script or command calling make command from its absolute path or using path injection, this method will not work.

E.g, if you are using STM32CubeIDE and building your project using stm32cubeidec CLI tool, then this method will not work as this tool calls make command by injecting its own make path. See STM32CubeIDE compability page for more information.

As stated above, you may also directly use below-make-intercept tool to generate a compilation database outside of beLow (in this case, local mode must be used). You may also use it to check the capacity of beLow of generating a compilation database for your make command.

To do that, in a terminal in your project, run:

below-make-intercept "your-command"

The compilation database is printed on the standard output.

For instance, if you wish to generate a compile_commands.json file:

make clean
below-make-intercept "make all" > compile_commands.json

On Windows, to ensure that the compile_commands.json file is encoded properly (and not in a format dependent on your system language), prefer the following Powershell syntax:

make clean
below-make-intercept "make all" | Out-File -Encoding ASCII -FilePath .\compile_commands.json

If beLow seems unable to generate the compile_commands.json file automatically from your build scripts for any reason, you may use below-make-intercept tool directly in the Configure script.

Last updated