Files
external_libcamera/include/libcamera/meson.build
Laurent Pinchart b8d318ebeb 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>
2024-08-15 04:44:09 +03:00

132 lines
4.0 KiB
Meson

# SPDX-License-Identifier: CC0-1.0
libcamera_include_dir = 'libcamera' / 'libcamera'
libcamera_public_headers = files([
'camera.h',
'camera_manager.h',
'color_space.h',
'controls.h',
'fence.h',
'framebuffer.h',
'framebuffer_allocator.h',
'geometry.h',
'logging.h',
'orientation.h',
'pixel_format.h',
'request.h',
'stream.h',
'transform.h',
])
subdir('base')
subdir('internal')
subdir('ipa')
install_headers(libcamera_public_headers,
subdir : libcamera_include_dir)
#
# Generate headers from templates.
#
libcamera_headers_install_dir = get_option('includedir') / libcamera_include_dir
controls_map = {
'controls': {
'draft': 'control_ids_draft.yaml',
'core': 'control_ids_core.yaml',
'rpi/vc4': 'control_ids_rpi.yaml',
},
'properties': {
'draft': 'property_ids_draft.yaml',
'core': 'property_ids_core.yaml',
}
}
control_headers = []
controls_files = []
controls_files_names = []
properties_files = []
properties_files_names = []
foreach mode, entry : controls_map
files_list = []
input_files = []
foreach vendor, header : entry
if vendor != 'core' and vendor != 'draft'
if vendor not in pipelines
continue
endif
endif
if header in files_list
continue
endif
files_list += header
input_files += files('../../src/libcamera/' + header)
endforeach
outfile = ''
if mode == 'controls'
outfile = 'control_ids.h'
controls_files += input_files
controls_files_names += files_list
else
outfile = 'property_ids.h'
properties_files += input_files
properties_files_names += files_list
endif
template_file = files(outfile + '.in')
ranges_file = files('../../src/libcamera/control_ranges.yaml')
control_headers += custom_target(header + '_h',
input : input_files,
output : outfile,
command : [gen_controls, '-o', '@OUTPUT@',
'--mode', mode, '-t', template_file,
'-r', ranges_file, '@INPUT@'],
install : true,
install_dir : libcamera_headers_install_dir)
endforeach
libcamera_public_headers += control_headers
# formats.h
formats_h = custom_target('formats_h',
input : files(
'../../src/libcamera/formats.yaml',
'formats.h.in',
'../linux/drm_fourcc.h'
),
output : 'formats.h',
command : [gen_formats, '-o', '@OUTPUT@', '@INPUT@'],
install : true,
install_dir : libcamera_headers_install_dir)
libcamera_public_headers += formats_h
# libcamera.h
libcamera_h = custom_target('gen-header',
input : 'meson.build',
output : 'libcamera.h',
command : [gen_header, meson.current_source_dir(), '@OUTPUT@'],
install : true,
install_dir : libcamera_headers_install_dir)
libcamera_public_headers += libcamera_h
# version.h
version = libcamera_version.split('.')
libcamera_version_config = configuration_data()
libcamera_version_config.set('LIBCAMERA_VERSION_MAJOR', version[0])
libcamera_version_config.set('LIBCAMERA_VERSION_MINOR', version[1])
libcamera_version_config.set('LIBCAMERA_VERSION_PATCH', version[2])
version_h = configure_file(input : 'version.h.in',
output : 'version.h',
configuration : libcamera_version_config,
install_dir : libcamera_headers_install_dir)
libcamera_public_headers += version_h