From e2fda7df32f2182a8b063a69a748a3e6c1fb3669 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 7 Jun 2021 09:36:02 -0400 Subject: [PATCH] Better node names for 3p libraries in picture of dependencies --- .../cmake-modules/AudacityFunctions.cmake | 15 ++++++++++++++- src/CMakeLists.txt | 3 +-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/cmake-proxies/cmake-modules/AudacityFunctions.cmake b/cmake-proxies/cmake-modules/AudacityFunctions.cmake index afe1ae57c..4a14db612 100644 --- a/cmake-proxies/cmake-modules/AudacityFunctions.cmake +++ b/cmake-proxies/cmake-modules/AudacityFunctions.cmake @@ -301,6 +301,19 @@ function( export_symbol_define var module_name ) set( "${var}" "${symbol}=${value}" PARENT_SCOPE ) endfunction() +# shorten a target name for purposes of generating a dependency graph picture +function( canonicalize_node_name var node ) + # strip generator expressions + string( REGEX REPLACE ".*>.*:(.*)>" "\\1" node "${node}" ) + # omit the "-interface" for alias targets to modules + string( REGEX REPLACE "-interface\$" "" node "${node}" ) + # shorten names of standard libraries or Apple frameworks + string( REGEX REPLACE "^-(l|framework )" "" node "${node}" ) + # shorten paths + get_filename_component( node "${node}" NAME_WE ) + set( "${var}" "${node}" PARENT_SCOPE ) +endfunction() + function( audacity_module_fn NAME SOURCES IMPORT_TARGETS ADDITIONAL_DEFINES ADDITIONAL_LIBRARIES LIBTYPE ) @@ -454,7 +467,7 @@ function( audacity_module_fn NAME SOURCES IMPORT_TARGETS if(IMPORT IN_LIST ACCESS) continue() endif() - string( REGEX REPLACE "-interface\$" "" IMPORT "${IMPORT}" ) + canonicalize_node_name(IMPORT "${IMPORT}") list( APPEND GRAPH_EDGES "\"${TARGET}\" -> \"${IMPORT}\"" ) endforeach() set( GRAPH_EDGES "${GRAPH_EDGES}" PARENT_SCOPE ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b480ff53f..90a878c61 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1365,8 +1365,7 @@ endif() list( APPEND GRAPH_EDGES "Audacity [shape=house]" ) foreach( LIBRARY ${LIBRARIES} ) if (NOT LIBRARY MATCHES "PUBLIC|PRIVATE|INTERFACE") - string( REGEX REPLACE ".*>.*:(.*)>" "\\1" LIBRARY "${LIBRARY}" ) - string( REGEX REPLACE "^-(l|framework )" "" LIBRARY "${LIBRARY}" ) + canonicalize_node_name(LIBRARY "${LIBRARY}") list( APPEND GRAPH_EDGES "\"${TARGET}\" -> \"${LIBRARY}\"" ) endif() endforeach()