Skip to content

Commit

Permalink
topology2/cmake: extract new function "alsatplg_version()" for re-use
Browse files Browse the repository at this point in the history
We'll use this new function to require ALSA 1.2.5 and finally rename to
"codec_consumer" (see revert discussion #5192)

Signed-off-by: Marc Herbert <[email protected]>
  • Loading branch information
marc-hb authored and lgirdwood committed Oct 23, 2023
1 parent ec1cfd8 commit 4495357
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions tools/topology/topology2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,38 @@ add_custom_target(topologies2)

# Check alsatplg version and build topology2 if alsatplg version is
# 1.2.7 or greater, see https://github.com/thesofproject/sof/issues/5323
execute_process(COMMAND alsatplg --version RESULT_VARIABLE STATUS OUTPUT_VARIABLE ALSA_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT STATUS EQUAL 0)
message(WARNING "alsatplg error: ${STATUS}, topology2 will be skipped")
else()
string(REPLACE "\n" ";" ALSA_VERSION_LIST ${ALSA_VERSION})

function(alsatplg_version OUT_STATUS OUT_VERSION)
execute_process(COMMAND alsatplg --version
RESULT_VARIABLE status
OUTPUT_VARIABLE stdout
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(DEBUG "alsatplg --version: status=${status}, output=${stdout}")

set(${OUT_STATUS} "${status}" PARENT_SCOPE)

# Some error messages have already been printed on stderr
if(NOT status EQUAL 0)
message(WARNING "alsatplg --version returned status: ${status},
${stdout}")
return()
endif()

string(REPLACE "\n" ";" ALSA_VERSION_LIST ${stdout})
list(GET ALSA_VERSION_LIST 0 ALSATPLG_VERSION)
string(REGEX MATCH "[0-9]\.[0-9]\.*[0-9]*" ALSATPLG_VERSION_NUMBER ${ALSATPLG_VERSION})

set(${OUT_VERSION} "${ALSATPLG_VERSION_NUMBER}" PARENT_SCOPE)
endfunction()

alsatplg_version(STATUS ALSATPLG_VERSION_NUMBER)

if(NOT STATUS EQUAL 0)
message(WARNING "alsatplg error: ${STATUS}; topology2 will be skipped")
else()
if(${ALSATPLG_VERSION_NUMBER} VERSION_LESS "1.2.7")
message(WARNING "topology2 will be skipped. Minimum required version for alsatplg: 1.2.7")
message(WARNING "topology2 skipped. Minimum alsatplg version 1.2.7,\
found ${ALSATPLG_VERSION_NUMBER}.")
else()
add_dependencies(topologies topologies2)
endif()
Expand Down

0 comments on commit 4495357

Please sign in to comment.