Skip to content
Merged
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
44 changes: 44 additions & 0 deletions tools/topology/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,49 @@
set(SOF_TOPOLOGY_BINARY_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")


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


# Being written in C, `alsatplg` silently ignores some invalid inputs
# and produces an corrupt .tplg file instead of returning an error code
# that fails the build. For instance, alsatplg versions < 1.2.5 silently
# corrupt `codec_consumer` and turn it into `codec_master` instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: some grammer tense issues

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the prompt review!

Could you be more precise about the grammar issues?

I found "produces A corrupt..." and nothing else (and that's not a tense). Google docs and MS Word don't find anything either.

# Longer story in #5192.
alsatplg_version(STATUS ALSATPLG_VERSION_NUMBER)
if(NOT STATUS EQUAL 0)
message(WARNING "alsatplg failed: ${STATUS}; all topologies skipped")
return()
else()
if(${ALSATPLG_VERSION_NUMBER} VERSION_LESS "1.2.5")
message(WARNING "All topologies skipped: minimum alsatplg version 1.2.5,\
found ${ALSATPLG_VERSION_NUMBER}.")
return()
endif()
# success
endif()


# This use of VERBOSE relies on original CMake behavior.
# From the add_custom_command() manual:
#
Expand Down
24 changes: 0 additions & 24 deletions tools/topology/topology2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,6 @@ 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

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)
Expand Down