Repository navigation
topology2: Add build support #5153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
| add_custom_target(topologies2 | ||
| COMMAND ${CMAKE_COMMAND} -E copy_directory cavs ${SOF_TOPOLOGY_BINARY_DIRECTORY} | ||
| ) | ||
|
|
||
| # generate ABI | ||
| execute_process( | ||
| COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/get_abi.sh ${SOF_ROOT_SOURCE_DIRECTORY} | ||
| OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/abi.conf | ||
| ) | ||
|
|
||
| # check alsatplg version and built topology2 if alsatplg version is 1.2.6 or greater | ||
| # This will override any common topologies built with topology1 | ||
| execute_process(COMMAND alsatplg --version RESULT_VARIABLE STATUS OUTPUT_VARIABLE ALSA_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
| if(STATUS AND NOT STATUS EQUAL 0) | ||
| message(WARNING "alsatplg error: ${STATUS}, topology2 will be skipped") | ||
| else() | ||
| string(REPLACE "\n" ";" ALSA_VERSION_LIST ${ALSA_VERSION}) | ||
| list(GET ALSA_VERSION_LIST 0 ALSATPLG_VERSION) | ||
| string(REGEX MATCH "[0-9]\.[0-9]\.*[0-9]*" ALSATPLG_VERSION_NUMBER ${ALSATPLG_VERSION}) | ||
| if(${ALSATPLG_VERSION_NUMBER} VERSION_LESS "1.2.6") | ||
| message(WARNING "topology2 will be skipped. Minimum required version for alsatplg: 1.2.6") | ||
| else() | ||
| add_dependencies(topologies topologies2) | ||
|
|
||
| # make sure topology1 always builds first so that the installed binaries from v2 override the ones from v1 | ||
| add_dependencies(topologies2 topologies1) | ||
|
|
||
| endif() | ||
| endif() | ||
|
|
||
| add_subdirectory(cavs) | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,43 @@ | ||||||||
| # SPDX-License-Identifier: BSD-3-Clause | ||||||||
|
|
||||||||
| # Array of "input-file-name;output-file-name;comma separated pre-processor variables" | ||||||||
| set(TPLGS | ||||||||
| # CAVS HDMI only topology with passthrough pipelines | ||||||||
| "cavs-passthrough-hdmi\;cavs-passthrough-hdmi" | ||||||||
| # CAVS HDA topology with passthrough pipelines | ||||||||
| "cavs-passthrough-hdmi\;cavs-passthrough-hda\;HDA_CONFIG=passthrough" | ||||||||
| # CAVS HDMI only topology with gain-based pipelines | ||||||||
| "cavs-gain-hdmi\;cavs-gain-hdmi" | ||||||||
| # CAVS HDA topology with gain-based pipelines | ||||||||
| "cavs-gain-hdmi\;cavs-gain-hda\;HDA_CONFIG=gain" | ||||||||
| # CAVS HDA topology with mixer-based pipelines | ||||||||
| "cavs-passthrough-hdmi\;cavs-mixin-mixout-hda\;HDA_CONFIG=mix" | ||||||||
| ) | ||||||||
|
|
||||||||
| # This will override the topology1 binaries with topology2 binaries | ||||||||
| add_custom_target(topology2_cavs) | ||||||||
| add_dependencies(topologies2 topology2_cavs) | ||||||||
|
|
||||||||
| foreach(tplg ${TPLGS}) | ||||||||
| set(defines "") | ||||||||
| list(LENGTH tplg length) | ||||||||
| list(GET tplg 0 input) | ||||||||
| list(GET tplg 1 output) | ||||||||
|
|
||||||||
| math(EXPR last_index "${length}-1") | ||||||||
|
|
||||||||
| # Get the pre-processor definitions from the 3rd item in the list for each topology | ||||||||
| # ex: "hda-generic\;hda-generic-2ch\;HDA_CONFIG=gain,DMIC_CH=2", "defines" would contain "HDA_CONFIG=gain,DMIC_CH=2" | ||||||||
| if (${last_index} EQUAL 2) | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would GREATER be more future-proof?
Suggested change
In any case I think testing ${length} would be slightly more readable. |
||||||||
| list(GET tplg ${last_index} defines) | ||||||||
|
ranj063 marked this conversation as resolved.
Outdated
|
||||||||
| endif() | ||||||||
|
|
||||||||
| # copy ABI and input conf file contents | ||||||||
| 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}") | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general |
||||||||
|
|
||||||||
| add_alsatplg2_command(${output}.conf ${output}.tplg ${CMAKE_CURRENT_SOURCE_DIR} ${defines}) | ||||||||
| add_custom_target(topology2_${output} DEPENDS ${output}.tplg) | ||||||||
| add_dependencies(topology2_cavs topology2_${output}) | ||||||||
| endforeach() | ||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/bin/bash | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
| # Copyright(c) 2019 Intel Corporation. All rights reserved. | ||
| set -e | ||
|
|
||
| ABI_MAJOR=$(awk '/^ *# *define *SOF_ABI_MAJOR / { print $3 }' $1/src/include/kernel/abi.h) | ||
| ABI_MINOR=$(awk '/^ *# *define *SOF_ABI_MINOR / { print $3 }' $1/src/include/kernel/abi.h) | ||
| ABI_PATCH=$(awk '/^ *# *define *SOF_ABI_PATCH / { print $3 }' $1/src/include/kernel/abi.h) | ||
|
|
||
| cat <<EOF_HEADER | ||
| Object.Base.manifest."sof_manifest" { | ||
| Object.Base.data."SOF ABI" { | ||
| EOF_HEADER | ||
| printf '\t\tbytes\t"0x%02x,' "$ABI_MAJOR" | ||
| printf "0x%02x," "$ABI_MINOR" | ||
| printf '0x%02x\"\n\t}\n}' "$ABI_PATCH" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to omit the entire subdirectory, instead omit only the edge in the dependency graph and don't add this target to the default ALL target. In other words, only this line needs to be conditional:
So everyone is aligned and runs the exact same CMake code at configuration time no matter what their ALSA version is. The difference comes later only at build time.
This is also more flexible for any adventurer who has multiple ALSA versions installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but as far as topology2 goes everything in the topology2 folder should be conditionally built based on version right? its not just topology2_cavs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes sorry, hasty review and copy/paste. The point is to use a scalpel to conditionally cut only the topology2 dependency in the graph, then all v2 dependency "leaves" will be configured and available but not built by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this look good?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, instead of
return()here use:+ remove ALL above