Skip to content

Commit

Permalink
Merge pull request audacity#6221 from Paul-Licameli/Module-subgraphs
Browse files Browse the repository at this point in the history
Module subgraphs

Reorganize the modules into several sub-folders, and change the generation
of Graphviz output from configuration to make a tidier graph that puts boxes
around sets of related modules, with the libraries used only in those modules.
  • Loading branch information
Paul-Licameli authored Apr 10, 2024
2 parents 634cf6b + 7805599 commit 2e64d69
Show file tree
Hide file tree
Showing 267 changed files with 234 additions and 74 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,8 @@ string( JOIN "\n" GRAPH_EDGES ${GRAPH_EDGES} )
# Choose edge attributes making it easy to hover at either end of edge
# and see a tooltip describing the edge, in svg image
file( WRITE "${CMAKE_CURRENT_BINARY_DIR}/modules.dot" "digraph {
graph [rankdir=LR] edge [dir=both,arrowtail=inv] \n"
graph [rankdir=LR newrank=true] edge [dir=both,arrowtail=inv] \n"
"${GRAPH_SUBGRAPHS}\n"
"${GRAPH_EDGES}"
"\n}\n"
)
Expand Down
56 changes: 55 additions & 1 deletion cmake-proxies/cmake-modules/AudacityFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ 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}" )
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
Expand Down Expand Up @@ -848,3 +848,57 @@ function(fix_bundle target_name)
-config=$<CONFIG>
)
endfunction()


# The list of modules is ordered so that each module occurs after any others
# that it depends on
macro( audacity_module_subdirectory modules )
# Make a graphviz cluster of module nodes and maybe some 3p libraries
set( subgraph )
get_filename_component( name "${CMAKE_CURRENT_SOURCE_DIR}" NAME_WE )
string( APPEND subgraph
# name must begin with "cluster" to get graphviz to draw a box
"subgraph \"cluster${name}\" { "
# style attributes and visible name
"style=bold color=blue labeljust=r labelloc=b label=\"${name}\" "
)

set( nodes )
set( EXCLUDE_LIST
Audacity
PRIVATE
PUBLIC
INTERFACE
)

# Visit each module, and may collect some clustered node names
foreach( MODULE ${MODULES} )
set( EXTRA_CLUSTER_NODES ) # a variable that the subdirectory may change
add_subdirectory( "${MODULE}" )

foreach( NODE ${EXTRA_CLUSTER_NODES} )
# This processing of NODE makes it easy for the module simply to
# designate all of its libraries as extra cluster nodes, when they
# (besides the executable itself) are not used anywhere else
if ( NODE IN_LIST EXCLUDE_LIST )
continue()
endif()
canonicalize_node_name( NODE "${NODE}" )
string( APPEND nodes "\"${NODE}\"\n" )
endforeach()
endforeach()

# complete the cluster description
foreach( MODULE ${MODULES} )
string( APPEND nodes "\"${MODULE}\"\n" )
endforeach()
string( APPEND subgraph
# names of nodes to be grouped
"\n${nodes}"
"}\n"
)

# propagate collected edges and subgraphs up to root CMakeLists.txt
set( GRAPH_EDGES "${GRAPH_EDGES}" PARENT_SCOPE )
set( GRAPH_SUBGRAPHS "${GRAPH_SUBGRAPHS}${subgraph}" PARENT_SCOPE )
endmacro()
66 changes: 13 additions & 53 deletions modules/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,60 +1,20 @@
# Include the modules that we'll build

