boot: zephyr: Fix build issue for multiple conf files

Change fixes build issue that occurs if CONF_FILE contains multiple
file paths instead of single file path.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
This commit is contained in:
Marek Pieta 2020-08-12 04:29:12 -07:00 committed by Andrzej Puzdrowski
parent 9ed399cd6d
commit c1cdcae197
1 changed files with 16 additions and 3 deletions

View File

@ -231,17 +231,30 @@ if(CONFIG_MCUBOOT_SERIAL)
)
endif()
# CONF_FILE points to the KConfig configuration file of the bootloader
get_filename_component(CONF_DIR ${CONF_FILE} DIRECTORY)
# CONF_FILE points to the KConfig configuration files of the bootloader.
foreach (filepath ${CONF_FILE})
file(READ ${filepath} temp_text)
string(FIND "${temp_text}" ${CONFIG_BOOT_SIGNATURE_KEY_FILE} match)
if (${match} GREATER_EQUAL 0)
if (NOT DEFINED CONF_DIR)
get_filename_component(CONF_DIR ${filepath} DIRECTORY)
else()
message(FATAL_ERROR "Signature key file defined in multiple conf files")
endif()
endif()
endforeach()
if(NOT CONFIG_BOOT_SIGNATURE_KEY_FILE STREQUAL "")
if(IS_ABSOLUTE ${CONFIG_BOOT_SIGNATURE_KEY_FILE})
set(KEY_FILE ${CONFIG_BOOT_SIGNATURE_KEY_FILE})
elseif(EXISTS ${CONF_DIR}/${CONFIG_BOOT_SIGNATURE_KEY_FILE})
elseif((DEFINED CONF_DIR) AND
(EXISTS ${CONF_DIR}/${CONFIG_BOOT_SIGNATURE_KEY_FILE}))
set(KEY_FILE ${CONF_DIR}/${CONFIG_BOOT_SIGNATURE_KEY_FILE})
else()
set(KEY_FILE ${MCUBOOT_DIR}/${CONFIG_BOOT_SIGNATURE_KEY_FILE})
endif()
message("MCUBoot bootloader key file: ${KEY_FILE}")
set(GENERATED_PUBKEY ${ZEPHYR_BINARY_DIR}/autogen-pubkey.c)
add_custom_command(
OUTPUT ${GENERATED_PUBKEY}