Skip to content

Commit c22e996

Browse files
committed
topology2: add SYMLINKS support for production topologies
Some topologies are byte-for-byte identical to an existing one and only need to be reachable under a different name. Add a SYMLINKS list, processed alongside TPLGS in production/CMakeLists.txt, that creates a real symlink instead of building a duplicate topology. cmake -E copy_if_different dereferences symlinks when deploying the build output, turning them back into regular file copies. Switch to "cp -a" so the deploy step preserves symlinks as symlinks. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 158518d commit c22e996

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

tools/topology/topology2/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ add_custom_target(topologies2 ALL
88
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/target/sof-ipc4-tplg
99
COMMAND ${CMAKE_COMMAND} -E create_symlink sof-ipc4-tplg ${CMAKE_CURRENT_BINARY_DIR}/target/sof-ace-tplg
1010
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/target/development
11-
# copy the topology files only to target
12-
COMMAND ${CMAKE_COMMAND} -E copy_if_different production/*.tplg ${CMAKE_CURRENT_BINARY_DIR}/target/sof-ipc4-tplg/
13-
COMMAND ${CMAKE_COMMAND} -E copy_if_different development/*.tplg ${CMAKE_CURRENT_BINARY_DIR}/target/development/
11+
# copy the topology files only to target, preserving symbolic links
12+
COMMAND sh -c "cp -a production/*.tplg \"${CMAKE_CURRENT_BINARY_DIR}/target/sof-ipc4-tplg/\""
13+
COMMAND sh -c "cp -a development/*.tplg \"${CMAKE_CURRENT_BINARY_DIR}/target/development/\""
1414
)
1515

1616
# Check alsatplg version and build topology2 if alsatplg version is

tools/topology/topology2/production/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,23 @@ foreach(tplg ${TPLGS})
3232
add_custom_target(topology2_prod_${output} DEPENDS ${output}.tplg)
3333
add_dependencies(topology2_prod topology2_prod_${output})
3434
endforeach()
35+
36+
foreach(link ${SYMLINKS})
37+
list(LENGTH link length)
38+
if(NOT length EQUAL 2)
39+
message(FATAL_ERROR "SYMLINKS entry '${link}' must have exactly 2 elements (link_name;link_target), got ${length}")
40+
endif()
41+
42+
list(GET link 0 link_name)
43+
list(GET link 1 link_target)
44+
45+
add_custom_command(
46+
OUTPUT ${link_name}.tplg
47+
COMMAND ${CMAKE_COMMAND} -E create_symlink "${link_target}.tplg" "${link_name}.tplg"
48+
DEPENDS ${link_target}.tplg
49+
VERBATIM
50+
)
51+
52+
add_custom_target(topology2_prod_${link_name} DEPENDS ${link_name}.tplg)
53+
add_dependencies(topology2_prod topology2_prod_${link_name})
54+
endforeach()

0 commit comments

Comments
 (0)