Skip to content

Commit 71d4aa9

Browse files
committed
cmake/zephyr: unify cmake rules for src/lib
Adding all source files in a single, giant zephyr/CMakeLists.txt is inconvenient and does not scale. Modify Zephyr rules to use definitions in src/lib/ instead. Link: #8260 Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent 70110f3 commit 71d4aa9

2 files changed

Lines changed: 37 additions & 43 deletions

File tree

src/lib/CMakeLists.txt

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,46 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22

3+
set(common_files notifier.c dma.c dai.c)
4+
35
if(CONFIG_LIBRARY)
4-
add_local_sources(sof
5-
lib.c
6-
dai.c
7-
dma.c
8-
notifier.c
9-
agent.c)
10-
return()
6+
add_local_sources(sof
7+
lib.c
8+
agent.c
9+
${common_files}
10+
)
11+
return()
1112
endif()
1213

1314
if(CONFIG_HAVE_AGENT)
14-
add_local_sources(sof agent.c)
15+
add_local_sources(sof agent.c)
1516
endif()
1617

17-
add_local_sources(sof
18-
lib.c
19-
alloc.c
20-
notifier.c
21-
pm_runtime.c
22-
clk.c
23-
dma.c
24-
dai.c
25-
wait.c
26-
cpu-clk-manager.c
27-
)
28-
2918
if(CONFIG_AMS)
30-
add_local_sources(sof ams.c)
19+
add_local_sources(sof ams.c)
20+
endif()
21+
22+
if(CONFIG_KCPS_DYNAMIC_CLOCK_CONTROL)
23+
add_local_sources(sof cpu-clk-manager.c)
24+
endif()
25+
26+
is_zephyr(zephyr)
27+
if(zephyr) ### Zephyr ###
28+
29+
add_local_sources(sof ${common_files})
30+
31+
if(NOT CONFIG_SOF_ZEPHYR_NO_SOF_CLOCK)
32+
add_local_sources(sof clk.c)
33+
endif()
34+
35+
else() ### XTOS ###
36+
37+
add_local_sources(sof
38+
${common_files}
39+
lib.c
40+
alloc.c
41+
pm_runtime.c
42+
clk.c
43+
wait.c
44+
)
45+
3146
endif()

zephyr/CMakeLists.txt

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ set(SOF_SRC_PATH "${sof_top_dir}/src")
135135

136136
set(SOF_PLATFORM_PATH "${SOF_SRC_PATH}/platform")
137137
set(SOF_SAMPLES_PATH "${SOF_SRC_PATH}/samples")
138-
set(SOF_LIB_PATH "${SOF_SRC_PATH}/lib")
139138
set(SOF_DRIVERS_PATH "${SOF_SRC_PATH}/drivers")
140139
set(SOF_TRACE_PATH "${SOF_SRC_PATH}/trace")
141140

@@ -209,6 +208,7 @@ add_subdirectory(../src/audio/ audio_unused_install/)
209208
add_subdirectory(../src/debug/ debug_unused_install/)
210209
add_subdirectory(../src/init/ init_unused_install/)
211210
add_subdirectory(../src/ipc/ ipc_unused_install/)
211+
add_subdirectory(../src/lib/ lib_unused_install/)
212212
add_subdirectory(../src/schedule/ schedule_unused_install/)
213213
add_subdirectory(test/)
214214

@@ -455,11 +455,6 @@ zephyr_include_directories(${SOF_PLATFORM_PATH}/${PLATFORM}/include)
455455
# Commented files will be added/removed as integration dictates.
456456
zephyr_library_sources(
457457

458-
# SOF library - parts to transition to Zephyr over time
459-
${SOF_LIB_PATH}/notifier.c
460-
${SOF_LIB_PATH}/dma.c
461-
${SOF_LIB_PATH}/dai.c
462-
463458
# SOF core infrastructure - runs on top of Zephyr
464459
${SOF_SRC_PATH}/arch/xtensa/drivers/cache_attr.c
465460

@@ -477,14 +472,6 @@ zephyr_library_sources(
477472
lib.c
478473
)
479474

480-
if(NOT CONFIG_SOF_ZEPHYR_NO_SOF_CLOCK)
481-
zephyr_library_sources(${SOF_LIB_PATH}/clk.c)
482-
endif()
483-
484-
zephyr_library_sources_ifdef(CONFIG_KCPS_DYNAMIC_CLOCK_CONTROL
485-
${SOF_LIB_PATH}/cpu-clk-manager.c
486-
)
487-
488475
# SOF module interface functions
489476
add_subdirectory(../src/module module_unused_install/)
490477

@@ -542,14 +529,6 @@ zephyr_library_sources_ifdef(CONFIG_MULTICORE
542529
${SOF_SRC_PATH}/idc/idc.c
543530
)
544531

545-
zephyr_library_sources_ifdef(CONFIG_HAVE_AGENT
546-
${SOF_LIB_PATH}/agent.c
547-
)
548-
549-
zephyr_library_sources_ifdef(CONFIG_AMS
550-
${SOF_LIB_PATH}/ams.c
551-
)
552-
553532
zephyr_library_sources_ifdef(CONFIG_DW_DMA
554533
${SOF_DRIVERS_PATH}/dw/dma.c
555534
)

0 commit comments

Comments
 (0)