@@ -30,6 +30,7 @@ set(ECLAIR_ANALYSIS_ECL_DIR "${ZEPHYR_BASE}/cmake/sca/eclair/ECL")
3030set (ECLAIR_DIAGNOSTICS_OUTPUT "${ECLAIR_OUTPUT_DIR} /DIAGNOSTIC.txt" )
3131set (ECLAIR_ANALYSIS_DATA_DIR "${ECLAIR_OUTPUT_DIR} /analysis_data" )
3232set (ECLAIR_PROJECT_ECD "${ECLAIR_OUTPUT_DIR} /PROJECT.ecd" )
33+ set (ECLAIR_WORKSPACE "${ECLAIR_OUTPUT_DIR} /eclair_workspace" )
3334set (CC_ALIASES "${CMAKE_C_COMPILER} " )
3435set (CXX_ALIASES "${CMAKE_CXX_COMPILER} " )
3536set (AS_ALIASES "${CMAKE_AS} " )
@@ -43,7 +44,14 @@ set(ECLAIR_REPORT_ADDITIONAL_OPTIONS "")
4344set (ECLAIR_RULESET first_analysis)
4445
4546# ECLAIR env
46- if (ECLAIR_RULESET_FIRST_ANALYSIS)
47+ if (ECLAIR_RULESET_USER)
48+ set (ECLAIR_RULESET ${ECLAIR_USER_RULESET_NAME} )
49+ if (IS_ABSOLUTE ${ECLAIR_USER_RULESET_PATH} )
50+ set (ECLAIR_ANALYSIS_ECL_DIR ${ECLAIR_USER_RULESET_PATH} )
51+ else ()
52+ set (ECLAIR_ANALYSIS_ECL_DIR ${APPLICATION_CONFIG_DIR} /${ECLAIR_USER_RULESET_PATH} )
53+ endif ()
54+ elseif (ECLAIR_RULESET_FIRST_ANALYSIS)
4755 set (ECLAIR_RULESET first_analysis)
4856elseif (ECLAIR_RULESET_STU)
4957 set (ECLAIR_RULESET STU)
@@ -53,13 +61,6 @@ elseif(ECLAIR_RULESET_WP)
5361 set (ECLAIR_RULESET WP)
5462elseif (ECLAIR_RULESET_STD_LIB)
5563 set (ECLAIR_RULESET std_lib)
56- elseif (ECLAIR_RULESET_USER)
57- set (ECLAIR_RULESET ${ECLAIR_USER_RULESET_NAME} )
58- if (IS_ABSOLUTE ${ECLAIR_USER_RULESET_PATH} )
59- set (ECLAIR_ANALYSIS_ECL_DIR ${ECLAIR_USER_RULESET_PATH} )
60- else ()
61- set (ECLAIR_ANALYSIS_ECL_DIR ${APPLICATION_CONFIG_DIR} /${ECLAIR_USER_RULESET_PATH} )
62- endif ()
6364endif ()
6465
6566# ECLAIR report
@@ -106,20 +107,47 @@ endif()
106107message (STATUS "ECLAIR outputs have been written to: ${ECLAIR_OUTPUT_DIR} " )
107108message (STATUS "ECLAIR ECB files have been written to: ${ECLAIR_ANALYSIS_DATA_DIR} " )
108109
110+ list (APPEND ECLAIR_CLEAN_ARGS
111+ +clean
112+ -project_name =${ECLAIR_PROJECT_NAME} -project_root=${ZEPHYR_BASE}
113+ -eval_file=${ECLAIR_ECL_DIR} /analysis.ecl
114+ -eval_file=${ECLAIR_ANALYSIS_ECL_DIR} /analysis_${ECLAIR_RULESET} .ecl
115+ ${ECLAIR_ENV_ADDITIONAL_OPTIONS} )
116+
109117add_custom_target (eclair_setup_analysis_dir ALL
110118 COMMAND ${CMAKE_COMMAND} -E remove_directory ${ECLAIR_ANALYSIS_DATA_DIR}
111119 COMMAND ${CMAKE_COMMAND} -E make_directory ${ECLAIR_ANALYSIS_DATA_DIR}
120+ COMMAND ${CMAKE_COMMAND} -E env
121+ ECLAIR_DIAGNOSTICS_OUTPUT=${ECLAIR_DIAGNOSTICS_OUTPUT}
122+ ECLAIR_DATA_DIR=${ECLAIR_ANALYSIS_DATA_DIR}
123+ ${ECLAIR_ENV} ${ECLAIR_CLEAN_ARGS} --
112124 VERBATIM
113125 USES_TERMINAL
114126)
115127
116- # configure the camke script which will be used to replace the compiler call with the eclair_env
128+ # configure the cmake script which will be used to replace the compiler call with the eclair_env
117129# call which calls the compiler and to generate analysis files.
118130configure_file (${CMAKE_CURRENT_LIST_DIR} /eclair.template ${ECLAIR_OUTPUT_DIR} /eclair.cmake @ONLY)
119131
120132set (launch_environment ${CMAKE_COMMAND} -P ${ECLAIR_OUTPUT_DIR} /eclair.cmake --)
121133set (CMAKE_C_COMPILER_LAUNCHER ${launch_environment} CACHE INTERNAL "" )
122134
135+ list (APPEND ECLAIR_PROJECT_ARGS
136+ +project
137+ -project_name =${ECLAIR_PROJECT_NAME} -project_root=${ZEPHYR_BASE}
138+ -eval_file=${ECLAIR_ECL_DIR} /analysis.ecl
139+ -eval_file=${ECLAIR_ANALYSIS_ECL_DIR} /analysis_${ECLAIR_RULESET} .ecl
140+ ${ECLAIR_ENV_ADDITIONAL_OPTIONS} )
141+
142+ add_custom_target (eclair_project_analysis ALL
143+ COMMAND ${CMAKE_COMMAND} -E env
144+ ECLAIR_DIAGNOSTICS_OUTPUT=${ECLAIR_DIAGNOSTICS_OUTPUT}
145+ ECLAIR_DATA_DIR=${ECLAIR_ANALYSIS_DATA_DIR}
146+ ${ECLAIR_ENV} ${ECLAIR_PROJECT_ARGS} --
147+ VERBATIM
148+ USES_TERMINAL
149+ )
150+
123151# This target is used to generate the ECLAIR database when all the compilation is done and the
124152# elf file was generated with this we cane make sure that the analysis is completed.
125153add_custom_target (eclair_report ALL
@@ -141,4 +169,6 @@ add_custom_target(eclair_summary_print ALL
141169 -overall_txt=${ECLAIR_OUTPUT_DIR} /summary_overall.txt
142170 COMMAND ${CMAKE_COMMAND} -E cat ${ECLAIR_OUTPUT_DIR} /summary_overall.txt
143171)
172+
173+ add_dependencies (eclair_report eclair_project_analysis)
144174add_dependencies (eclair_summary_print eclair_report)
0 commit comments