Search code examples
visual-studio-codevscode-extensions

How do I use the makefile.buildLog option in VSCode's Makefile Tools extension?


The Makefile Tools extension in VSCode has a configuration field makefile.buildLog.

From the docs:

The extension can also avoid running the make program when it configures your project, if you point the makefile.buildLog setting to the output of a build.

What exactly does the output of a build mean? How do I create it?

I need the feature since the project builds inside a dedicated container, so if VSCode calls dry-runs the environment won't match. However I couldn't find any references to the expected input of such logs.


Solution

  • What the extension expects is a file with the compiler commands used to compile every source file. It will parse the include dirs, compiler flags, etc. for each source file from there. Lines that are not compiler invocations are (I believe) ignored.

    Eg: g++ src/io/ConfiguredFile.cpp -c -o .../ConfiguredFile.o -Og -std=c++20 ...

    Just run make <your-usual-args> | tee output.txt to create it. You may need to manage verbosity settings if your Makefile does not print the full commands by default.

    Note: remember that you need to set the Configuration Provider setting in the C/C++ extension to the Makefile Tools extension in order for these settings to impact IntelliSense. This is what tricked me in into thinking the log was not being parsed. Just add "configurationProvider": "ms-vscode.makefile-tools" in your c_cpp_properties.json.