cmake/zephyr: decentralize src/init/

Adding all source files in a single, giant zephyr/CMakeLists.txt is
inconvenient and does not scale.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
This commit is contained in:
Marc Herbert 2023-10-31 06:36:58 +00:00 committed by Liam Girdwood
parent ad655446fd
commit ef563ebfe3
3 changed files with 46 additions and 5 deletions

View File

@ -40,6 +40,15 @@ function(get_optimization_flag OUT_VAR)
endif()
endfunction()
# Zephyr duplicate in sof/zephyr/CMakeLists.txt; keep in sync
macro(is_zephyr ret)
if(CONFIG_ZEPHYR_SOF_MODULE)
set(${ret} TRUE)
else()
set(${ret} FALSE)
endif()
endmacro()
# Adds sources to target like target_sources, but assumes that
# paths are relative to subdirectory.
# Works like:

View File

@ -1,5 +1,18 @@
# SPDX-License-Identifier: BSD-3-Clause
is_zephyr(it_is)
if(it_is) ### Zephyr ###
zephyr_library_sources(
init.c
ext_manifest.c
)
else() ### Not Zephyr ###
add_local_sources(sof init.c)
add_library(ext_manifest STATIC "")
@ -21,3 +34,6 @@ sof_append_relative_path_definitions(ext_manifest)
target_link_libraries(ext_manifest sof_options)
target_link_libraries(sof_static_libraries INTERFACE ext_manifest)
endif() # Zephyr

View File

@ -1,7 +1,7 @@
# This is still WIP - Not fully validated on any platform.
# When west is installed, Zephyr's CMake invokes west to list and try to
# compile every Zephyr module that can be found.
# compile every Zephyr module that can be found. See
# sof/zephyr/module.yml and
# https://docs.zephyrproject.org/latest/develop/modules.html
if(CONFIG_SOF)
if(CONFIG_LIBRARY)
@ -114,6 +114,24 @@ zephyr_include_directories(
# SOC level sources
# Files that are commented may not be needed.
# New, "de-centralized Zephyr" way. Requires "is_zephyr()" conditionals in
# the decentralized CMakeLists.txt files shared with XTOS.
# XTOS duplicate in sof/scripts/misc.cmake; keep in sync
macro(is_zephyr ret)
if(CONFIG_ZEPHYR_SOF_MODULE)
set(${ret} TRUE)
else()
set(${ret} FALSE)
endif()
endmacro()
add_subdirectory(../src/init/ init_unused_install/)
# Old way below: all .c files added by this giant CMake file.
# Intel TGL and CAVS 2.5 platforms
if (CONFIG_SOC_SERIES_INTEL_CAVS_V25)
@ -372,8 +390,6 @@ zephyr_library_sources(
${SOF_AUDIO_PATH}/pipeline/pipeline-xrun.c
# SOF core infrastructure - runs on top of Zephyr
${SOF_SRC_PATH}/init/init.c
${SOF_SRC_PATH}/init/ext_manifest.c
${SOF_SRC_PATH}/arch/xtensa/drivers/cache_attr.c
${SOF_SRC_PATH}/schedule/zephyr_domain.c
${SOF_SRC_PATH}/schedule/schedule.c