Skip to content

Commit ef563eb

Browse files
marc-hblgirdwood
authored andcommitted
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>
1 parent ad65544 commit ef563eb

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

scripts/cmake/misc.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ function(get_optimization_flag OUT_VAR)
4040
endif()
4141
endfunction()
4242

43+
# Zephyr duplicate in sof/zephyr/CMakeLists.txt; keep in sync
44+
macro(is_zephyr ret)
45+
if(CONFIG_ZEPHYR_SOF_MODULE)
46+
set(${ret} TRUE)
47+
else()
48+
set(${ret} FALSE)
49+
endif()
50+
endmacro()
51+
4352
# Adds sources to target like target_sources, but assumes that
4453
# paths are relative to subdirectory.
4554
# Works like:

src/init/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22

3+
is_zephyr(it_is)
4+
if(it_is) ### Zephyr ###
5+
6+
7+
zephyr_library_sources(
8+
init.c
9+
ext_manifest.c
10+
)
11+
12+
13+
else() ### Not Zephyr ###
14+
15+
316
add_local_sources(sof init.c)
417

518
add_library(ext_manifest STATIC "")
@@ -21,3 +34,6 @@ sof_append_relative_path_definitions(ext_manifest)
2134

2235
target_link_libraries(ext_manifest sof_options)
2336
target_link_libraries(sof_static_libraries INTERFACE ext_manifest)
37+
38+
39+
endif() # Zephyr

zephyr/CMakeLists.txt

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# This is still WIP - Not fully validated on any platform.
2-
31
# When west is installed, Zephyr's CMake invokes west to list and try to
4-
# compile every Zephyr module that can be found.
2+
# compile every Zephyr module that can be found. See
3+
# sof/zephyr/module.yml and
4+
# https://docs.zephyrproject.org/latest/develop/modules.html
55
if(CONFIG_SOF)
66

77
if(CONFIG_LIBRARY)
@@ -114,6 +114,24 @@ zephyr_include_directories(
114114
# SOC level sources
115115
# Files that are commented may not be needed.
116116

117+
118+
# New, "de-centralized Zephyr" way. Requires "is_zephyr()" conditionals in
119+
# the decentralized CMakeLists.txt files shared with XTOS.
120+
121+
# XTOS duplicate in sof/scripts/misc.cmake; keep in sync
122+
macro(is_zephyr ret)
123+
if(CONFIG_ZEPHYR_SOF_MODULE)
124+
set(${ret} TRUE)
125+
else()
126+
set(${ret} FALSE)
127+
endif()
128+
endmacro()
129+
130+
add_subdirectory(../src/init/ init_unused_install/)
131+
132+
133+
# Old way below: all .c files added by this giant CMake file.
134+
117135
# Intel TGL and CAVS 2.5 platforms
118136
if (CONFIG_SOC_SERIES_INTEL_CAVS_V25)
119137

@@ -372,8 +390,6 @@ zephyr_library_sources(
372390
${SOF_AUDIO_PATH}/pipeline/pipeline-xrun.c
373391

374392
# SOF core infrastructure - runs on top of Zephyr
375-
${SOF_SRC_PATH}/init/init.c
376-
${SOF_SRC_PATH}/init/ext_manifest.c
377393
${SOF_SRC_PATH}/arch/xtensa/drivers/cache_attr.c
378394
${SOF_SRC_PATH}/schedule/zephyr_domain.c
379395
${SOF_SRC_PATH}/schedule/schedule.c

0 commit comments

Comments
 (0)