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 32find_program(PUNCOVER puncover) 33 34if(NOT ${PUNCOVER} STREQUAL PUNCOVER-NOTFOUND) 35 add_custom_target( 36 puncover 37 ${PUNCOVER} 38 --elf_file ${ZEPHYR_BINARY_DIR}/${KERNEL_ELF_NAME} 39 --gcc_tools_base ${CROSS_COMPILE} 40 --src_root ${ZEPHYR_BASE} 41 --build_dir ${CMAKE_BINARY_DIR} 42 DEPENDS ${logical_target_for_zephyr_elf} 43 $<TARGET_PROPERTY:zephyr_property_target,${report}_DEPENDENCIES> 44 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 45 USES_TERMINAL 46 ) 47endif() 48 49find_program(PAHOLE pahole) 50 51if(NOT ${PAHOLE} STREQUAL PAHOLE-NOTFOUND) 52 add_custom_target( 53 pahole 54 ${PAHOLE} 55 --anon_include 56 --nested_anon_include 57 --show_decl_info 58 $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose> 59 ${ZEPHYR_BINARY_DIR}/${KERNEL_ELF_NAME} 60 DEPENDS ${logical_target_for_zephyr_elf} 61 $<TARGET_PROPERTY:zephyr_property_target,${report}_DEPENDENCIES> 62 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 63 USES_TERMINAL 64 ) 65endif() 66