microsoft / vscode-makefile-tools

MAKE integration in Visual Studio Code
Other
194 stars 58 forks source link

Please consider an option to always "Clean Configure" when setting the Configuration #534

Open b-spencer opened 10 months ago

b-spencer commented 10 months ago

First up, thanks for the extension. I use it constantly to generate a compilation database (CDB).

I think that the following Makefile Tools commands behave as I describe below:

  1. "Makefile: Configure" generates a build log by running make with flags including --dry-run that cause it to print the commands needed to build all out-of-date targets. Makefile Tools then parses this to produce compile_commands.json.
  2. "Makefile: Clean Configure" generates a build log by running make with the same flags, plus --always-make so that it prints the commands needed to build all targets.

I also think that whenever I change the "Configuration" on the Makefile Tools section of the Primary Sidebar, the extension automatically runs "Makefile: Configure". Thus, when I switch configuration, the CDB is updated, but only with information about the commands needed to build the out-of-date targets.

(BTW, I learned the above by examining the diagnostics output of Makefile Tools. This wasn't at all obvious to me, and it took a great deal of experimentation to figure this out. I suggest expanding the documentation to talk about these commands and why and when you should use them.)

When I am working on a project, I almost always have all of it already built. So, most of my targets are already up-to-date. This means that when "Makefile: Configure" runs, there are usually zero or very few commands printed by make to the build log, which means that Makefile Tools does not update very much of the CDB.

So, when I change the Configuration in the Makefile Tools section of the Primary Sidebar, I always want to regenerate all of the commands in the CDB. At least for all of my projects, changing the configuration means changing every compile command. Note that I am talking about the Configuration, not the Build target. Note that I do not make clean when I switch configurations. In my projects, different configurations actually generate completely different artefacts to different build output directories, or have other automatic rules that do not require cleaning the workspace. I think this is common even for less complex projects with, for example, release vs. debug configurations.

Thus, every time I change the Configuration:

  1. Makefile Tools runs "Makefile: Configure". It often finds no targets needing rebuilt for the new configuration or some arbitrary small subset and makes no or minimal updates to the CDB.
  2. I wait for that to finish, and then I immediately run "Makefile: Clean Configure" manually in order to regenerate the full CDB for the new configuration.

Therefore, I ask:

  1. Should Makefile Tools have an option to run "Makefile: Clean Configure" whenever you switch targets instead of running "Makefile: Configure"?
  2. Should such an option be enabled by default? (I would think this is the typical case. I can't think of when I'd change configuration and not want to regenerate the whole CDB. Maybe my understanding of how Makefile Tools works is wrong?)

Thanks for considering the questions.

gcampbell-msft commented 10 months ago

@b-spencer Thank you for the detailed issue and request! Updating the docs as well as your suggestions for running clean configure upon switching targets is a reasonable thing to consider, I will mark it as a request and put it on our backlog to investigate and consider! Thanks.