Skip to content

Commit bd7775f

Browse files
lgirdwoodkv2019i
authored andcommitted
topology: cmake: use local ALSA utilities to build topology
Dont use the system ALSA installation which may be out of date with current topology development. Use the locally installed ALSA lib and utils installed in the SOF workspace. Signed-off-by: Liam Girdwood <liam.r.girdwood@intel.com> (cherry picked from commit 47dd8d3) Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent d03638a commit bd7775f

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

tools/ctl/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ add_executable(sof-ctl
44
ctl.c
55
)
66

7+
target_link_directories(sof-ctl BEFORE
8+
PRIVATE "${SOF_ROOT_SOURCE_DIRECTORY}/../tools/lib")
9+
710
target_link_libraries(sof-ctl PRIVATE
811
"-lasound"
912
)
@@ -13,6 +16,7 @@ target_compile_options(sof-ctl PRIVATE
1316
)
1417

1518
target_include_directories(sof-ctl PRIVATE
19+
"${SOF_ROOT_SOURCE_DIRECTORY}/../tools/include"
1620
"${SOF_ROOT_SOURCE_DIRECTORY}/src/include"
1721
"${SOF_ROOT_SOURCE_DIRECTORY}"
1822
)

tools/topology/CMakeLists.txt

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,48 @@
11
set(SOF_TOPOLOGY_BINARY_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
2+
set(SOF_ALSA_TOOLS_DIR "${SOF_ROOT_SOURCE_DIRECTORY}/../tools/bin")
3+
set(ALSATPLG_CMD "${SOF_ALSA_TOOLS_DIR}/alsatplg")
4+
5+
function(alsatplg_version OUT_STATUS OUT_VERSION)
6+
execute_process(COMMAND ${ALSATPLG_CMD} --version
7+
RESULT_VARIABLE status
8+
OUTPUT_VARIABLE stdout
9+
OUTPUT_STRIP_TRAILING_WHITESPACE)
10+
message(DEBUG "${ALSATPLG_CMD} --version: status=${status}, output=${stdout}")
11+
12+
set(${OUT_STATUS} "${status}" PARENT_SCOPE)
13+
14+
# Some error messages have already been printed on stderr
15+
if(NOT status EQUAL 0)
16+
message(WARNING "${ALSATPLG_CMD} --version returned status: ${status},
17+
${stdout}")
18+
return()
19+
endif()
20+
21+
string(REPLACE "\n" ";" ALSA_VERSION_LIST ${stdout})
22+
list(GET ALSA_VERSION_LIST 0 ALSATPLG_VERSION)
23+
string(REGEX MATCH "[0-9]\.[0-9]\.*[0-9]*" ALSATPLG_VERSION_NUMBER ${ALSATPLG_VERSION})
24+
25+
set(${OUT_VERSION} "${ALSATPLG_VERSION_NUMBER}" PARENT_SCOPE)
26+
endfunction()
27+
28+
29+
# Being written in C, `alsatplg` silently ignores some invalid inputs
30+
# and produces an corrupt .tplg file instead of returning an error code
31+
# that fails the build. For instance, alsatplg versions < 1.2.5 silently
32+
# corrupt `codec_consumer` and turn it into `codec_master` instead.
33+
# Longer story in #5192.
34+
alsatplg_version(STATUS ALSATPLG_VERSION_NUMBER)
35+
if(NOT STATUS EQUAL 0)
36+
message(WARNING "${ALSATPLG_CMD} failed: ${STATUS}; all topologies skipped")
37+
return()
38+
else()
39+
if(${ALSATPLG_VERSION_NUMBER} VERSION_LESS "1.2.5")
40+
message(WARNING "All topologies skipped: minimum alsatplg version 1.2.5,\
41+
found ${ALSATPLG_VERSION_NUMBER}.")
42+
return()
43+
endif()
44+
# success
45+
endif()
246

347
# This use of VERBOSE relies on original CMake behavior.
448
# From the add_custom_command() manual:
@@ -23,7 +67,7 @@ macro(add_alsatplg_command)
2367
# permissions are hardcoded and only the user can read
2468
# the -o(utput) file.
2569
# See bug https://github.com/alsa-project/alsa-utils/issues/126
26-
COMMAND alsatplg \$\${VERBOSE:+-v 1} -c ${ARGV0} -o ${ARGV1}
70+
COMMAND ${ALSATPLG_CMD} \$\${VERBOSE:+-v 1} -c ${ARGV0} -o ${ARGV1}
2771
USES_TERMINAL
2872
)
2973
endmacro()
@@ -41,7 +85,7 @@ macro(add_alsatplg2_command input_file output_file include_path)
4185
MAIN_DEPENDENCY ${input_file}
4286
OUTPUT ${output_file}
4387
# -p to pre-process Topology2.0 conf file
44-
COMMAND ALSA_CONFIG_DIR=${CMAKE_SOURCE_DIR}/topology/topology2 alsatplg \$\${VERBOSE:+-v 1}
88+
COMMAND ALSA_CONFIG_DIR=${CMAKE_SOURCE_DIR}/topology/topology2 ${ALSATPLG_CMD} \$\${VERBOSE:+-v 1}
4589
-I ${include_path} -D "'${defines}'" -p -c ${input_file} -o ${output_file}
4690
USES_TERMINAL
4791
)

0 commit comments

Comments
 (0)