From 611e46e0cd56656708f824896102e94a3c7b0657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20R=C3=B8nningstad?= Date: Fri, 3 May 2019 16:52:12 +0200 Subject: [PATCH] [nrf toup] cmake: Improve access to other images in multi-image builds. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Global property: - ${IMAGE}PROJECT_BINARY_DIR. - ${IMAGE}KERNEL_NAME. Helper function: - get_image_name() to strip the '_'. Signed-off-by: Øyvind Rønningstad Signed-off-by: Marti Bolivar (cherry picked from commit f84debcfbe019253d8786eca9d649c2499b3856d) (cherry picked from commit 85a6975aad5466490cd3d3a6b13cd91e9c417b9f) (cherry picked from commit 64d246320061fc14295c220f51e454669d3bd29d) --- cmake/app/boilerplate.cmake | 12 ++++++++++++ cmake/extensions.cmake | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/cmake/app/boilerplate.cmake b/cmake/app/boilerplate.cmake index 9116c4cb88e99a..325af04de67528 100644 --- a/cmake/app/boilerplate.cmake +++ b/cmake/app/boilerplate.cmake @@ -87,6 +87,12 @@ set(__build_dir ${CMAKE_CURRENT_BINARY_DIR}/zephyr) set(PROJECT_BINARY_DIR ${__build_dir}) +define_property(GLOBAL PROPERTY ${IMAGE}PROJECT_BINARY_DIR + BRIEF_DOCS "Build directory (PROJECT_BINARY_DIR) for the ${IMAGE} image." + FULL_DOCS "To be used to access e.g. this image's hex file." + ) +set_property(GLOBAL PROPERTY ${IMAGE}PROJECT_BINARY_DIR ${PROJECT_BINARY_DIR}) + add_custom_target(${IMAGE}code_data_relocation_target) # CMake's 'project' concept has proven to not be very useful for Zephyr @@ -543,6 +549,12 @@ set(KERNEL_EXE_NAME ${KERNEL_NAME}.exe) set(KERNEL_STAT_NAME ${KERNEL_NAME}.stat) set(KERNEL_STRIP_NAME ${KERNEL_NAME}.strip) +define_property(GLOBAL PROPERTY ${IMAGE}KERNEL_NAME + BRIEF_DOCS "Name (KERNEL_NAME) for the ${IMAGE} image." + FULL_DOCS "To be used to access e.g. this image's hex file." + ) +set_property(GLOBAL PROPERTY ${IMAGE}KERNEL_NAME ${KERNEL_NAME}) + include(${BOARD_DIR}/board.cmake OPTIONAL) # If we are using a suitable ethernet driver inside qemu, then these options diff --git a/cmake/extensions.cmake b/cmake/extensions.cmake index 83a935de0c2df7..03ebd0ed42f900 100644 --- a/cmake/extensions.cmake +++ b/cmake/extensions.cmake @@ -1064,6 +1064,13 @@ function(import_kconfig prefix kconfig_fragment) endforeach() endfunction() +function(get_image_name image out_var) + string(LENGTH ${image} len) + MATH(EXPR len "${len}-1") + string(SUBSTRING ${image} 0 ${len} ${out_var}) + set(${out_var} ${${out_var}} PARENT_SCOPE) +endfunction() + ######################################################## # 3. CMake-generic extensions ########################################################