esptool_py: better display logs when generating binary

Since OUTPUT argument of custom command does not currently support
generator expressions, the project image is only generated as a side
effect. The primary generated file is a timestamp file. Unfortunately as a consequence
the output logs when the
binary is about to be generated is not as helpful anymore.

Set a custom comment that is more descriptive of what is happening,
and provide more feedback as to what has been generated.
This commit is contained in:
Renz Christian Bagaporo 2019-06-17 12:20:12 +08:00
parent 64d37f5cb9
commit 7a19894aec

View File

@ -75,28 +75,33 @@ set(PROJECT_BIN "${elf_name}.bin")
# #
# Add 'app.bin' target - generates with elf2image # Add 'app.bin' target - generates with elf2image
# #
add_custom_command(OUTPUT "${build_dir}/.app_hash" add_custom_command(OUTPUT "${build_dir}/.bin_timestamp"
COMMAND ${ESPTOOLPY} elf2image ${ESPTOOLPY_ELF2IMAGE_FLASH_OPTIONS} ${ESPTOOLPY_ELF2IMAGE_OPTIONS} COMMAND ${ESPTOOLPY} elf2image ${ESPTOOLPY_ELF2IMAGE_FLASH_OPTIONS} ${ESPTOOLPY_ELF2IMAGE_OPTIONS}
-o "${build_dir}/${unsigned_project_binary}" "${elf}" -o "${build_dir}/${unsigned_project_binary}" "${elf}"
COMMAND ${CMAKE_COMMAND} -E md5sum "${build_dir}/${unsigned_project_binary}" > "${build_dir}/.app_hash" COMMAND ${CMAKE_COMMAND} -E echo "Generated ${build_dir}/${unsigned_project_binary}"
COMMAND ${CMAKE_COMMAND} -E md5sum "${build_dir}/${unsigned_project_binary}" > "${build_dir}/.bin_timestamp"
DEPENDS ${elf} DEPENDS ${elf}
VERBATIM VERBATIM
WORKING_DIRECTORY ${build_dir} WORKING_DIRECTORY ${build_dir}
COMMENT "Generating binary image from built executable"
) )
add_custom_target(gen_project_binary DEPENDS "${build_dir}/.app_hash") add_custom_target(gen_project_binary DEPENDS "${build_dir}/.bin_timestamp")
if(NOT BOOTLOADER_BUILD AND if(NOT BOOTLOADER_BUILD AND
CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES) CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)
# for locally signed secure boot image, add a signing step to get from unsigned app to signed app # for locally signed secure boot image, add a signing step to get from unsigned app to signed app
add_custom_command(OUTPUT "${build_dir}/.signed_app_hash" add_custom_command(OUTPUT "${build_dir}/.signed_bin_timestamp"
COMMAND ${ESPSECUREPY} sign_data --keyfile ${secure_boot_signing_key} COMMAND ${ESPSECUREPY} sign_data --keyfile ${secure_boot_signing_key}
-o "${build_dir}/${PROJECT_BIN}" "${build_dir}/${unsigned_project_binary}" -o "${build_dir}/${PROJECT_BIN}" "${build_dir}/${unsigned_project_binary}"
COMMAND ${CMAKE_COMMAND} -E md5sum "${build_dir}/${PROJECT_BIN}" > "${build_dir}/.signed_app_hash" COMMAND ${CMAKE_COMMAND} -E echo "Generated signed binary image ${build_dir}/${PROJECT_BIN}"
DEPENDS "${build_dir}/.app_hash" "from ${build_dir}/${unsigned_project_binary}"
COMMAND ${CMAKE_COMMAND} -E md5sum "${build_dir}/${PROJECT_BIN}" > "${build_dir}/.signed_bin_timestamp"
DEPENDS "${build_dir}/.bin_timestamp"
VERBATIM VERBATIM
COMMENT "Generating signed binary image"
) )
add_custom_target(gen_signed_project_binary DEPENDS "${build_dir}/.signed_app_hash") add_custom_target(gen_signed_project_binary DEPENDS "${build_dir}/.signed_bin_timestamp")
add_dependencies(gen_project_binary gen_signed_project_binary) add_dependencies(gen_project_binary gen_signed_project_binary)
endif() endif()
@ -106,6 +111,7 @@ else()
add_custom_target(bootloader ALL DEPENDS gen_project_binary) add_custom_target(bootloader ALL DEPENDS gen_project_binary)
endif() endif()
if(NOT BOOTLOADER_BUILD AND if(NOT BOOTLOADER_BUILD AND
CONFIG_SECURE_BOOT_ENABLED AND CONFIG_SECURE_BOOT_ENABLED AND
NOT CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES) NOT CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)