From eee058abcd199cacfc6880f0c706b98365f4c183 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Tue, 27 Sep 2022 00:00:52 +0000 Subject: [PATCH] topology2: concat abi.conf at build time to fix incremental build It's now possible to rebuild just only one modified topology without rebuilding all of them from scratch. Building topologies v2 has two steps: 1. concatenation of abi.conf with topo.conf 2. run alsatplg on the concatenation Concatenation step 1. was wrongly implemented at configuration time, not at build time. So when the topology source of step 1 (topo.conf) was modified, the dependency of step 2 (= the concatenation) was not affected and the topology was not rebuilt. Fix this by moving the concatenation to build time. Fixes commit 308a24a92b44 ("topology2: Add build support") Signed-off-by: Marc Herbert --- tools/topology/CMakeLists.txt | 15 +++++++++------ tools/topology/topology2/cavs/CMakeLists.txt | 12 +++--------- tools/topology/topology2/get_abi.sh | 2 +- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/tools/topology/CMakeLists.txt b/tools/topology/CMakeLists.txt index 4b7b36d1a..a25135402 100644 --- a/tools/topology/CMakeLists.txt +++ b/tools/topology/CMakeLists.txt @@ -28,21 +28,24 @@ macro(add_alsatplg_command) ) endmacro() -macro(add_alsatplg2_command input_file output_file include_path) +macro(add_alsatplg2_command conf_header input_name output_name include_path) # command line definitions are optional # Set defines if there is an optional argument - if (${ARGC} GREATER 3) - set (defines ${ARGV3}) + if (${ARGC} GREATER 4) + set (defines ${ARGV4}) else() set (defines "") endif() add_custom_command( - MAIN_DEPENDENCY ${input_file} - OUTPUT ${output_file} + MAIN_DEPENDENCY ${input_name}.conf + OUTPUT ${output_name}.tplg + + COMMAND cat ${conf_header} ${input_name}.conf > ${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/topology2/cavs/CMakeLists.txt b/tools/topology/topology2/cavs/CMakeLists.txt index ee60915e5..a9d89fba4 100644 --- a/tools/topology/topology2/cavs/CMakeLists.txt +++ b/tools/topology/topology2/cavs/CMakeLists.txt @@ -68,15 +68,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" + "${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 73a0bac5c..1ddb8549b 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'