mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
feat(cmakev2/utilities): add idf_target_post_build_msg helper
Add a helper function for printing multi-line post-build messages on a target. The message lines are joined with newlines, written to a file at configure time, and printed at build time using a single cmake -E cat command, replacing the need for repeated cmake -E echo invocations. Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
@@ -683,6 +683,31 @@ function(add_prefix var prefix)
|
||||
set(${var} "${newlist}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
#[[
|
||||
idf_target_post_build_msg(<target> <line>...)
|
||||
|
||||
*target[in]*
|
||||
|
||||
Target to attach the post-build message to.
|
||||
|
||||
*line[in]*
|
||||
|
||||
Message lines to print after the target is built.
|
||||
|
||||
Add a post-build step to ``<target>`` that prints the given message lines.
|
||||
The lines are joined with newlines, written to a file at configure time,
|
||||
and printed at build time using a single ``cmake -E cat`` command.
|
||||
#]]
|
||||
function(idf_target_post_build_msg target)
|
||||
string(MD5 hash "${ARGN}")
|
||||
set(msg_file "${CMAKE_CURRENT_BINARY_DIR}/_post_build_msg_${target}_${hash}.txt")
|
||||
list(JOIN ARGN "\n" msg)
|
||||
file(WRITE "${msg_file}" "${msg}\n")
|
||||
add_custom_command(TARGET ${target} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E cat "${msg_file}"
|
||||
VERBATIM)
|
||||
endfunction()
|
||||
|
||||
#[[
|
||||
fail_target(<target> <line0> [<line>...])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user