diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 5e8db8263cdc..a8517951201a 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -108,7 +108,7 @@ jobs: - name: apt get run: sudo apt-get update && - sudo apt-get -y install valgrind alsa-utils libasound2-dev + sudo apt-get -y install valgrind alsa-utils libasound2-dev ninja-build octave octave-io octave-signal # testbench needs some topologies. diff --git a/scripts/build-tools.sh b/scripts/build-tools.sh index 496ca4c2d7cc..3118cd55f40a 100755 --- a/scripts/build-tools.sh +++ b/scripts/build-tools.sh @@ -10,10 +10,10 @@ SOF_TOP=$(cd "$(dirname "$0")/.." && pwd) print_usage() { cat < ${output_name}.conf + # -p to pre-process Topology2.0 conf file COMMAND ALSA_CONFIG_DIR=${CMAKE_SOURCE_DIR}/topology/topology2 alsatplg \$\${VERBOSE:+-v 1} - -I ${include_path} -D "'${defines}'" -p -c ${input_file} -o ${output_file} + -I ${include_path} -D "'${defines}'" -p -c ${output_name}.conf -o ${output_name}.tplg USES_TERMINAL ) endmacro() diff --git a/tools/topology/topology1/CMakeLists.txt b/tools/topology/topology1/CMakeLists.txt index 3de145bd9078..661bc22ac864 100644 --- a/tools/topology/topology1/CMakeLists.txt +++ b/tools/topology/topology1/CMakeLists.txt @@ -9,8 +9,12 @@ file(GLOB TPLG_DEPS ) add_custom_target(abi_v1 + DEPENDS abi.h +) +add_custom_command(OUTPUT abi.h COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/get_abi.sh ${SOF_ROOT_SOURCE_DIRECTORY} - DEPENDS ${TPLG_DEPS} + DEPENDS ${TPLG_DEPS} ${SOF_ROOT_SOURCE_DIRECTORY}/src/include/kernel/abi.h + # get_abi.h generates (a smaller) abi.h in the current directory WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} VERBATIM USES_TERMINAL @@ -316,6 +320,8 @@ foreach(tplg ${TPLGS}) endforeach() endif() + # m4 + # TODO: reduce duplication with subdirectories add_custom_command( OUTPUT production/${output}.conf COMMAND m4 --fatal-warnings @@ -329,11 +335,16 @@ foreach(tplg ${TPLGS}) ${CMAKE_CURRENT_SOURCE_DIR}/${input}.m4 > production/${output}.conf MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${input}.m4 - DEPENDS abi_v1 + # The 'abi.h' file is the real dependency that triggers + # a rebuild. 'abi_v1' is the target that avoids a race + # to rebuild abi.h. See the CMake FAQ or (better) Sam + # Thursfield's blog about custom targets. + DEPENDS abi_v1 ${CMAKE_CURRENT_BINARY_DIR}/abi.h VERBATIM USES_TERMINAL ) + # alsatplg add_alsatplg_command(production/${output}.conf production/${output}.tplg) add_custom_target(topology1_${output} DEPENDS production/${output}.tplg) diff --git a/tools/topology/topology1/development/CMakeLists.txt b/tools/topology/topology1/development/CMakeLists.txt index 973703177b7c..be0faa223a91 100644 --- a/tools/topology/topology1/development/CMakeLists.txt +++ b/tools/topology/topology1/development/CMakeLists.txt @@ -89,15 +89,15 @@ foreach(tplg ${TPLGS}) ${CMAKE_CURRENT_SOURCE_DIR}/../common/abi.m4 ${CMAKE_CURRENT_SOURCE_DIR}/${input}.m4 > ${output}.conf - DEPENDS abi_v1 + DEPENDS abi_v1 ${CMAKE_BINARY_DIR}/topology/topology1/abi.h VERBATIM USES_TERMINAL ) add_alsatplg_command(${output}.conf ${output}.tplg) - add_custom_target(topology_${output} DEPENDS ${output}.tplg) - add_dependencies(dev_topologies1 topology_${output}) + add_custom_target(dev_topology_${output} DEPENDS ${output}.tplg) + add_dependencies(dev_topologies1 dev_topology_${output}) endforeach() # Duplicate of above to handle topologies in parent directory @@ -125,7 +125,7 @@ foreach(tplg ${TPLGS_UP}) ${CMAKE_CURRENT_SOURCE_DIR}/../common/abi.m4 ${CMAKE_CURRENT_SOURCE_DIR}/../${input}.m4 > ${output}.conf - DEPENDS abi_v1 + DEPENDS abi_v1 ${CMAKE_BINARY_DIR}/topology/topology1/abi.h VERBATIM USES_TERMINAL ) diff --git a/tools/topology/topology1/dsp_enhancement/CMakeLists.txt b/tools/topology/topology1/dsp_enhancement/CMakeLists.txt index 9399b48e5c21..bdb655dd7800 100644 --- a/tools/topology/topology1/dsp_enhancement/CMakeLists.txt +++ b/tools/topology/topology1/dsp_enhancement/CMakeLists.txt @@ -34,13 +34,13 @@ foreach(tplg ${TPLGS_UP}) ${CMAKE_CURRENT_SOURCE_DIR}/../common/abi.m4 ${CMAKE_CURRENT_SOURCE_DIR}/../${input}.m4 > ${output}.conf - DEPENDS abi_v1 + DEPENDS abi_v1 ${CMAKE_BINARY_DIR}/topology/topology1/abi.h VERBATIM USES_TERMINAL ) add_alsatplg_command(${output}.conf ${output}.tplg) - add_custom_target(topology_${output} DEPENDS ${output}.tplg) - add_dependencies(dsp_topologies1 topology_${output}) + add_custom_target(dsp_topology_${output} DEPENDS ${output}.tplg) + add_dependencies(dsp_topologies1 dsp_topology_${output}) endforeach() diff --git a/tools/topology/topology1/kernel_dependent/v5.19/CMakeLists.txt b/tools/topology/topology1/kernel_dependent/v5.19/CMakeLists.txt index 89154fb9c16f..c141eeceb88f 100644 --- a/tools/topology/topology1/kernel_dependent/v5.19/CMakeLists.txt +++ b/tools/topology/topology1/kernel_dependent/v5.19/CMakeLists.txt @@ -73,12 +73,12 @@ foreach(tplg ${TPLGS_UP}) ${CMAKE_CURRENT_SOURCE_DIR}/../../common/abi.m4 ${CMAKE_CURRENT_SOURCE_DIR}/../../${input}.m4 > ${output}.conf - DEPENDS abi_v1 + DEPENDS abi_v1 ${CMAKE_BINARY_DIR}/topology/topology1/abi.h VERBATIM USES_TERMINAL ) add_alsatplg_command(${output}.conf ${output}.tplg) - add_custom_target(topology_${output} DEPENDS ${output}.tplg) - add_dependencies(kernel_dependent_v5_19_topologies1 topology_${output}) + add_custom_target(k519_topology_${output} DEPENDS ${output}.tplg) + add_dependencies(kernel_dependent_v5_19_topologies1 k519_topology_${output}) endforeach() diff --git a/tools/topology/topology2/cavs/CMakeLists.txt b/tools/topology/topology2/cavs/CMakeLists.txt index ee60915e5cf9..61ae8379bc92 100644 --- a/tools/topology/topology2/cavs/CMakeLists.txt +++ b/tools/topology/topology2/cavs/CMakeLists.txt @@ -46,9 +46,12 @@ PREPROCESS_PLUGINS=nhlt,NHLT_BIN=nhlt-ace-mtl-nocodec.bin" ) # generate ABI for IPC4 -execute_process( - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../get_abi.sh ${SOF_ROOT_SOURCE_DIRECTORY} "ipc4" - OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/abi.conf +add_custom_command(OUTPUT abi.conf + COMMAND > abi.conf ${CMAKE_CURRENT_SOURCE_DIR}/../get_abi.sh ${SOF_ROOT_SOURCE_DIRECTORY} "ipc4" + DEPENDS ${SOF_ROOT_SOURCE_DIRECTORY}/src/include/kernel/abi.h +) +add_custom_target(cavs_abi_target + DEPENDS abi.conf ) add_custom_target(topology2_cavs) @@ -68,15 +71,9 @@ foreach(tplg ${TPLGS}) list(GET tplg ${last_index} defines) endif() - # copy ABI and input conf file contents - # - # BUG: move this from CMake configuration time to build time to - # fix incremental builds - configure_file(${CMAKE_CURRENT_BINARY_DIR}/abi.conf ${CMAKE_CURRENT_BINARY_DIR}/${output}.conf) - file(READ ${CMAKE_CURRENT_SOURCE_DIR}/${input}.conf CONTENTS) - file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/${output}.conf "${CONTENTS}") - - add_alsatplg2_command("${output}.conf" "${output}.tplg" "${CMAKE_CURRENT_SOURCE_DIR}" "${defines}") + add_alsatplg2_command("${CMAKE_CURRENT_BINARY_DIR}/abi.conf" cavs_abi_target + "${CMAKE_CURRENT_SOURCE_DIR}/${input}" "${output}" + "${CMAKE_CURRENT_SOURCE_DIR}" "${defines}") add_custom_target(topology2_${output} DEPENDS ${output}.tplg) add_dependencies(topology2_cavs topology2_${output}) endforeach() diff --git a/tools/topology/topology2/get_abi.sh b/tools/topology/topology2/get_abi.sh index 73a0bac5c47e..1ddb8549b11e 100755 --- a/tools/topology/topology2/get_abi.sh +++ b/tools/topology/topology2/get_abi.sh @@ -36,4 +36,4 @@ case "$2" in ipc4) print_2bytes "$ABI_PATCH" ;; esac -printf '\"\n\t}\n}' +printf '\"\n\t}\n}\n'