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
  • Did a bit more experimentation. The only way I could make this work was to add the following to CMakeLists.txt
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DAPP_DBG_LEVEL=4")
    But that does achieve my goal of setting that flag to a certain value based on a condition ( debug vs release build )
    When I set that flag in the build configuration window "Extra flags for CMAKE" I see it appear in the output but the flag is not processed by the preprocessor so it remains undefined in the code
    #ifndef APP_DBG_LEVEL
    #error App debug level undefined
    #endif

Reply
  • Did a bit more experimentation. The only way I could make this work was to add the following to CMakeLists.txt
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DAPP_DBG_LEVEL=4")
    But that does achieve my goal of setting that flag to a certain value based on a condition ( debug vs release build )
    When I set that flag in the build configuration window "Extra flags for CMAKE" I see it appear in the output but the flag is not processed by the preprocessor so it remains undefined in the code
    #ifndef APP_DBG_LEVEL
    #error App debug level undefined
    #endif

Children
No Data
Related