mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-28 03:23:14 +00:00
e08aca162a
The idf_create_size_report function allows for the creation of size report targets based on the generated link map file. The size report targets are created using the TARGET option name: "<target>", "<target>-files", and "<target>-components". These size report targets are added to the idf_default_project with the TARGET set to "size", resulting in the creation of "size", "size-files", and "size-components" targets for the default project. Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
84 lines
2.6 KiB
CMake
84 lines
2.6 KiB
CMake
# SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
#[[
|
|
.. cmakev2:function:: idf_create_size_report
|
|
|
|
.. code-block:: cmake
|
|
|
|
idf_create_size_report(<mapfile>
|
|
TARGET <target>)
|
|
|
|
*mapfile[in]*
|
|
|
|
The mapfile target generated by the idf_build_executable function.
|
|
|
|
*TARGET[in]*
|
|
|
|
The base name for the size report targets to be created. In addition to
|
|
the default size report, which will be available under the target name
|
|
specified in the ``TARGET`` option, two more detailed targets,
|
|
"<target>-files" and "<target>-components", will also be created.
|
|
|
|
Create size report targets for the specified ``mapfile`` target. The
|
|
``TARGET`` option specifies the name of the default size report target, but
|
|
two more targets with detailed reports are also created. For example, if
|
|
``TARGET`` is set to "size," three targets "size", "size-files", and
|
|
"size-components" will be created.
|
|
#]]
|
|
function(idf_create_size_report mapfile_target)
|
|
set(options)
|
|
set(one_value TARGET)
|
|
set(multi_value)
|
|
cmake_parse_arguments(ARG "${options}" "${one_value}" "${multi_value}" ${ARGN})
|
|
|
|
if(NOT DEFINED ARG_TARGET)
|
|
idf_die("TARGET option is required")
|
|
endif()
|
|
|
|
get_target_property(mapfile "${mapfile_target}" MAPFILE_PATH)
|
|
if(NOT mapfile)
|
|
idf_die("Mapfile target '${mapfile_target}' is missing 'MAPFILE_PATH' property.")
|
|
endif()
|
|
|
|
idf_build_get_property(idf_path IDF_PATH)
|
|
idf_build_get_property(python PYTHON)
|
|
|
|
set(idf_size ${python} -m esp_idf_size)
|
|
|
|
add_custom_target(${ARG_TARGET}
|
|
COMMAND ${CMAKE_COMMAND}
|
|
-D "IDF_SIZE_TOOL=${idf_size}"
|
|
-D "MAP_FILE=${mapfile}"
|
|
-D "OUTPUT_JSON=${OUTPUT_JSON}"
|
|
-P "${idf_path}/tools/cmake/run_size_tool.cmake"
|
|
DEPENDS ${mapfile_target}
|
|
USES_TERMINAL
|
|
VERBATIM
|
|
)
|
|
|
|
add_custom_target(${ARG_TARGET}-files
|
|
COMMAND ${CMAKE_COMMAND}
|
|
-D "IDF_SIZE_TOOL=${idf_size}"
|
|
-D "IDF_SIZE_MODE=--files"
|
|
-D "MAP_FILE=${mapfile}"
|
|
-D "OUTPUT_JSON=${OUTPUT_JSON}"
|
|
-P "${idf_path}/tools/cmake/run_size_tool.cmake"
|
|
DEPENDS ${mapfile_target}
|
|
USES_TERMINAL
|
|
VERBATIM
|
|
)
|
|
|
|
add_custom_target(${ARG_TARGET}-components
|
|
COMMAND ${CMAKE_COMMAND}
|
|
-D "IDF_SIZE_TOOL=${idf_size}"
|
|
-D "IDF_SIZE_MODE=--archives"
|
|
-D "MAP_FILE=${mapfile}"
|
|
-D "OUTPUT_JSON=${OUTPUT_JSON}"
|
|
-P "${idf_path}/tools/cmake/run_size_tool.cmake"
|
|
DEPENDS ${mapfile_target}
|
|
USES_TERMINAL
|
|
VERBATIM
|
|
)
|
|
endfunction()
|