From 9d7f57241271bff2a06061a62c872904ab23260a Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Fri, 17 Nov 2023 19:13:22 +0000 Subject: [PATCH 1/4] zephyr/cmake: remove now unused SOF_IPC_PATH variable Fixes commit 1bd9e0d2c7a8 ("cmake/zephyr: decentralize src/ipc/") Signed-off-by: Marc Herbert --- zephyr/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index f9e1f3c40e00..8ea073b878a5 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -48,16 +48,17 @@ zephyr_interface_library_named(SOF) # SOF source paths. 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_AUDIO_PATH "${SOF_SRC_PATH}/audio") set(SOF_AUDIO_MODULES_PATH "${SOF_SRC_PATH}/audio/module_adapter/module") 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_IPC_PATH "${SOF_SRC_PATH}/ipc") set(SOF_DEBUG_PATH "${SOF_SRC_PATH}/debug") set(SOF_MATH_PATH "${SOF_SRC_PATH}/math") set(SOF_TRACE_PATH "${SOF_SRC_PATH}/trace") + set(RIMAGE_TOP ${sof_top_dir}/tools/rimage) # Save path to rimage configuration files in cmake cache for later use by From 17a6459017a8e018aa3aa03bd37ae86c13ac39f5 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Fri, 17 Nov 2023 20:50:23 +0000 Subject: [PATCH 2/4] cmake: a few new add_local_sources[_ifdef]() compatibility macros For reducing CMake duplication and centralization, see #8260 Not used yet. Signed-off-by: Marc Herbert --- scripts/cmake/misc.cmake | 9 +++++++++ zephyr/CMakeLists.txt | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/scripts/cmake/misc.cmake b/scripts/cmake/misc.cmake index ee794780cd09..77ae05ee2754 100644 --- a/scripts/cmake/misc.cmake +++ b/scripts/cmake/misc.cmake @@ -49,6 +49,15 @@ macro(is_zephyr ret) endif() endmacro() +# This macro +# - saves a LOT of repetition, and +# - mimics Zephyr, which helps with compatibility. +macro(add_local_sources_ifdef condition target) + if(${condition}) + add_local_sources(${target} ${ARGN}) + endif() +endmacro() + # Adds sources to target like target_sources, but assumes that # paths are relative to subdirectory. # Works like: diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 8ea073b878a5..a859282102c6 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -128,6 +128,22 @@ macro(is_zephyr ret) endif() endmacro() +# Wrappers for compatibility and re-use of existing, XTOS CMake files. +# Do NOT use these macros in this file or in any other Zephyr-specific +# CMake code. +macro(add_local_sources target) + if (NOT "${target}" STREQUAL "sof") + message(FATAL_ERROR "add_local_sources() target is not 'sof'") + endif() + zephyr_library_sources(${ARGN}) +endmacro() +macro(add_local_sources_ifdef condition target) + if (NOT "${target}" STREQUAL "sof") + message(FATAL_ERROR "add_local_sources_ifdef() target is not 'sof'") + endif() + zephyr_library_sources_ifdef(${condition} ${ARGN}) +endmacro() + add_subdirectory(../src/init/ init_unused_install/) add_subdirectory(../src/ipc/ ipc_unused_install/) From 2a3aa23ab21c0faee0802d08778671c932095aa4 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Tue, 28 Nov 2023 00:47:49 +0000 Subject: [PATCH 3/4] module/cmake: simplify thanks to the new add_local_sources() macro Leverage the previous commit. Signed-off-by: Marc Herbert --- src/module/audio/CMakeLists.txt | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/module/audio/CMakeLists.txt b/src/module/audio/CMakeLists.txt index 2d805aa68929..06407bab7520 100644 --- a/src/module/audio/CMakeLists.txt +++ b/src/module/audio/CMakeLists.txt @@ -1,14 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause -is_zephyr(it_is) -if(it_is) ### Zephyr ### - zephyr_library_sources( - source_api.c - sink_api.c - ) -else() ### Not Zephyr ### - add_local_sources(sof - source_api.c - sink_api.c - ) -endif() # Zephyr +add_local_sources(sof + source_api.c + sink_api.c +) From 812f476a607fedd4f82553569d6a0dd55b9c109f Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Fri, 17 Nov 2023 22:23:59 +0000 Subject: [PATCH 4/4] math/cmake: use new macro add_local_sources_ifdef() This makes the code shorter and will help with #8260 Zero functional change. Do not use it when Zephyr use is not conditional. Signed-off-by: Marc Herbert --- src/math/CMakeLists.txt | 38 +++++++++----------------------- src/math/auditory/CMakeLists.txt | 8 ++----- src/math/fft/CMakeLists.txt | 8 ++----- 3 files changed, 15 insertions(+), 39 deletions(-) diff --git a/src/math/CMakeLists.txt b/src/math/CMakeLists.txt index 899810544864..afbc4718fa59 100644 --- a/src/math/CMakeLists.txt +++ b/src/math/CMakeLists.txt @@ -11,49 +11,33 @@ if(CONFIG_CORDIC_FIXED) add_local_sources(sof trig.c) endif() -if(CONFIG_SQRT_FIXED) - add_local_sources(sof sqrt_int16.c) -endif() +add_local_sources_ifdef(CONFIG_SQRT_FIXED sof sqrt_int16.c) -if(CONFIG_MATH_EXP) - add_local_sources(sof exp_fcn.c exp_fcn_hifi.c) -endif() +add_local_sources_ifdef(CONFIG_MATH_EXP sof exp_fcn.c exp_fcn_hifi.c) if(CONFIG_MATH_DECIBELS) add_local_sources(sof decibels.c) endif() -if(CONFIG_NATURAL_LOGARITHM_FIXED) - add_local_sources(sof log_e.c) -endif() +add_local_sources_ifdef(CONFIG_NATURAL_LOGARITHM_FIXED sof log_e.c) -if(CONFIG_COMMON_LOGARITHM_FIXED) - add_local_sources(sof log_10.c) -endif() +add_local_sources_ifdef(CONFIG_COMMON_LOGARITHM_FIXED sof log_10.c) -if(CONFIG_POWER_FIXED) - add_local_sources(sof power.c) -endif() +add_local_sources_ifdef(CONFIG_POWER_FIXED sof power.c) -if(CONFIG_BINARY_LOGARITHM_FIXED) - add_local_sources(sof base2log.c) -endif() +add_local_sources_ifdef(CONFIG_BINARY_LOGARITHM_FIXED sof base2log.c) -if(CONFIG_MATH_FIR) - add_local_sources(sof fir_generic.c fir_hifi2ep.c fir_hifi3.c) -endif() +add_local_sources_ifdef(CONFIG_MATH_FIR sof fir_generic.c fir_hifi2ep.c fir_hifi3.c) if(CONFIG_MATH_FFT) add_subdirectory(fft) endif() -if(CONFIG_MATH_IIR_DF2T) - add_local_sources(sof iir_df2t_generic.c iir_df2t_hifi3.c iir_df2t.c) -endif() +add_local_sources_ifdef(CONFIG_MATH_IIR_DF2T sof + iir_df2t_generic.c iir_df2t_hifi3.c iir_df2t.c) -if(CONFIG_MATH_IIR_DF1) - add_local_sources(sof iir_df1_generic.c iir_df1_hifi3.c iir_df1.c) -endif() +add_local_sources_ifdef(CONFIG_MATH_IIR_DF1 sof + iir_df1_generic.c iir_df1_hifi3.c iir_df1.c) if(CONFIG_MATH_WINDOW) add_local_sources(sof window.c) diff --git a/src/math/auditory/CMakeLists.txt b/src/math/auditory/CMakeLists.txt index c94aed430040..2983e1eb4483 100644 --- a/src/math/auditory/CMakeLists.txt +++ b/src/math/auditory/CMakeLists.txt @@ -2,10 +2,6 @@ add_local_sources(sof auditory.c) -if(CONFIG_MATH_16BIT_MEL_FILTERBANK) - add_local_sources(sof mel_filterbank_16.c) -endif() +add_local_sources_ifdef(CONFIG_MATH_16BIT_MEL_FILTERBANK sof mel_filterbank_16.c) -if(CONFIG_MATH_32BIT_MEL_FILTERBANK) - add_local_sources(sof mel_filterbank_32.c) -endif() +add_local_sources_ifdef(CONFIG_MATH_32BIT_MEL_FILTERBANK sof mel_filterbank_32.c) diff --git a/src/math/fft/CMakeLists.txt b/src/math/fft/CMakeLists.txt index e196f54fa0e9..8d422b93c5b1 100644 --- a/src/math/fft/CMakeLists.txt +++ b/src/math/fft/CMakeLists.txt @@ -2,10 +2,6 @@ add_local_sources(sof fft_common.c) -if(CONFIG_MATH_16BIT_FFT) - add_local_sources(sof fft_16.c fft_16_hifi3.c) -endif() +add_local_sources_ifdef(CONFIG_MATH_16BIT_FFT sof fft_16.c fft_16_hifi3.c) -if(CONFIG_MATH_32BIT_FFT) - add_local_sources(sof fft_32.c fft_32_hifi3.c) -endif() +add_local_sources_ifdef(CONFIG_MATH_32BIT_FFT sof fft_32.c fft_32_hifi3.c)