Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT IGNORE] cmake math move #8495

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions scripts/cmake/misc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ macro(is_zephyr ret)
endif()
endmacro()

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:
Expand Down
52 changes: 24 additions & 28 deletions src/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,51 @@ if(BUILD_LIBRARY)
return()
endif()

is_zephyr(it_is_zephyr)

add_local_sources(sof numbers.c)

if(CONFIG_CORDIC_FIXED)
if(CONFIG_CORDIC_FIXED OR it_is_zephyr)
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)
if(CONFIG_MATH_DECIBELS OR it_is_zephyr)
add_local_sources(sof decibels.c)
endif()

if(CONFIG_NATURAL_LOGARITHM_FIXED)
add_local_sources(sof log_e.c)
endif()
# Never used with Zephyr.
if(NOT it_is_zephyr)
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)
add_local_sources_ifdef(CONFIG_BINARY_LOGARITHM_FIXED sof base2log.c)
endif()

if(CONFIG_MATH_FIR)
add_local_sources(sof fir_generic.c fir_hifi2ep.c fir_hifi3.c)
if(it_is_zephyr)
add_local_sources_ifdef(CONFIG_COMP_FIR sof fir_generic.c fir_hifi2ep.c fir_hifi3.c)
else()
add_local_sources_ifdef(CONFIG_MATH_FIR sof fir_generic.c fir_hifi2ep.c fir_hifi3.c)
endif()

if(CONFIG_MATH_FFT)
# Never used with Zephyr.
if(CONFIG_MATH_FFT AND NOT it_is_zephyr)
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(NOT it_is_zephyr)
if(CONFIG_MATH_WINDOW)
add_local_sources(sof window.c)
endif()
Expand All @@ -70,3 +65,4 @@ endif()
if(CONFIG_MATH_DCT)
add_local_sources(sof dct.c)
endif()
endif() # not Zephyr
8 changes: 2 additions & 6 deletions src/math/auditory/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 2 additions & 6 deletions src/math/fft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
48 changes: 17 additions & 31 deletions zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ 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
Expand Down Expand Up @@ -127,8 +127,23 @@ macro(is_zephyr ret)
endif()
endmacro()

# Wrappers for re-using existing, XTOS CMake files. Do NOT use in Zephyr-specific 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/)
add_subdirectory(../src/math/ math_unused_install/)



Expand Down Expand Up @@ -349,11 +364,6 @@ zephyr_include_directories(${SOF_PLATFORM_PATH}/${PLATFORM}/include)
# Commented files will be added/removed as integration dictates.
zephyr_library_sources(

# SOF math utilities
${SOF_MATH_PATH}/decibels.c
${SOF_MATH_PATH}/numbers.c
${SOF_MATH_PATH}/trig.c

# SOF library - parts to transition to Zephyr over time
${SOF_LIB_PATH}/clk.c
${SOF_LIB_PATH}/notifier.c
Expand Down Expand Up @@ -441,9 +451,6 @@ zephyr_library_sources_ifdef(CONFIG_COMP_FIR
${SOF_AUDIO_PATH}/eq_fir/eq_fir_hifi2ep.c
${SOF_AUDIO_PATH}/eq_fir/eq_fir_generic.c
${SOF_AUDIO_PATH}/eq_fir/eq_fir.c
${SOF_MATH_PATH}/fir_generic.c
${SOF_MATH_PATH}/fir_hifi2ep.c
${SOF_MATH_PATH}/fir_hifi3.c
)

if(CONFIG_IPC_MAJOR_3)
Expand All @@ -468,18 +475,6 @@ elseif(CONFIG_IPC_MAJOR_4)
)
endif()

zephyr_library_sources_ifdef(CONFIG_MATH_IIR_DF1
${SOF_MATH_PATH}/iir_df1_generic.c
${SOF_MATH_PATH}/iir_df1_hifi3.c
${SOF_MATH_PATH}/iir_df1.c
)

zephyr_library_sources_ifdef(CONFIG_MATH_IIR_DF2T
${SOF_MATH_PATH}/iir_df2t_generic.c
${SOF_MATH_PATH}/iir_df2t_hifi3.c
${SOF_MATH_PATH}/iir_df2t.c
)

zephyr_library_sources_ifdef(CONFIG_COMP_ASRC
${SOF_AUDIO_PATH}/asrc/asrc.c
${SOF_AUDIO_PATH}/asrc/asrc_farrow_hifi3.c
Expand Down Expand Up @@ -741,15 +736,6 @@ zephyr_library_sources_ifdef(CONFIG_COMP_TDFB
${SOF_AUDIO_PATH}/tdfb/tdfb_hifi3.c
)

zephyr_library_sources_ifdef(CONFIG_SQRT_FIXED
${SOF_MATH_PATH}/sqrt_int16.c
)

zephyr_library_sources_ifdef(CONFIG_MATH_EXP
${SOF_MATH_PATH}/exp_fcn.c
${SOF_MATH_PATH}/exp_fcn_hifi.c
)

zephyr_library_sources_ifdef(CONFIG_COMP_UP_DOWN_MIXER
${SOF_AUDIO_PATH}/up_down_mixer/up_down_mixer.c
${SOF_AUDIO_PATH}/up_down_mixer/up_down_mixer_hifi3.c
Expand Down