Skip to content

Commit 5e33442

Browse files
pdgendtcarlescufi
authored andcommitted
cmake: sca: codechecker: Parse twister variables
If we're running in a twister context, use the information as sane defaults for CodeChecker. Signed-off-by: Pieter De Gendt <[email protected]>
1 parent 518c818 commit 5e33442

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

cmake/sca/codechecker/sca.cmake

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
#
33
# Copyright (c) 2023, Basalte bv
44

5+
include(boards)
6+
include(git)
7+
include(extensions)
8+
include(west)
9+
510
find_program(CODECHECKER_EXE NAMES CodeChecker codechecker REQUIRED)
611
message(STATUS "Found SCA: CodeChecker (${CODECHECKER_EXE})")
712

@@ -17,14 +22,24 @@ zephyr_get(CODECHECKER_PARSE_SKIP)
1722
zephyr_get(CODECHECKER_STORE)
1823
zephyr_get(CODECHECKER_STORE_OPTS)
1924
zephyr_get(CODECHECKER_STORE_TAG)
20-
zephyr_get(CODECHECKER_TRIM_PATH_PREFIX)
25+
zephyr_get(CODECHECKER_TRIM_PATH_PREFIX MERGE VAR CODECHECKER_TRIM_PATH_PREFIX WEST_TOPDIR)
26+
27+
# Get twister runner specific variables
28+
zephyr_get(TC_RUNID)
29+
zephyr_get(TC_NAME)
2130

2231
if(NOT CODECHECKER_NAME)
23-
set(CODECHECKER_NAME zephyr)
32+
if(TC_NAME)
33+
set(CODECHECKER_NAME "${BOARD}${BOARD_QUALIFIERS}:${TC_NAME}")
34+
else()
35+
set(CODECHECKER_NAME zephyr)
36+
endif()
2437
endif()
2538

2639
if(CODECHECKER_ANALYZE_JOBS)
2740
set(CODECHECKER_ANALYZE_JOBS "--jobs;${CODECHECKER_ANALYZE_JOBS}")
41+
elseif(TC_RUNID)
42+
set(CODECHECKER_ANALYZE_JOBS "--jobs;1")
2843
endif()
2944

3045
if(CODECHECKER_CONFIG_FILE)
@@ -33,6 +48,11 @@ endif()
3348

3449
if(CODECHECKER_STORE_TAG)
3550
set(CODECHECKER_STORE_TAG "--tag;${CODECHECKER_STORE_TAG}")
51+
else()
52+
git_describe(${APPLICATION_SOURCE_DIR} app_version)
53+
if(app_version)
54+
set(CODECHECKER_STORE_TAG "--tag;${app_version}")
55+
endif()
3656
endif()
3757

3858
if(CODECHECKER_TRIM_PATH_PREFIX)

0 commit comments

Comments
 (0)