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
  • Any updates on this? I am also in search for a way to define different #defines for debug vs release configuration using UI in vscode extension. 

  • I resolved with a config fragment where the log level config defined

    Config fragment is just a text file with the .conf extension where you can place your build specific configurations

    Here is my debug_build.conf file:

    #If extra debugging is needed - select this file as a kconfig fragment when creating a build configuration
    CONFIG_LOG_DEFAULT_LEVEL=4
    A config fragment can be added when you create ( or edit ) your build configuration.
    Hope this helps
    Andy
  • Thanks alot for sharing this. But can we also define custom flags here? For example something like:

    DISABLE_CONNECTION_TIMEOUT = y # I get a compile time error if I do this.

    and then refer to this in the code as:


    #ifdef DISABLE_CONNECTION_TIMEOUT 

    // disable timout code

    #endif

  • 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.

Reply
  • 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.

Children
No Data
Related