From 62dc2ae2652a39dfd938b44b4ce4c278a6603836 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Wed, 2 Apr 2025 12:39:44 +0300 Subject: [PATCH 1/6] 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: https://github.com/thesofproject/sof/issues/8260 Signed-off-by: Kai Vehmanen --- src/lib/CMakeLists.txt | 57 ++++++++++++++++++++++++++---------------- zephyr/CMakeLists.txt | 23 +---------------- 2 files changed, 37 insertions(+), 43 deletions(-) diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index bfcb2613ced5..631731675e5f 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -1,31 +1,46 @@ # SPDX-License-Identifier: BSD-3-Clause +set(common_files notifier.c dma.c dai.c) + if(CONFIG_LIBRARY) - add_local_sources(sof - lib.c - dai.c - dma.c - notifier.c - agent.c) - return() + add_local_sources(sof + lib.c + agent.c + ${common_files} + ) + return() endif() if(CONFIG_HAVE_AGENT) - add_local_sources(sof agent.c) + add_local_sources(sof agent.c) endif() -add_local_sources(sof - lib.c - alloc.c - notifier.c - pm_runtime.c - clk.c - dma.c - dai.c - wait.c - cpu-clk-manager.c -) - if(CONFIG_AMS) -add_local_sources(sof ams.c) + add_local_sources(sof ams.c) +endif() + +if(CONFIG_KCPS_DYNAMIC_CLOCK_CONTROL) + add_local_sources(sof cpu-clk-manager.c) +endif() + +is_zephyr(zephyr) +if(zephyr) ### Zephyr ### + + add_local_sources(sof ${common_files}) + + if(NOT CONFIG_SOF_ZEPHYR_NO_SOF_CLOCK) + add_local_sources(sof clk.c) + endif() + +else() ### XTOS ### + + add_local_sources(sof + ${common_files} + lib.c + alloc.c + pm_runtime.c + clk.c + wait.c + ) + endif() diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 73684f75e42b..442507e7f0c4 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -135,7 +135,6 @@ set(SOF_SRC_PATH "${sof_top_dir}/src") set(SOF_PLATFORM_PATH "${SOF_SRC_PATH}/platform") set(SOF_SAMPLES_PATH "${SOF_SRC_PATH}/samples") -set(SOF_LIB_PATH "${SOF_SRC_PATH}/lib") set(SOF_DRIVERS_PATH "${SOF_SRC_PATH}/drivers") set(SOF_TRACE_PATH "${SOF_SRC_PATH}/trace") @@ -209,6 +208,7 @@ add_subdirectory(../src/audio/ audio_unused_install/) add_subdirectory(../src/debug/ debug_unused_install/) add_subdirectory(../src/init/ init_unused_install/) add_subdirectory(../src/ipc/ ipc_unused_install/) +add_subdirectory(../src/lib/ lib_unused_install/) add_subdirectory(../src/schedule/ schedule_unused_install/) add_subdirectory(test/) @@ -455,11 +455,6 @@ zephyr_include_directories(${SOF_PLATFORM_PATH}/${PLATFORM}/include) # Commented files will be added/removed as integration dictates. zephyr_library_sources( - # SOF library - parts to transition to Zephyr over time - ${SOF_LIB_PATH}/notifier.c - ${SOF_LIB_PATH}/dma.c - ${SOF_LIB_PATH}/dai.c - # SOF core infrastructure - runs on top of Zephyr ${SOF_SRC_PATH}/arch/xtensa/drivers/cache_attr.c @@ -477,14 +472,6 @@ zephyr_library_sources( lib.c ) -if(NOT CONFIG_SOF_ZEPHYR_NO_SOF_CLOCK) - zephyr_library_sources(${SOF_LIB_PATH}/clk.c) -endif() - -zephyr_library_sources_ifdef(CONFIG_KCPS_DYNAMIC_CLOCK_CONTROL - ${SOF_LIB_PATH}/cpu-clk-manager.c -) - # SOF module interface functions add_subdirectory(../src/module module_unused_install/) @@ -542,14 +529,6 @@ zephyr_library_sources_ifdef(CONFIG_MULTICORE ${SOF_SRC_PATH}/idc/idc.c ) -zephyr_library_sources_ifdef(CONFIG_HAVE_AGENT - ${SOF_LIB_PATH}/agent.c -) - -zephyr_library_sources_ifdef(CONFIG_AMS - ${SOF_LIB_PATH}/ams.c -) - zephyr_library_sources_ifdef(CONFIG_DW_DMA ${SOF_DRIVERS_PATH}/dw/dma.c ) From a815a4e27055412c4a580b483c80a1004c98c00b Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Thu, 27 Mar 2025 16:10:31 +0200 Subject: [PATCH 2/6] cmake/zephyr: unify cmake rules for src/library_manager 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/library_manager/ instead. Link: https://github.com/thesofproject/sof/issues/8260 Signed-off-by: Kai Vehmanen --- src/library_manager/CMakeLists.txt | 6 +++++- zephyr/CMakeLists.txt | 12 +----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/library_manager/CMakeLists.txt b/src/library_manager/CMakeLists.txt index 836b46d07fc6..31e2fc4a24be 100644 --- a/src/library_manager/CMakeLists.txt +++ b/src/library_manager/CMakeLists.txt @@ -1,5 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause if(CONFIG_LIBRARY_MANAGER) - add_local_sources(sof lib_manager.c, lib_notifications.c) + add_local_sources(sof lib_manager.c lib_notification.c) + + if (CONFIG_MM_DRV AND CONFIG_LLEXT) + add_local_sources(sof llext_manager.c) + endif() endif() diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 442507e7f0c4..1a999c2dc2f9 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -209,6 +209,7 @@ add_subdirectory(../src/debug/ debug_unused_install/) add_subdirectory(../src/init/ init_unused_install/) add_subdirectory(../src/ipc/ ipc_unused_install/) add_subdirectory(../src/lib/ lib_unused_install/) +add_subdirectory(../src/library_manager/ library_manager_unused_install/) add_subdirectory(../src/schedule/ schedule_unused_install/) add_subdirectory(test/) @@ -496,17 +497,6 @@ zephyr_library_sources_ifdef(CONFIG_SAMPLE_KEYPHRASE ${SOF_SAMPLES_PATH}/audio/detect_test.c ) -zephyr_library_sources_ifdef(CONFIG_LIBRARY_MANAGER - ${SOF_SRC_PATH}/library_manager/lib_manager.c - ${SOF_SRC_PATH}/library_manager/lib_notification.c -) - -if (CONFIG_MM_DRV AND CONFIG_LLEXT) -zephyr_library_sources_ifdef(CONFIG_LIBRARY_MANAGER - ${SOF_SRC_PATH}/library_manager/llext_manager.c -) -endif() - if(CONFIG_SAMPLE_SMART_AMP STREQUAL "m") add_subdirectory(${SOF_SAMPLES_PATH}/audio/smart_amp_test_llext ${PROJECT_BINARY_DIR}/smart_amp_test_llext) From 31a1b4a0f94082c85c0afec712f1b0c6df21e146 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Thu, 27 Mar 2025 16:16:52 +0200 Subject: [PATCH 3/6] cmake/zephyr: unify cmake rules for src/trace 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/trace/ instead. Link: https://github.com/thesofproject/sof/issues/8260 Signed-off-by: Kai Vehmanen --- src/trace/CMakeLists.txt | 4 +++- zephyr/CMakeLists.txt | 6 +----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/trace/CMakeLists.txt b/src/trace/CMakeLists.txt index 75b843876df4..7fab6cf5eaaa 100644 --- a/src/trace/CMakeLists.txt +++ b/src/trace/CMakeLists.txt @@ -1,3 +1,5 @@ # SPDX-License-Identifier: BSD-3-Clause -add_local_sources(sof dma-trace.c trace.c) +if(CONFIG_TRACE) + add_local_sources(sof dma-trace.c trace.c) +endif() diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 1a999c2dc2f9..83e2372a507b 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -211,9 +211,9 @@ add_subdirectory(../src/ipc/ ipc_unused_install/) add_subdirectory(../src/lib/ lib_unused_install/) add_subdirectory(../src/library_manager/ library_manager_unused_install/) add_subdirectory(../src/schedule/ schedule_unused_install/) +add_subdirectory(../src/trace/ trace_unused_install/) add_subdirectory(test/) - # Old way below: all .c files added by this giant CMake file. # Intel TGL and CAVS 2.5 platforms @@ -476,10 +476,6 @@ zephyr_library_sources( # SOF module interface functions add_subdirectory(../src/module module_unused_install/) -zephyr_library_sources_ifdef(CONFIG_TRACE - ${SOF_SRC_PATH}/trace/dma-trace.c - ${SOF_SRC_PATH}/trace/trace.c) - zephyr_library_sources_ifdef(CONFIG_LOG_BACKEND_SOF_PROBE ${SOF_SRC_PATH}/logging/log_backend_probe.c) From 8b5664067679704cb56cef5002dfc01cfb85e8c6 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Thu, 27 Mar 2025 16:21:32 +0200 Subject: [PATCH 4/6] cmake/zephyr: unify cmake rules for src/logging 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/logging/ instead. Link: https://github.com/thesofproject/sof/issues/8260 Signed-off-by: Kai Vehmanen --- src/logging/CMakeLists.txt | 3 +++ zephyr/CMakeLists.txt | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 src/logging/CMakeLists.txt diff --git a/src/logging/CMakeLists.txt b/src/logging/CMakeLists.txt new file mode 100644 index 000000000000..6114062e37c6 --- /dev/null +++ b/src/logging/CMakeLists.txt @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: BSD-3-Clause + +add_local_sources_ifdef(CONFIG_LOG_BACKEND_SOF_PROBE sof log_backend_probe.c) diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 83e2372a507b..2c98fb12afe0 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -210,6 +210,7 @@ add_subdirectory(../src/init/ init_unused_install/) add_subdirectory(../src/ipc/ ipc_unused_install/) add_subdirectory(../src/lib/ lib_unused_install/) add_subdirectory(../src/library_manager/ library_manager_unused_install/) +add_subdirectory(../src/logging/ logging_unused_install/) add_subdirectory(../src/schedule/ schedule_unused_install/) add_subdirectory(../src/trace/ trace_unused_install/) add_subdirectory(test/) @@ -476,9 +477,6 @@ zephyr_library_sources( # SOF module interface functions add_subdirectory(../src/module module_unused_install/) -zephyr_library_sources_ifdef(CONFIG_LOG_BACKEND_SOF_PROBE - ${SOF_SRC_PATH}/logging/log_backend_probe.c) - zephyr_library_sources_ifdef(CONFIG_FAST_GET lib/fast-get.c) # Optional SOF sources - depends on Kconfig - WIP From a3454e911ac6bef6b7ac65f0df2d7256e009048c Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Thu, 27 Mar 2025 18:05:12 +0200 Subject: [PATCH 5/6] cmake/zephyr: unify cmake rules for src/samples 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/samples/ instead. Link: https://github.com/thesofproject/sof/issues/8260 Signed-off-by: Kai Vehmanen --- src/samples/audio/CMakeLists.txt | 28 ++++++++++++++-------------- zephyr/CMakeLists.txt | 22 +--------------------- 2 files changed, 15 insertions(+), 35 deletions(-) diff --git a/src/samples/audio/CMakeLists.txt b/src/samples/audio/CMakeLists.txt index 328070c2bb52..4f6628b51add 100644 --- a/src/samples/audio/CMakeLists.txt +++ b/src/samples/audio/CMakeLists.txt @@ -1,22 +1,22 @@ # SPDX-License-Identifier: BSD-3-Clause -if(CONFIG_SAMPLE_SMART_AMP) - if(CONFIG_IPC_MAJOR_3) - add_local_sources(sof - smart_amp_test_ipc3.c - ) - elseif(CONFIG_IPC_MAJOR_4) - add_local_sources(sof - smart_amp_test_ipc4.c - ) - endif() + +if(CONFIG_IPC_MAJOR_3) + set(ipc_suffix ipc3) +elseif(CONFIG_IPC_MAJOR_4) + set(ipc_suffix ipc4) +endif() + +if(CONFIG_SAMPLE_SMART_AMP STREQUAL "m") + add_subdirectory(smart_amp_test_llext ${PROJECT_BINARY_DIR}/smart_amp_test_llext) + add_dependencies(app smart_amp_test) +elseif(CONFIG_SAMPLE_SMART_AMP) + add_local_sources(sof smart_amp_test_${ipc_suffix}.c) endif() if(CONFIG_SAMPLE_KEYPHRASE) - add_local_sources(sof - detect_test.c - ) + add_local_sources(sof detect_test.c) endif() if(CONFIG_KWD_NN_SAMPLE_KEYPHRASE) - add_local_sources(sof kwd_nn_detect_test.c) + add_local_sources(sof kwd_nn_detect_test.c) endif() diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 2c98fb12afe0..7ea1b6bb10e0 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -134,7 +134,6 @@ cmake_path(SET sof_top_dir NORMALIZE "${CMAKE_CURRENT_SOURCE_DIR}/..") set(SOF_SRC_PATH "${sof_top_dir}/src") set(SOF_PLATFORM_PATH "${SOF_SRC_PATH}/platform") -set(SOF_SAMPLES_PATH "${SOF_SRC_PATH}/samples") set(SOF_DRIVERS_PATH "${SOF_SRC_PATH}/drivers") set(SOF_TRACE_PATH "${SOF_SRC_PATH}/trace") @@ -211,6 +210,7 @@ add_subdirectory(../src/ipc/ ipc_unused_install/) add_subdirectory(../src/lib/ lib_unused_install/) add_subdirectory(../src/library_manager/ library_manager_unused_install/) add_subdirectory(../src/logging/ logging_unused_install/) +add_subdirectory(../src/samples/ samples_unused_install/) add_subdirectory(../src/schedule/ schedule_unused_install/) add_subdirectory(../src/trace/ trace_unused_install/) add_subdirectory(test/) @@ -481,26 +481,6 @@ zephyr_library_sources_ifdef(CONFIG_FAST_GET lib/fast-get.c) # Optional SOF sources - depends on Kconfig - WIP -if(CONFIG_IPC_MAJOR_3) -set(ipc_suffix ipc3) -elseif(CONFIG_IPC_MAJOR_4) -set(ipc_suffix ipc4) -endif() - -zephyr_library_sources_ifdef(CONFIG_SAMPLE_KEYPHRASE - ${SOF_SAMPLES_PATH}/audio/detect_test.c -) - -if(CONFIG_SAMPLE_SMART_AMP STREQUAL "m") - add_subdirectory(${SOF_SAMPLES_PATH}/audio/smart_amp_test_llext - ${PROJECT_BINARY_DIR}/smart_amp_test_llext) - add_dependencies(app smart_amp_test) -elseif(CONFIG_SAMPLE_SMART_AMP) - zephyr_library_sources( - ${SOF_SAMPLES_PATH}/audio/smart_amp_test_${ipc_suffix}.c - ) -endif() - if(CONFIG_PROBE STREQUAL "m") add_subdirectory(${SOF_SRC_PATH}/probe/llext ${PROJECT_BINARY_DIR}/probe_llext) From 940e1c37b0ba464c34fd864e7142e5bef4e99628 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Thu, 27 Mar 2025 18:06:06 +0200 Subject: [PATCH 6/6] cmake/zephyr: unify cmake rules for src/probe 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/probe/ instead. Link: https://github.com/thesofproject/sof/issues/8260 Signed-off-by: Kai Vehmanen --- src/probe/CMakeLists.txt | 7 ++++++- zephyr/CMakeLists.txt | 9 +-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/probe/CMakeLists.txt b/src/probe/CMakeLists.txt index e12e3554b94f..22ad5e24f9a4 100644 --- a/src/probe/CMakeLists.txt +++ b/src/probe/CMakeLists.txt @@ -1,3 +1,8 @@ # SPDX-License-Identifier: BSD-3-Clause -add_local_sources(sof probe.c) +if(CONFIG_PROBE STREQUAL "m") + add_subdirectory(llext ${PROJECT_BINARY_DIR}/probe_llext) + add_dependencies(app probe) +elseif(CONFIG_PROBE) + add_local_sources(sof probe.c) +endif() diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 7ea1b6bb10e0..65ab930578af 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -210,6 +210,7 @@ add_subdirectory(../src/ipc/ ipc_unused_install/) add_subdirectory(../src/lib/ lib_unused_install/) add_subdirectory(../src/library_manager/ library_manager_unused_install/) add_subdirectory(../src/logging/ logging_unused_install/) +add_subdirectory(../src/probe/ probes_unused_install/) add_subdirectory(../src/samples/ samples_unused_install/) add_subdirectory(../src/schedule/ schedule_unused_install/) add_subdirectory(../src/trace/ trace_unused_install/) @@ -481,14 +482,6 @@ zephyr_library_sources_ifdef(CONFIG_FAST_GET lib/fast-get.c) # Optional SOF sources - depends on Kconfig - WIP -if(CONFIG_PROBE STREQUAL "m") - add_subdirectory(${SOF_SRC_PATH}/probe/llext - ${PROJECT_BINARY_DIR}/probe_llext) - add_dependencies(app probe) -elseif(CONFIG_PROBE) - zephyr_library_sources(${SOF_SRC_PATH}/probe/probe.c) -endif() - zephyr_library_sources_ifdef(CONFIG_MULTICORE ${SOF_SRC_PATH}/idc/idc.c )