From 3579bb65da66f1dd0572ecbecfd670a978590f57 Mon Sep 17 00:00:00 2001 From: Lingkai Dong Date: Wed, 3 Mar 2021 18:11:45 +0000 Subject: [PATCH] Force regenerate application binaries on rebuild If a target has a post binary hook, we should force regenerate the application binaries every time so that the hook is run on a raw binary rather than a previous build that already went through the post-build process once. --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe0587aec2..f5857f3d94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -171,6 +171,12 @@ function(mbed_generate_bin_hex target) ) if(TARGET mbed-post-build-bin-${MBED_TARGET}) + # Remove the .elf file to force regenerate the application binaries + # (including .bin and .hex). This ensures that the post-build script runs + # on a raw application instead of a previous build that already went + # through the post-build process once. + file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/${target}.elf) + # The artefacts must be created before they can be further manipulated add_dependencies(mbed-post-build-bin-${MBED_TARGET} ${target})