1# SPDX-License-Identifier: Apache-2.0 2 3set(flag_for_ram_report ram) 4set(flag_for_rom_report rom) 5set(flag_for_footprint all -q) 6set(report_depth 99) 7 8if(DEFINED ZEPHYR_WORKSPACE) 9 set(workspace_arg "--workspace=${ZEPHYR_WORKSPACE}") 10elseif(DEFINED WEST_TOPDIR) 11 set(workspace_arg "--workspace=${WEST_TOPDIR}") 12endif() 13 14foreach(report ram_report rom_report footprint) 15 add_custom_target( 16 ${report} 17 ${PYTHON_EXECUTABLE} 18 ${ZEPHYR_BASE}/scripts/footprint/size_report 19 -k ${ZEPHYR_BINARY_DIR}/${KERNEL_ELF_NAME} 20 -z ${ZEPHYR_BASE} 21 -o ${CMAKE_BINARY_DIR} 22 ${workspace_arg} 23 -d ${report_depth} 24 ${flag_for_${report}} 25 DEPENDS ${logical_target_for_zephyr_elf} 26 $<TARGET_PROPERTY:zephyr_property_target,${report}_DEPENDENCIES> 27 USES_TERMINAL 28 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 29 ) 30endforeach() 31 32if (CONFIG_BUILD_WITH_TFM) 33 foreach(report ram_report rom_report footprint) 34 add_custom_target( 35 tfm_${report} 36 ${PYTHON_EXECUTABLE} 37 ${ZEPHYR_BASE}/scripts/footprint/size_report 38 -k $<TARGET_PROPERTY:tfm,TFM_S_ELF_FILE> 39 -z ${ZEPHYR_BASE} 40 -o ${CMAKE_BINARY_DIR} 41 ${workspace_arg} 42 -d ${report_depth} 43 ${flag_for_${report}} 44 DEPENDS tfm 45 USES_TERMINAL 46 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 47 ) 48 endforeach() 49endif() 50 51if (CONFIG_TFM_BL2) 52 foreach(report ram_report rom_report footprint) 53 add_custom_target( 54 bl2_${report} 55 ${PYTHON_EXECUTABLE} 56 ${ZEPHYR_BASE}/scripts/footprint/size_report 57 -k $<TARGET_PROPERTY:tfm,BL2_ELF_FILE> 58 -z ${ZEPHYR_BASE} 59 -o ${CMAKE_BINARY_DIR} 60 ${workspace_arg} 61 -d ${report_depth} 62 ${flag_for_${report}} 63 DEPENDS tfm 64 USES_TERMINAL 65 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 66 ) 67 endforeach() 68endif() 69 70find_program(PUNCOVER puncover) 71 72if(NOT ${PUNCOVER} STREQUAL PUNCOVER-NOTFOUND) 73 add_custom_target( 74 puncover 75 ${PUNCOVER} 76 --elf_file ${ZEPHYR_BINARY_DIR}/${KERNEL_ELF_NAME} 77 --gcc_tools_base ${CROSS_COMPILE} 78 --src_root ${ZEPHYR_BASE} 79 --build_dir ${CMAKE_BINARY_DIR} 80 DEPENDS ${logical_target_for_zephyr_elf} 81 $<TARGET_PROPERTY:zephyr_property_target,${report}_DEPENDENCIES> 82 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 83 USES_TERMINAL 84 ) 85endif() 86 87find_program(PAHOLE pahole) 88 89if(NOT ${PAHOLE} STREQUAL PAHOLE-NOTFOUND) 90 add_custom_target( 91 pahole 92 ${PAHOLE} 93 --anon_include 94 --nested_anon_include 95 --show_decl_info 96 $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose> 97 ${ZEPHYR_BINARY_DIR}/${KERNEL_ELF_NAME} 98 DEPENDS ${logical_target_for_zephyr_elf} 99 $<TARGET_PROPERTY:zephyr_property_target,${report}_DEPENDENCIES> 100 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 101 USES_TERMINAL 102 ) 103endif() 104