Skip to content

Commit 2cd6c70

Browse files
authored
Merge pull request #15117 from JojoS62/fix-memap-diff
CLI2: copy mapfile for diff statistics
2 parents 8706a1a + 2b7b973 commit 2cd6c70

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tools/cmake/mbed_set_post_build.cmake

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ function(mbed_generate_map_file target)
5858
COMMAND ${Python3_EXECUTABLE} ${mbed-os_SOURCE_DIR}/tools/memap.py -t ${MBED_TOOLCHAIN} ${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map
5959
WORKING_DIRECTORY
6060
${CMAKE_CURRENT_BINARY_DIR}
61-
COMMENT
62-
"Displaying memory map for ${target}"
6361
)
6462
endfunction()
6563

@@ -87,6 +85,18 @@ function(mbed_set_post_build target)
8785
# The mapfile name includes the top-level target name and the
8886
# executable suffix for all toolchains as CMake hardcodes the name of the
8987
# diagnostic output file for some toolchains.
88+
89+
# copy mapfile .map to .map.old for ram/rom statistics diff in memap.py
90+
if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map)
91+
add_custom_command(
92+
TARGET
93+
${target}
94+
PRE_BUILD
95+
COMMAND
96+
${CMAKE_COMMAND} -E rename "${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map" "${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map.old"
97+
)
98+
endif()
99+
90100
mbed_configure_memory_map(${target} "${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map")
91101
mbed_validate_application_profile(${target})
92102
mbed_generate_bin_hex(${target})

0 commit comments

Comments
 (0)