cmake: defer the rimage build until it's actually needed.

This is motivated by the zephyr.elf build that does not need rimage at
all.

Also build smex later, only when it's needed.

After building and deleting the rimage/ clone, a plain SOF clean +
RE-build now fails much later: it now fails AFTER successfully building
the sof binary, only when it tries to build either bootloader,
boot_module or base_module that actually need rimage:

[ 87%] Performing configure step for 'rimage_ep'
CMake Error: The source directory "/home/SOF/sof/rimage" does not appear
to contain CMakeLists.txt.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
This commit is contained in:
Marc Herbert 2021-08-25 18:06:33 +02:00 committed by Daniel Baluta
parent 39d5365fc7
commit 177d9bd073
2 changed files with 14 additions and 6 deletions

View File

@ -37,8 +37,11 @@ if(GIT_FOUND AND EXISTS "${SOF_ROOT_SOURCE_DIRECTORY}/.git")
# manually initializing rimage and _not_ some other
# submodule. In that case you get the warning above.
message(STATUS "Git submodules update")
# TODO: get rid of this CMake configuration time
# hack. Downloading, configuring and building should always be
# kept separate; that's CI 101.
message(STATUS "Git submodules update HACK")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --merge --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
@ -50,8 +53,3 @@ if(GIT_FOUND AND EXISTS "${SOF_ROOT_SOURCE_DIRECTORY}/.git")
endif() # rimage/CMakeLists.txt
endif() # .git/
# rimage is not optional, see "git grep include.*rimage"
if(NOT EXISTS "${RIMAGE_CMAKE}")
message(FATAL_ERROR "rimage not found! Please update git submodules and try again.")
endif()

View File

@ -256,6 +256,14 @@ add_custom_target(bin_extras)
if(build_bootloader)
add_executable(bootloader "")
add_dependencies(bootloader rimage_ep)
# This line should be next to the boot_module
# (resp. base_module) definitions but there are too many of
# them; one per platform. So do it only once here instead.
add_dependencies(boot_module rimage_ep)
add_dependencies(base_module rimage_ep)
target_link_libraries(bootloader PRIVATE sof_options)
add_local_sources(bootloader xtos/_vectors.S ${PROJECT_SOURCE_DIR}/src/platform/${family_path}/boot_entry.S ${PROJECT_SOURCE_DIR}/src/platform/${family_path}/boot_loader.c)
target_link_libraries(bootloader PRIVATE reset)
@ -351,6 +359,7 @@ ExternalProject_Add(smex_ep
SOURCE_DIR "${PROJECT_SOURCE_DIR}/smex"
PREFIX "${PROJECT_BINARY_DIR}/smex_ep"
BINARY_DIR "${PROJECT_BINARY_DIR}/smex_ep/build"
EXCLUDE_FROM_ALL TRUE
BUILD_ALWAYS 1
INSTALL_COMMAND ""
)
@ -372,6 +381,7 @@ ExternalProject_Add(rimage_ep
SOURCE_DIR "${PROJECT_SOURCE_DIR}/rimage"
PREFIX "${PROJECT_BINARY_DIR}/rimage_ep"
BINARY_DIR "${PROJECT_BINARY_DIR}/rimage_ep/build"
EXCLUDE_FROM_ALL TRUE
BUILD_ALWAYS 1
INSTALL_COMMAND ""
)