This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nRF Connect VSCode Extension - Saving Build Configuration

Hello,

I've started to develop with the nRF Connect VSCode extension and enjoying it a lot. However, I've noticed when I share a project the build configuration doesn't carry across.

Is there any way to get the extension to save the build configuration to a file or to .vscode/settings.json?

Our current workaround is to a shell script that runs the same command as the build configurator does but it's not ideal.

Many thanks,

Archie

Parents
  • Hi Archie,

    The build configuration in VS Code is connected to the build folder, so sharing the project folder with the build folder inside will technically let you share the build configuration. However, this will give you an error if you try to build the shared project unless you do a pristine build, because the environment of the project folder will now be incorrect with regards to the configurations. I would not recommend doing this.

    Is there a particular reason for why you need to share the build configuration and cannot simply create a new one in the shared project? If you are going to build the shared project you would have to configure the project again anyway (by either doing a pristine build or creating a new build configuration), so there is no reason to share the build configuration/folder.

    Best regards,

    Marte

  • Hi Marte,

    Thank you for your swift response. 

    As you said, I don't want to share the build folder but I do want others to be able to clone the repo and build the same configuration as me (same board, same CMake arguments, same folder name etc). Ideally, I would like these to appear in the nRF Connect GUI like the application does so they can quickly make a pristine build without having to fill in the build configuration GUI or type a command.

    Maybe I'm using build configurations wrong and this isn't the intended use case? We currently have two build configurations in your repo, one for the nRF dev board and one for the native posix board. One is our main target, the other is for unit testing. 

    I hope that makes sense. Let me know if you have more questions. 

    Many Thanks,

    Archie

  • Hi Archie,

    I would not recommend using the build configuration for this. However, some of this can be solved by setting the configurations in CMakeLists.txt. Please see Providing CMake options and Important Build System Variables for more information.

    Best regards,

    Marte

  • Hi Marte,

    Thank you for your reply. This is the solution I have come to as well.

    What is the purpose of build configuration then? I'm a bit unsure what their use case is if this isn't it. 

    Many Thanks,
    Archie

  • Hi Archie,

    The build configuration is essentially a CMake build system. Much of what the VS Code extension does are things you can do on the command line using west and cmake, but with the extension you have a GUI making the process easier. When you create the build configuration it is the same as if you were to run the 'west build' command, but instead of needing to know what parameters to add to the command and how you can just select them in the GUI. For example, it is easier to select which .conf file to use using the drop down menu in the configuration option in the build configuration wizard than to know that you have to add -DCONF_FILE="<conf_filename>.conf" to the west build command. Additionally it makes it easier for users to do things such as rebuild and flash applications, as they can do so by selecting the build configuration and the desired action, instead of having to run the commands on command line.

    Best regards,

    Marte

Reply
  • Hi Archie,

    The build configuration is essentially a CMake build system. Much of what the VS Code extension does are things you can do on the command line using west and cmake, but with the extension you have a GUI making the process easier. When you create the build configuration it is the same as if you were to run the 'west build' command, but instead of needing to know what parameters to add to the command and how you can just select them in the GUI. For example, it is easier to select which .conf file to use using the drop down menu in the configuration option in the build configuration wizard than to know that you have to add -DCONF_FILE="<conf_filename>.conf" to the west build command. Additionally it makes it easier for users to do things such as rebuild and flash applications, as they can do so by selecting the build configuration and the desired action, instead of having to run the commands on command line.

    Best regards,

    Marte

Children
  • Hi Marte,

    Thanks for the quick reply. That makes sense. I think my original point still stands, being able to store build configuration in their own file or in the vscode settings and have them detected by the nRF Connect extension would be very useful to quickly get developers up and running on a new codebase. 

    Is it possible to make an official feature request somewhere?

    Many thanks,

    Archie

  • Hi Archie,

    I have forwarded this to the VS Code team.

    Best regards,

    Marte

  • Hi Archie,

    I see that you marked the ticket as verified answer, but I just want to inform you what the developers said.

    They have thought a bit about this previously, and what they came up with then was to use cmake-presets: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html. Since we do not have any UI support for this you will need to use command line. Here is an example from the developers that works with CMake 3.22:

    CMakePresets.json (in the app folder, next to CMakeLists.txt):

    {
      "version": 3,
      "cmakeMinimumRequired": {
        "major": 3,
        "minor": 22,
        "patch": 0
      },
      "configurePresets": [
        {
          "name": "default",
          "displayName": "nRF52 DK",
          "description": "Default build for nRF52 DK",
          "generator": "Ninja",
          "cacheVariables": {
            "BOARD": "nrf52dk_nrf52832"
          }
        }
      ]
    }

    Call west build -d new_build_folder -- --preset default and west will generate and build a new configuration with this preset that the extension picks up automatically.

    This has also been discussed with the Zephyr build system maintainers, who agreed that this is the right solution to this problem in Zephyr. The developers will look into also adding support for this in the generate build UI.

    Best regards,

    Marte

Related