226563607e
Scripts should be referenced using the meson files() directive to ensure
the location is correctly identified with the relevant paths. This
prevents compilation failures if the working directory does not match
the source tree.
Fixes: 6e92cb9dc4 ("py: Generate control enums from yaml")
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
67 lines
2.0 KiB
Meson
67 lines
2.0 KiB
Meson
# SPDX-License-Identifier: CC0-1.0
|
|
|
|
py3_dep = dependency('python3', required : get_option('pycamera'))
|
|
|
|
if not py3_dep.found()
|
|
pycamera_enabled = false
|
|
subdir_done()
|
|
endif
|
|
|
|
pycamera_enabled = true
|
|
|
|
pybind11_proj = subproject('pybind11')
|
|
pybind11_dep = pybind11_proj.get_variable('pybind11_dep')
|
|
|
|
pycamera_sources = files([
|
|
'pyenums.cpp',
|
|
'pymain.cpp',
|
|
])
|
|
|
|
gen_input_files = [
|
|
meson.project_source_root() / 'src' / 'libcamera' / 'control_ids.yaml',
|
|
'pyenums_generated.cpp.in',
|
|
]
|
|
|
|
gen_py_control_enums = files('gen-py-control-enums.py')
|
|
|
|
generated_sources = custom_target('py_gen_controls',
|
|
input : gen_input_files,
|
|
output : ['pyenums_generated.cpp'],
|
|
command : [gen_py_control_enums, '-o', '@OUTPUT@', '@INPUT@'])
|
|
|
|
pycamera_sources += generated_sources
|
|
|
|
pycamera_deps = [
|
|
libcamera_public,
|
|
py3_dep,
|
|
pybind11_dep,
|
|
]
|
|
|
|
pycamera_args = [
|
|
'-fvisibility=hidden',
|
|
'-Wno-shadow',
|
|
'-DPYBIND11_USE_SMART_HOLDER_AS_DEFAULT',
|
|
'-DLIBCAMERA_BASE_PRIVATE',
|
|
]
|
|
|
|
destdir = get_option('libdir') / ('python' + py3_dep.version()) / 'site-packages' / 'libcamera'
|
|
|
|
pycamera = shared_module('_libcamera',
|
|
pycamera_sources,
|
|
install : true,
|
|
install_dir : destdir,
|
|
name_prefix : '',
|
|
dependencies : pycamera_deps,
|
|
cpp_args : pycamera_args)
|
|
|
|
run_command('ln', '-fsT', '../../../../src/py/libcamera/__init__.py',
|
|
meson.current_build_dir() / '__init__.py',
|
|
check: true)
|
|
|
|
install_data(['__init__.py'], install_dir : destdir)
|
|
|
|
# \todo Generate stubs when building. See https://peps.python.org/pep-0484/#stub-files
|
|
# Note: Depends on pybind11-stubgen. To generate pylibcamera stubs:
|
|
# $ PYTHONPATH=build/src/py pybind11-stubgen --no-setup-py -o build/src/py libcamera
|
|
# $ mv build/src/py/libcamera-stubs/* build/src/py/libcamera/
|