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.
This commit is contained in:
Peter Wu 2021-01-06 20:43:37 +01:00 committed by AndersBroman
parent 1d43b2a3aa
commit 2e0dda9e03
2 changed files with 7 additions and 5 deletions

View File

@ -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()

View File

@ -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')