meson: Store controls and properties YAML files in variables
When generating control headers, the YAML files to be used are determined dynamically based on the selected pipeline handlers. As part of this process, the build system populates an array of meson File objects used as an input for the control headers generation custom target, as well as an array of file names (as strings). The file names array is later used to generate the control source files for the libcamera core, as well as the source code for controls support in the Python bindings. Both of the source code generators manually turn the array of file names into File objects. This duplicates code and reduces readability. A third similar implementation has also been proposed to generate control support sources in the GStreamer element, making the issue worse. To simplify this, store File objects instead of file names in the controls_files array. As the meson configuration summary doesn't support File objects, create a separate controls_files_names to store the file names for that sole purpose. The exact same process occurs for properties, address them the same way. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
parent
53108b6ff1
commit
b8d318ebeb
4 changed files with 10 additions and 19 deletions
|
@ -47,7 +47,9 @@ controls_map = {
|
||||||
|
|
||||||
control_headers = []
|
control_headers = []
|
||||||
controls_files = []
|
controls_files = []
|
||||||
|
controls_files_names = []
|
||||||
properties_files = []
|
properties_files = []
|
||||||
|
properties_files_names = []
|
||||||
|
|
||||||
foreach mode, entry : controls_map
|
foreach mode, entry : controls_map
|
||||||
files_list = []
|
files_list = []
|
||||||
|
@ -70,10 +72,12 @@ foreach mode, entry : controls_map
|
||||||
outfile = ''
|
outfile = ''
|
||||||
if mode == 'controls'
|
if mode == 'controls'
|
||||||
outfile = 'control_ids.h'
|
outfile = 'control_ids.h'
|
||||||
controls_files += files_list
|
controls_files += input_files
|
||||||
|
controls_files_names += files_list
|
||||||
else
|
else
|
||||||
outfile = 'property_ids.h'
|
outfile = 'property_ids.h'
|
||||||
properties_files += files_list
|
properties_files += input_files
|
||||||
|
properties_files_names += files_list
|
||||||
endif
|
endif
|
||||||
|
|
||||||
template_file = files(outfile + '.in')
|
template_file = files(outfile + '.in')
|
||||||
|
|
|
@ -278,8 +278,8 @@ py_mod.find_installation('python3', modules : py_modules)
|
||||||
summary({
|
summary({
|
||||||
'Enabled pipelines': pipelines,
|
'Enabled pipelines': pipelines,
|
||||||
'Enabled IPA modules': enabled_ipa_names,
|
'Enabled IPA modules': enabled_ipa_names,
|
||||||
'Controls files': controls_files,
|
'Controls files': controls_files_names,
|
||||||
'Properties files': properties_files,
|
'Properties files': properties_files_names,
|
||||||
'Hotplug support': libudev.found(),
|
'Hotplug support': libudev.found(),
|
||||||
'Tracing support': tracing_enabled,
|
'Tracing support': tracing_enabled,
|
||||||
'Android support': android_enabled,
|
'Android support': android_enabled,
|
||||||
|
|
|
@ -134,8 +134,6 @@ controls_mode_files = {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach mode, input_files : controls_mode_files
|
foreach mode, input_files : controls_mode_files
|
||||||
input_files = files(input_files)
|
|
||||||
|
|
||||||
if mode == 'controls'
|
if mode == 'controls'
|
||||||
template_file = files('control_ids.cpp.in')
|
template_file = files('control_ids.cpp.in')
|
||||||
else
|
else
|
||||||
|
|
|
@ -28,32 +28,21 @@ pycamera_sources = files([
|
||||||
|
|
||||||
# Generate controls
|
# Generate controls
|
||||||
|
|
||||||
gen_py_controls_input_files = []
|
|
||||||
gen_py_controls_template = files('py_controls_generated.cpp.in')
|
gen_py_controls_template = files('py_controls_generated.cpp.in')
|
||||||
|
|
||||||
gen_py_controls = files('gen-py-controls.py')
|
gen_py_controls = files('gen-py-controls.py')
|
||||||
|
|
||||||
foreach file : controls_files
|
|
||||||
gen_py_controls_input_files += files('../../libcamera/' + file)
|
|
||||||
endforeach
|
|
||||||
|
|
||||||
pycamera_sources += custom_target('py_gen_controls',
|
pycamera_sources += custom_target('py_gen_controls',
|
||||||
input : gen_py_controls_input_files,
|
input : controls_files,
|
||||||
output : ['py_controls_generated.cpp'],
|
output : ['py_controls_generated.cpp'],
|
||||||
command : [gen_py_controls, '--mode', 'controls', '-o', '@OUTPUT@',
|
command : [gen_py_controls, '--mode', 'controls', '-o', '@OUTPUT@',
|
||||||
'-t', gen_py_controls_template, '@INPUT@'])
|
'-t', gen_py_controls_template, '@INPUT@'])
|
||||||
|
|
||||||
# Generate properties
|
# Generate properties
|
||||||
|
|
||||||
gen_py_property_enums_input_files = []
|
|
||||||
gen_py_properties_template = files('py_properties_generated.cpp.in')
|
gen_py_properties_template = files('py_properties_generated.cpp.in')
|
||||||
|
|
||||||
foreach file : properties_files
|
|
||||||
gen_py_property_enums_input_files += files('../../libcamera/' + file)
|
|
||||||
endforeach
|
|
||||||
|
|
||||||
pycamera_sources += custom_target('py_gen_properties',
|
pycamera_sources += custom_target('py_gen_properties',
|
||||||
input : gen_py_property_enums_input_files,
|
input : properties_files,
|
||||||
output : ['py_properties_generated.cpp'],
|
output : ['py_properties_generated.cpp'],
|
||||||
command : [gen_py_controls, '--mode', 'properties', '-o', '@OUTPUT@',
|
command : [gen_py_controls, '--mode', 'properties', '-o', '@OUTPUT@',
|
||||||
'-t', gen_py_properties_template, '@INPUT@'])
|
'-t', gen_py_properties_template, '@INPUT@'])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue