From 2e0dda9e0315bbd13aa2e29c1a8a4eef8f9419ba Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 6 Jan 2021 20:43:37 +0100 Subject: [PATCH] CMake: Reduce "Generating plugin.c" noise during the build With Ninja, the build is unnecessarily noisy: [21/81] Generating plugin.c Generated plugin.c for l16_mono. [22/81] Generating plugin.c Generated plugin.c for G711. Avoid writing `Generated plugin.c for G711` and generate a single line such as `Generating plugins/codecs/G711/plugin.c` instead. Do not write the absolute path to plugin.c, this should hopefully help with reproducible builds that are independent of the build directory. --- cmake/modules/UseMakePluginReg.cmake | 8 +++++--- tools/make-plugin-reg.py | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cmake/modules/UseMakePluginReg.cmake b/cmake/modules/UseMakePluginReg.cmake index 19f0e9bf40..e6e6a9193d 100644 --- a/cmake/modules/UseMakePluginReg.cmake +++ b/cmake/modules/UseMakePluginReg.cmake @@ -1,9 +1,10 @@ # -MACRO(REGISTER_PLUGIN_FILES _outputfile _registertype ) +function(register_plugin_files _outputfile _registertype) include(LocatePythonModule) locate_python_module(make-plugin-reg REQUIRED PATHS ${CMAKE_SOURCE_DIR}/tools) - ADD_CUSTOM_COMMAND( + file(RELATIVE_PATH output "${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/${_outputfile}") + add_custom_command( OUTPUT ${_outputfile} COMMAND ${PYTHON_EXECUTABLE} @@ -11,8 +12,9 @@ MACRO(REGISTER_PLUGIN_FILES _outputfile _registertype ) ${CMAKE_CURRENT_SOURCE_DIR} ${_registertype} ${ARGN} + COMMENT "Generating ${output}" DEPENDS ${ARGN} ${PY_MAKE-PLUGIN-REG} ) -ENDMACRO(REGISTER_PLUGIN_FILES) +endfunction() diff --git a/tools/make-plugin-reg.py b/tools/make-plugin-reg.py index 946edb8d3b..455936032a 100755 --- a/tools/make-plugin-reg.py +++ b/tools/make-plugin-reg.py @@ -2,6 +2,7 @@ # # Looks for registration routines in the plugins # and assembles C code to call all the routines. +# A new "plugin.c" file will be written in the current directory. # import os @@ -28,7 +29,7 @@ preamble = """\ * * Generated automatically from %s. */ -""" % (sys.argv[0]) +""" % (os.path.basename(sys.argv[0])) # Create the proper list of filenames filenames = [] @@ -165,7 +166,6 @@ try: fh = open(final_filename, 'w') fh.write(reg_code) fh.close() - print('Generated {} for {}.'.format(final_filename, os.path.basename(srcdir))) except OSError: sys.exit('Unable to write ' + final_filename + '.\n')