Add single-module code-coverage support

Use the support from https://github.com/ARMmbed/yotta/pull/633 to enable cmakeIncludes
Add a cmakeInclude include to enable coverage if configured by yotta config

For example, to enable code coverage on sockets, use:
```JSON
    "debug" : {
        "options" : {
            "coverage" : {
                "modules" : {
                    "sockets" : true
                }
            }
        }
    }
```
This commit is contained in:
Brendan Moran 2015-12-17 15:19:53 -08:00
parent 1d52c265f9
commit 8cb9af5d0e
2 changed files with 14 additions and 1 deletions

12
coverage/coverage.cmake Normal file
View File

@ -0,0 +1,12 @@
string(TOUPPER "${YOTTA_MODULE_NAME}" upper_name)
string(REPLACE "-" "_" under_name "${upper_name}")
if(${YOTTA_CFG_DEBUG_OPTIONS_COVERAGE_MODULES_${under_name}})
message("Code coverage enabled on ${YOTTA_MODULE_NAME}")
get_property(s TARGET ${YOTTA_MODULE_NAME} PROPERTY COMPILE_FLAGS SET)
if(${s})
get_target_property(flags ${YOTTA_MODULE_NAME} COMPILE_FLAGS)
endif()
set_target_properties(${YOTTA_MODULE_NAME} PROPERTIES COMPILE_FLAGS "${flags} -fprofile-arcs -ftest-coverage")
endif()

View File

@ -32,5 +32,6 @@
"additional_event_pools_size": 100
}
},
"toolchain": "CMake/toolchain.cmake"
"toolchain": "CMake/toolchain.cmake",
"cmakeIncludes": ["coverage/coverage.cmake"]
}