# The list of modules is ordered so that each module occurs after any others
# that it depends on
set( MODULES
mod-midi-import-export
mod-script-pipe
mod-mp3
mod-pcm
mod-cl
mod-lof
mod-aup
# The list of module sub-folders is ordered so that each folder occurs after any
# others that it depends on
set( FOLDERS
etc
import-export
track-ui
scripting
nyquist
sharing
)
if( NOT CMAKE_SYSTEM_NAME MATCHES "Windows" )
list( APPEND MODULES
mod-null
mod-nyq-bench
)
endif()

if ( USE_LIBOGG AND USE_LIBVORBIS )
list( APPEND MODULES mod-ogg )
endif()

if ( USE_LIBFLAC )
list( APPEND MODULES mod-flac )
endif()

if ( USE_LIBTWOLAME )
list ( APPEND MODULES mod-mp2)
endif()

if ( USE_WAVPACK )
list ( APPEND MODULES mod-wavpack )
endif()

if ( USE_LIBMPG123 )
list ( APPEND MODULES mod-mpg123 )
endif()

if ( USE_FFMPEG )
list ( APPEND MODULES mod-ffmpeg )
endif()

if ( USE_LIBOPUS AND USE_OPUSFILE AND USE_LIBOGG )
list ( APPEND MODULES mod-opus )
endif()

if ( ${_OPT}has_audiocom_upload)
list( APPEND MODULES
mod-cloud-audiocom
)
endif()

foreach( MODULE ${MODULES} )
add_subdirectory("${MODULE}")
foreach( FOLDER ${FOLDERS} )
add_subdirectory("${FOLDER}")
endforeach()

#propagate collected edges up to root CMakeLists.txt
#propagate collected edges and subgraphs up to root CMakeLists.txt
set( GRAPH_EDGES "${GRAPH_EDGES}" PARENT_SCOPE )
set( GRAPH_SUBGRAPHS "${GRAPH_SUBGRAPHS}" PARENT_SCOPE )
13 changes: 13 additions & 0 deletions modules/etc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Include the modules that we'll build

# The list of modules is ordered so that each module occurs after any others
# that it depends on
set( MODULES
)
if( NOT CMAKE_SYSTEM_NAME MATCHES "Windows" )
list( APPEND MODULES
mod-null
)
endif()

audacity_module_subdirectory("${MODULES}")
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ set( SOURCES
ModNullCallback.cpp
ModNullCallback.h
)
audacity_module( ${TARGET} "${SOURCES}" "Audacity"
set ( LIBRARIES
PRIVATE
Audacity
)
audacity_module( ${TARGET} "${SOURCES}" "${LIBRARIES}"
"${DEFINES}" "" )

set_target_properties( ${TARGET} PROPERTIES EXCLUDE_FROM_ALL YES )
File renamed without changes.
File renamed without changes.
41 changes: 41 additions & 0 deletions modules/import-export/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Include the modules that we'll build

# The list of modules is ordered so that each module occurs after any others
# that it depends on
set( MODULES
mod-mp3
mod-pcm
mod-cl
mod-lof
mod-aup
)

if ( USE_LIBOGG AND USE_LIBVORBIS )
list( APPEND MODULES mod-ogg )
endif()

if ( USE_LIBFLAC )
list( APPEND MODULES mod-flac )
endif()

if ( USE_LIBTWOLAME )
list ( APPEND MODULES mod-mp2 )
endif()

if ( USE_WAVPACK )
list ( APPEND MODULES mod-wavpack )
endif()

if ( USE_LIBMPG123 )
list ( APPEND MODULES mod-mpg123 )
endif()

if ( USE_FFMPEG )
list ( APPEND MODULES mod-ffmpeg )
endif()

if ( USE_LIBOPUS AND USE_OPUSFILE AND USE_LIBOGG )
list ( APPEND MODULES mod-opus )
endif()

audacity_module_subdirectory("${MODULES}")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ if ( USE_LIBID3TAG )
list ( APPEND LIBRARIES PRIVATE libid3tag::libid3tag)
endif()

set (EXTRA_CLUSTER_NODES "${LIBRARIES}" PARENT_SCOPE)

audacity_module( ${TARGET} "${SOURCES}" "${LIBRARIES}" "" "" )
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ set( LIBRARIES
Audacity
)

set (EXTRA_CLUSTER_NODES "${LIBRARIES}" PARENT_SCOPE)

if( "${${_OPT}use_ffmpeg}" STREQUAL "linked" )
set( DISABLE_DYNAMIC_LOADING_FFMPEG YES )
endif()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ set( SOURCES

set( LIBRARIES
PRIVATE
lib-import-export-interface
FLAC::FLAC
FLAC::FLAC++
)
Expand All @@ -17,4 +16,10 @@ if ( USE_LIBID3TAG )
list ( APPEND LIBRARIES PRIVATE libid3tag::libid3tag)
endif()

set (EXTRA_CLUSTER_NODES "${LIBRARIES}" PARENT_SCOPE)

list(APPEND LIBRARIES
lib-import-export-interface
)

audacity_module( ${TARGET} "${SOURCES}" "${LIBRARIES}" "" "" )
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ set( SOURCES

set( LIBRARIES
PRIVATE
lib-import-export-interface
twolame
)

if ( USE_LIBID3TAG )
list ( APPEND LIBRARIES PRIVATE libid3tag::libid3tag)
endif()

set (EXTRA_CLUSTER_NODES "${LIBRARIES}" PARENT_SCOPE)

list (APPEND LIBRARIES
lib-import-export-interface
)

audacity_module( ${TARGET} "${SOURCES}" "${LIBRARIES}" "" "" )
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ if ( USE_LIBID3TAG )
list ( APPEND LIBRARIES PRIVATE libid3tag::libid3tag)
endif()

set (EXTRA_CLUSTER_NODES "${LIBRARIES}" PARENT_SCOPE)

audacity_module( ${TARGET} "${SOURCES}" "${LIBRARIES}" "" "" )
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ set( SOURCES

set( LIBRARIES
PRIVATE
lib-import-export-interface
mpg123::libmpg123
)

if ( USE_LIBID3TAG )
list ( APPEND LIBRARIES PRIVATE libid3tag::libid3tag)
endif()

set (EXTRA_CLUSTER_NODES "${LIBRARIES}" PARENT_SCOPE)

list(APPEND LIBRARIES
lib-import-export-interface
)

audacity_module( ${TARGET} "${SOURCES}" "${LIBRARIES}" "" "" )
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ set( SOURCES

set( LIBRARIES
PRIVATE
lib-import-export-interface
Ogg::ogg
Vorbis::vorbis
Vorbis::vorbisfile
Vorbis::vorbisenc
)

set (EXTRA_CLUSTER_NODES "${LIBRARIES}" PARENT_SCOPE)

list(APPEND LIBRARIES
lib-import-export-interface
)

audacity_module( ${TARGET} "${SOURCES}" "${LIBRARIES}" "" "" )
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ set( SOURCES

set( LIBRARIES
PRIVATE
lib-import-export-interface
Opus::opus
opusfile::opusfile
Ogg::ogg
)

set (EXTRA_CLUSTER_NODES "${LIBRARIES}" PARENT_SCOPE)

list(APPEND LIBRARIES
lib-import-export-interface
)

audacity_module( ${TARGET} "${SOURCES}" "${LIBRARIES}" "" "" )
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ set( SOURCES
PCM.cpp
)

set( LIBRARIES
if ( USE_LIBID3TAG )
list ( APPEND LIBRARIES PRIVATE libid3tag::libid3tag)
endif()

set (EXTRA_CLUSTER_NODES "${LIBRARIES}" PARENT_SCOPE)

list (APPEND LIBRARIES
PRIVATE
lib-import-export-interface
lib-file-formats-interface
)

if ( USE_LIBID3TAG )
list ( APPEND LIBRARIES PRIVATE libid3tag::libid3tag)
endif()

audacity_module( ${TARGET} "${SOURCES}" "${LIBRARIES}" "" "" )
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ set( SOURCES

set( LIBRARIES
PRIVATE
lib-import-export-interface
wavpack::wavpack
)

set (EXTRA_CLUSTER_NODES "${LIBRARIES}" PARENT_SCOPE)

list(APPEND LIBRARIES
lib-import-export-interface
)

audacity_module( ${TARGET} "${SOURCES}" "${LIBRARIES}" "" "" )
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions modules/nyquist/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Include the modules that we'll build

# The list of modules is ordered so that each module occurs after any others
# that it depends on
set( MODULES
)

if( NOT CMAKE_SYSTEM_NAME MATCHES "Windows" )
list( APPEND MODULES
mod-nyq-bench
)
endif()

audacity_module_subdirectory("${MODULES}")
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ set( DEFINES
# versions of wxWidgets...even if the build is for Release.
wxDEBUG_LEVEL=0
)
audacity_module( ${TARGET} "${SOURCES}" "Audacity"
set( LIBRARIES
PRIVATE
Audacity
)
audacity_module( ${TARGET} "${SOURCES}" "${LIBRARIES}"
"${DEFINES}" "" )

set_target_properties( ${TARGET} PROPERTIES EXCLUDE_FROM_ALL YES )
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 2e64d69

Please sign in to comment.