Skip to content

Commit e4469c3

Browse files
authored
add depth, json and html to memap (ARMmbed#95)
1 parent 72832c7 commit e4469c3

File tree

1 file changed

+48
-8
lines changed

1 file changed

+48
-8
lines changed

tools/cmake/mbed_target_functions.cmake

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,54 @@ endfunction()
5656
# Parse toolchain generated map file of `target` and display a readable table format.
5757
#
5858
function(mbed_generate_map_file target)
59-
add_custom_command(
60-
TARGET
61-
${target}
62-
POST_BUILD
63-
COMMAND ${Python3_EXECUTABLE} ${mbed-os_SOURCE_DIR}/tools/memap.py -t ${MBED_TOOLCHAIN} ${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map
64-
WORKING_DIRECTORY
65-
${CMAKE_CURRENT_BINARY_DIR}
66-
)
59+
# set default args for memap.py
60+
set(MBED_MEMAP_DEPTH "2" CACHE STRING "directory depth level to display report")
61+
set(MBED_MEMAP_CREATE_JSON FALSE CACHE BOOL "create report in json file")
62+
set(MBED_MEMAP_CREATE_HTML FALSE CACHE BOOL "create report in html file")
63+
64+
# generate table for screen
65+
add_custom_command(
66+
TARGET
67+
${target}
68+
POST_BUILD
69+
COMMAND ${Python3_EXECUTABLE} ${mbed-os_SOURCE_DIR}/tools/memap.py
70+
-t ${MBED_TOOLCHAIN} ${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map
71+
--depth ${MBED_MEMAP_DEPTH}
72+
WORKING_DIRECTORY
73+
${CMAKE_CURRENT_BINARY_DIR}
74+
)
75+
76+
# generate json file
77+
if (${MBED_MEMAP_CREATE_JSON})
78+
add_custom_command(
79+
TARGET
80+
${target}
81+
POST_BUILD
82+
COMMAND ${Python3_EXECUTABLE} ${mbed-os_SOURCE_DIR}/tools/memap.py
83+
-t ${MBED_TOOLCHAIN} ${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map
84+
--depth ${MBED_MEMAP_DEPTH}
85+
-e json
86+
-o ${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.memmap.json
87+
WORKING_DIRECTORY
88+
${CMAKE_CURRENT_BINARY_DIR}
89+
)
90+
endif()
91+
92+
# generate html file
93+
if (${MBED_MEMAP_CREATE_HTML})
94+
add_custom_command(
95+
TARGET
96+
${target}
97+
POST_BUILD
98+
COMMAND ${Python3_EXECUTABLE} ${mbed-os_SOURCE_DIR}/tools/memap.py
99+
-t ${MBED_TOOLCHAIN} ${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map
100+
--depth ${MBED_MEMAP_DEPTH}
101+
-e html
102+
-o ${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.memmap.html
103+
WORKING_DIRECTORY
104+
${CMAKE_CURRENT_BINARY_DIR}
105+
)
106+
endif()
67107
endfunction()
68108

69109
#

0 commit comments

Comments
 (0)