Compiler flags in vscode with nRF connecy extension

I want to add compiler  flags to my  build configuration i.e _DEBUG, etc

My understanding is that  a build is done by  build task

nRF Connect extension allows to create a tasks.json from a default nRF Connect build task

In  Terminal->Configure tasks I can select nrf Connect build and it creates the following tasks.json file

{
    "version": "2.0.0",
    "tasks": [
        {
           
            "type": "nrf-connect-build",
            "config": "c:\\<project>\\build",
            "runCmake": false,
            "problemMatcher": [
                "$gcc",
                "$cmake",
                "$kconfig",
                "$kconfig_syntax",
                "$kconfig_syntax_files",
                "$dts",
                "$dts_syntax"
            ],
            "group": "build",
            "label": "My app(Debug)"
        }
    ]
}
The problem is that I cannot add the "args" property - at least in other discussions I saw it being used to add compiler flags 
When I add it I get an error "args is not allowed"
How can I add compile flags to my nrf connect build task ? Or is there another way to do this?
My ultimate goal is to create a debug and release configurations with some defines present in one but not the other 
Thanks
Parents Reply Children
  • I believe this is only for Kconfig . It basically extends your  proj.conf file

    To add arbitrary flags you need to use "Extra CMake arguments"

    The tootip reads
    "Pass additional arguments to the CMake invocation performed by west build. Arguments are appended to the end of the command line, after a "--".

    An argument should follow this format:
    -DCONFIG_DEBUG_OPTIMIZATIONS=y"

    The problem is that you have to enter those arguments in the edit field and they are only saved in the current configuration. And I don't see a way to save multiple configurations and choose the ones you want to build ( like in every other IDE I've used ) I think it's a big deficiency of VSCode.

Related