Fix dependency on boot_stage2 so that changes actually cause update of .S and relink of main application elf

This commit is contained in:
graham sanderson 2021-01-30 20:09:09 -06:00 committed by Graham Sanderson
parent 1243ee175f
commit b8c17354e4

View File

@ -31,26 +31,24 @@ function(pico_define_boot_stage2 NAME SOURCES)
target_link_libraries(${NAME} hardware_regs) target_link_libraries(${NAME} hardware_regs)
target_link_options(${NAME} PRIVATE "LINKER:--script=${PICO_BOOT_STAGE2_DIR}/boot_stage2.ld") target_link_options(${NAME} PRIVATE "LINKER:--script=${PICO_BOOT_STAGE2_DIR}/boot_stage2.ld")
set_target_properties(${NAME} PROPERTIES LINK_DEPENDS ${PICO_BOOT_STAGE2_DIR}/boot_stage2.ld) set_target_properties(${NAME} PROPERTIES LINK_DEPENDS ${PICO_BOOT_STAGE2_DIR}/boot_stage2.ld)
pico_add_dis_output(${NAME}) pico_add_dis_output(${NAME})
pico_add_map_output(${NAME}) pico_add_map_output(${NAME})
set(ORIGINAL_BIN ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.bin) set(ORIGINAL_BIN ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.bin)
set(PADDED_CHECKSUMMED_ASM ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_padded_checksummed.S) set(PADDED_CHECKSUMMED_ASM ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_padded_checksummed.S)
add_custom_target(${NAME}_bin DEPENDS ${ORIGINAL_BIN})
add_dependencies(${NAME}_bin ${NAME})
add_custom_command(OUTPUT ${ORIGINAL_BIN} COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${NAME}> ${ORIGINAL_BIN})
find_package (Python3 REQUIRED COMPONENTS Interpreter) find_package (Python3 REQUIRED COMPONENTS Interpreter)
add_custom_command(OUTPUT ${PADDED_CHECKSUMMED_ASM}
COMMAND ${Python3_EXECUTABLE} ${PICO_BOOT_STAGE2_DIR}/pad_checksum -s 0xffffffff ${ORIGINAL_BIN} ${PADDED_CHECKSUMMED_ASM} add_custom_target(${NAME}_bin DEPENDS ${ORIGINAL_BIN})
) add_custom_command(OUTPUT ${ORIGINAL_BIN} DEPENDS ${NAME} COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${NAME}> ${ORIGINAL_BIN})
add_custom_target(${NAME}_padded_checksummed_asm DEPENDS ${PADDED_CHECKSUMMED_ASM}) add_custom_target(${NAME}_padded_checksummed_asm DEPENDS ${PADDED_CHECKSUMMED_ASM})
add_dependencies(${NAME}_padded_checksummed_asm ${NAME}_bin) add_custom_command(OUTPUT ${PADDED_CHECKSUMMED_ASM} DEPENDS ${ORIGINAL_BIN}
COMMAND ${Python3_EXECUTABLE} ${PICO_BOOT_STAGE2_DIR}/pad_checksum -s 0xffffffff ${ORIGINAL_BIN} ${PADDED_CHECKSUMMED_ASM}
)
add_library(${NAME}_library INTERFACE) add_library(${NAME}_library INTERFACE)
add_dependencies(${NAME}_library ${NAME}_padded_checksummed_asm) add_dependencies(${NAME}_library ${NAME}_padded_checksummed_asm)
# not strictly (or indeed actually) a link library, but this avoids dependency cycle # not strictly (or indeed actually) a link library, but this avoids dependency cycle