When collaborating with others, being able to share and reproduce build configurations across different machines becomes increasingly important as the project grows in complexity. Although this could be achieved by sharing the west build invocation, it is an error-prone and painful workflow, and the VS Code extension hasn't supported this properly until now.
We have now added the ability to save and load build configurations as CMake Presets. CMake Presets are build configuration templates, that can be passed to CMake to produce a build that has the exact same parameters without having to store the CMake command line arguments. CMake Presets are stored in a CMakePresets.json file in the application source directory. Presets can be checked into source control to make sure that all developers working on the same application can build with exactly the same parameters without having to manually copy the parameters.
You can save existing build configurations as presets with the new Save Configuration As Preset action in the Applications panel. Click the menu icon in the top level build configuration called More Actions..., and click on Save Configuration as Preset to use this action, as shown below.
nRF Connect: Save Configuration as Preset is also available through the Command Palette. This opens a quick-pick selection of a build configuration, then saves it to the CMakePresets.json file.
When presets are available for an application, a preset selection box will appear at the top of the Add Build Configuration window. When a preset is selected, it fills in the rest of the fields. You can make changes to the fields before building, or press Ctrl-Enter to build right away. You can also populate build configurations from a preset.
The newly created file can be used to generate new builds by using:
west build -d ${targetDir} -- --preset ${presetName} -DNCS_TOOLCHAIN_VERSION=NONE