From e228c290c956ac7823fb9347be8ea957cf6d6172 Mon Sep 17 00:00:00 2001 From: Kieran Bingham Date: Sat, 19 Jun 2021 00:27:42 +0100 Subject: libcamera/base: Validate internal headers as private Headers which must not be exposed as part of the public libcamera API should include base/private.h. Any interface which includes the private.h header will only be able to build if the libcamera_private dependency is used (or the libcamera_base_private dependency directly). Build targets which are intended to use the private API's will use the libcamera_private to handle the automatic definition of the inclusion guard. Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- src/android/meson.build | 2 +- src/ipa/ipu3/meson.build | 2 +- src/ipa/libipa/meson.build | 2 +- src/ipa/raspberrypi/meson.build | 2 +- src/ipa/rkisp1/meson.build | 2 +- src/ipa/vimc/meson.build | 2 +- src/libcamera/base/meson.build | 8 ++++++++ src/libcamera/meson.build | 9 ++++++++- src/libcamera/proxy/worker/meson.build | 2 +- src/v4l2/meson.build | 2 +- 10 files changed, 24 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/android/meson.build b/src/android/meson.build index bd58ef96..7d1e7e85 100644 --- a/src/android/meson.build +++ b/src/android/meson.build @@ -4,7 +4,7 @@ android_deps = [ dependency('libexif', required : get_option('android')), dependency('libjpeg', required : get_option('android')), dependency('yaml-0.1', required : get_option('android')), - libcamera_dep, + libcamera_private, ] android_enabled = true diff --git a/src/ipa/ipu3/meson.build b/src/ipa/ipu3/meson.build index 0d843846..b6364190 100644 --- a/src/ipa/ipu3/meson.build +++ b/src/ipa/ipu3/meson.build @@ -12,7 +12,7 @@ mod = shared_module(ipa_name, [ipu3_ipa_sources, libcamera_generated_ipa_headers], name_prefix : '', include_directories : [ipa_includes, libipa_includes], - dependencies : libcamera_dep, + dependencies : libcamera_private, link_with : libipa, install : true, install_dir : ipa_install_dir) diff --git a/src/ipa/libipa/meson.build b/src/ipa/libipa/meson.build index 038fc490..ca541a5a 100644 --- a/src/ipa/libipa/meson.build +++ b/src/ipa/libipa/meson.build @@ -14,4 +14,4 @@ libipa_includes = include_directories('..') libipa = static_library('ipa', [libipa_sources, libipa_headers], include_directories : ipa_includes, - dependencies : libcamera_dep) + dependencies : libcamera_private) diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build index 230356d3..d7203aa0 100644 --- a/src/ipa/raspberrypi/meson.build +++ b/src/ipa/raspberrypi/meson.build @@ -3,7 +3,7 @@ ipa_name = 'ipa_rpi' rpi_ipa_deps = [ - libcamera_dep, + libcamera_private, dependency('boost'), libatomic, ] diff --git a/src/ipa/rkisp1/meson.build b/src/ipa/rkisp1/meson.build index 1a1c7159..f76b37f5 100644 --- a/src/ipa/rkisp1/meson.build +++ b/src/ipa/rkisp1/meson.build @@ -6,7 +6,7 @@ mod = shared_module(ipa_name, ['rkisp1.cpp', libcamera_generated_ipa_headers], name_prefix : '', include_directories : [ipa_includes, libipa_includes], - dependencies : libcamera_dep, + dependencies : libcamera_private, link_with : libipa, install : true, install_dir : ipa_install_dir) diff --git a/src/ipa/vimc/meson.build b/src/ipa/vimc/meson.build index a35825ae..ecbeee13 100644 --- a/src/ipa/vimc/meson.build +++ b/src/ipa/vimc/meson.build @@ -6,7 +6,7 @@ mod = shared_module(ipa_name, ['vimc.cpp', libcamera_generated_ipa_headers], name_prefix : '', include_directories : [ipa_includes, libipa_includes], - dependencies : libcamera_dep, + dependencies : libcamera_private, link_with : libipa, install : true, install_dir : ipa_install_dir) diff --git a/src/libcamera/base/meson.build b/src/libcamera/base/meson.build index a8b04cfc..87172157 100644 --- a/src/libcamera/base/meson.build +++ b/src/libcamera/base/meson.build @@ -21,10 +21,15 @@ libcamera_base_deps = [ dependency('threads'), ] +# Internal components must use the libcamera_base_private dependency to enable +# the use of headers which must not be exposed to the libcamera public api. +libcamera_base_args = [ '-DLIBCAMERA_BASE_PRIVATE' ] + libcamera_base_lib = shared_library('libcamera-base', [libcamera_base_sources, libcamera_base_headers], name_prefix : '', install : true, + cpp_args : libcamera_base_args, include_directories : libcamera_includes, dependencies : libcamera_base_deps) @@ -39,3 +44,6 @@ pkg_mod.generate(libcamera_base_lib, version : '1.0', description : 'Camera support base utility library', subdirs : 'libcamera') + +libcamera_base_private = declare_dependency(dependencies : libcamera_base, + compile_args : libcamera_base_args) diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index e0c47352..ebd37e06 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -112,6 +112,7 @@ endif libcamera_deps = [ libatomic, libcamera_base, + libcamera_base_private, libdl, libgnutls, liblttng, @@ -143,9 +144,15 @@ libcamera_dep = declare_dependency(sources : [ libcamera_generated_ipa_headers, ], include_directories : libcamera_includes, - dependencies: libcamera_base, + dependencies : libcamera_base, link_with : libcamera) +# Internal dependency for components and plugins which can use private APIs +libcamera_private = declare_dependency(dependencies : [ + libcamera_dep, + libcamera_base_private, + ]) + pkg_mod = import('pkgconfig') pkg_mod.generate(libcamera, libraries : libcamera_base_lib, diff --git a/src/libcamera/proxy/worker/meson.build b/src/libcamera/proxy/worker/meson.build index 28fe5f1f..70c8760a 100644 --- a/src/libcamera/proxy/worker/meson.build +++ b/src/libcamera/proxy/worker/meson.build @@ -21,7 +21,7 @@ foreach mojom : ipa_mojoms [worker, libcamera_generated_ipa_headers], install : true, install_dir : proxy_install_dir, - dependencies : libcamera_dep) + dependencies : libcamera_private) endforeach config_h.set('IPA_PROXY_DIR', diff --git a/src/v4l2/meson.build b/src/v4l2/meson.build index 0accac19..f78497b6 100644 --- a/src/v4l2/meson.build +++ b/src/v4l2/meson.build @@ -31,5 +31,5 @@ v4l2_compat = shared_library('v4l2-compat', v4l2_compat_sources, name_prefix : '', install : true, - dependencies : [libcamera_dep, libdl], + dependencies : [libcamera_private, libdl], cpp_args : v4l2_compat_cpp_args) -- cgit v1.2.1