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 308a24a92b ("topology2: Add build support")

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
This commit is contained in:
Marc Herbert 2022-09-27 00:00:52 +00:00 committed by Liam Girdwood
parent a29d522059
commit eee058abcd
3 changed files with 13 additions and 16 deletions

View File

@ -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()

View File

@ -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()

View File

@ -36,4 +36,4 @@ case "$2" in
ipc4) print_2bytes "$ABI_PATCH" ;;
esac
printf '\"\n\t}\n}'
printf '\"\n\t}\n}\n'