forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmake: Toolchain abstraction: Abstraction of print memory usage.
The method for getting a memory usage report printed during build, is based on a GNU linker (ld) option flag, and thus is not necessarily supported by other toolchain binary tools. The introduced cmake macro allows for a given toolchain to specify how the memory usage report is to be generated, and whether the command for generation, if any, is to be added to the post_build_commands and the post_build_byproducts lists of the top level CMakeLists.txt The intent here is to abstract Zephyr's dependence on toolchains, thus allowing for easier porting to other, perhaps commercial, toolchains and/or usecases. No functional change expected. Signed-off-by: Danny Oerndrup <[email protected]>
- Loading branch information
Showing
5 changed files
with
59 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Add and/or prepare print of memory usage report | ||
# | ||
# Usage: | ||
# bintools_print_mem_usage( | ||
# RESULT_CMD_LIST <List of commands to be executed, usually after build> | ||
# RESULT_BYPROD_LIST <List of command output byproducts> | ||
# ) | ||
# | ||
macro(bintools_print_mem_usage) | ||
|
||
# Here we make use of the linkers ability to produce memory usage output | ||
# and thus we have no need for the above provided arguments, but another | ||
# toolchain with a different set of binary tools, most likely will... | ||
# | ||
# Use --print-memory-usage with the first link. | ||
# | ||
# Don't use this option with the second link because seeing it twice | ||
# could confuse users and using it on the second link would suppress | ||
# it when the first link has a ram/flash-usage issue. | ||
set(option ${LINKERFLAGPREFIX},--print-memory-usage) | ||
string(MAKE_C_IDENTIFIER check${option} check) | ||
|
||
set(SAVED_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) | ||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${option}") | ||
zephyr_check_compiler_flag(C "" ${check}) | ||
set(CMAKE_REQUIRED_FLAGS ${SAVED_CMAKE_REQUIRED_FLAGS}) | ||
|
||
target_link_libraries_ifdef(${check} ${ZEPHYR_PREBUILT_EXECUTABLE} ${option}) | ||
|
||
endmacro(bintools_print_mem_usage) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters