summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@ideasonboard.com>2021-06-19 00:27:42 +0100
committerKieran Bingham <kieran.bingham@ideasonboard.com>2021-06-25 16:11:11 +0100
commite228c290c956ac7823fb9347be8ea957cf6d6172 (patch)
treee60e343876c9a86568a5a1c178c6fbda73cdc554
parentb71e8c2f39d823891aab4c681cccab9af5a49406 (diff)
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 <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rw-r--r--include/libcamera/base/event_dispatcher.h2
-rw-r--r--include/libcamera/base/event_dispatcher_poll.h2
-rw-r--r--include/libcamera/base/event_notifier.h2
-rw-r--r--include/libcamera/base/file.h2
-rw-r--r--include/libcamera/base/log.h2
-rw-r--r--include/libcamera/base/meson.build1
-rw-r--r--include/libcamera/base/private.h22
-rw-r--r--include/libcamera/base/semaphore.h1
-rw-r--r--include/libcamera/base/thread.h2
-rw-r--r--include/libcamera/base/timer.h2
-rw-r--r--include/libcamera/base/utils.h2
-rw-r--r--src/android/meson.build2
-rw-r--r--src/ipa/ipu3/meson.build2
-rw-r--r--src/ipa/libipa/meson.build2
-rw-r--r--src/ipa/raspberrypi/meson.build2
-rw-r--r--src/ipa/rkisp1/meson.build2
-rw-r--r--src/ipa/vimc/meson.build2
-rw-r--r--src/libcamera/base/meson.build8
-rw-r--r--src/libcamera/meson.build9
-rw-r--r--src/libcamera/proxy/worker/meson.build2
-rw-r--r--src/v4l2/meson.build2
-rw-r--r--test/camera/meson.build2
-rw-r--r--test/ipa/meson.build2
-rw-r--r--test/ipc/meson.build2
-rw-r--r--test/libtest/meson.build2
-rw-r--r--test/log/meson.build2
-rw-r--r--test/media_device/meson.build4
-rw-r--r--test/meson.build2
-rw-r--r--test/pipeline/ipu3/meson.build2
-rw-r--r--test/pipeline/rkisp1/meson.build2
-rw-r--r--test/process/meson.build2
-rw-r--r--test/serialization/generated_serializer/meson.build2
-rw-r--r--test/serialization/meson.build2
-rw-r--r--test/v4l2_subdevice/meson.build2
-rw-r--r--test/v4l2_videodevice/meson.build2
35 files changed, 79 insertions, 24 deletions
diff --git a/include/libcamera/base/event_dispatcher.h b/include/libcamera/base/event_dispatcher.h
index 045df27f..825af7a3 100644
--- a/include/libcamera/base/event_dispatcher.h
+++ b/include/libcamera/base/event_dispatcher.h
@@ -9,6 +9,8 @@
#include <vector>
+#include <libcamera/base/private.h>
+
namespace libcamera {
class EventNotifier;
diff --git a/include/libcamera/base/event_dispatcher_poll.h b/include/libcamera/base/event_dispatcher_poll.h
index ae2a3f04..683934bf 100644
--- a/include/libcamera/base/event_dispatcher_poll.h
+++ b/include/libcamera/base/event_dispatcher_poll.h
@@ -11,6 +11,8 @@
#include <map>
#include <vector>
+#include <libcamera/base/private.h>
+
#include <libcamera/base/event_dispatcher.h>
struct pollfd;
diff --git a/include/libcamera/base/event_notifier.h b/include/libcamera/base/event_notifier.h
index 5aa2784a..5055ccbf 100644
--- a/include/libcamera/base/event_notifier.h
+++ b/include/libcamera/base/event_notifier.h
@@ -7,6 +7,8 @@
#ifndef __LIBCAMERA_BASE_EVENT_NOTIFIER_H__
#define __LIBCAMERA_BASE_EVENT_NOTIFIER_H__
+#include <libcamera/base/private.h>
+
#include <libcamera/base/object.h>
#include <libcamera/base/signal.h>
diff --git a/include/libcamera/base/file.h b/include/libcamera/base/file.h
index 465f3ef8..7dd1559d 100644
--- a/include/libcamera/base/file.h
+++ b/include/libcamera/base/file.h
@@ -12,6 +12,8 @@
#include <map>
#include <string>
+#include <libcamera/base/private.h>
+
#include <libcamera/base/class.h>
#include <libcamera/base/span.h>
diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h
index b93c947a..866a2133 100644
--- a/include/libcamera/base/log.h
+++ b/include/libcamera/base/log.h
@@ -10,6 +10,8 @@
#include <chrono>
#include <sstream>
+#include <libcamera/base/private.h>
+
#include <libcamera/base/class.h>
#include <libcamera/base/utils.h>
diff --git a/include/libcamera/base/meson.build b/include/libcamera/base/meson.build
index 6b90f9f7..7c499b55 100644
--- a/include/libcamera/base/meson.build
+++ b/include/libcamera/base/meson.build
@@ -12,6 +12,7 @@ libcamera_base_headers = files([
'log.h',
'message.h',
'object.h',
+ 'private.h',
'semaphore.h',
'signal.h',
'span.h',
diff --git a/include/libcamera/base/private.h b/include/libcamera/base/private.h
new file mode 100644
index 00000000..163012bf
--- /dev/null
+++ b/include/libcamera/base/private.h
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2021, Google Inc.
+ *
+ * private.h - Private Header Validation
+ *
+ * A selection of internal libcamera headers are installed as part
+ * of the libcamera package to allow sharing of a select subset of
+ * internal functionality with IPA module only.
+ *
+ * This functionality is not considered part of the public libcamera
+ * API, and can therefore potentially face ABI instabilities which
+ * should not be exposed to applications. IPA modules however should be
+ * versioned and more closely matched to the libcamera installation.
+ *
+ * Components which include this file can not be included in any file
+ * which forms part of the libcamera API.
+ */
+
+#ifndef LIBCAMERA_BASE_PRIVATE
+#error "Private headers must not be included in the libcamera API"
+#endif
diff --git a/include/libcamera/base/semaphore.h b/include/libcamera/base/semaphore.h
index c8e62e3e..d8146eb8 100644
--- a/include/libcamera/base/semaphore.h
+++ b/include/libcamera/base/semaphore.h
@@ -9,6 +9,7 @@
#include <condition_variable>
+#include <libcamera/base/private.h>
#include <libcamera/base/thread.h>
namespace libcamera {
diff --git a/include/libcamera/base/thread.h b/include/libcamera/base/thread.h
index 2ed18d49..762beab2 100644
--- a/include/libcamera/base/thread.h
+++ b/include/libcamera/base/thread.h
@@ -12,6 +12,8 @@
#include <sys/types.h>
#include <thread>
+#include <libcamera/base/private.h>
+
#include <libcamera/base/message.h>
#include <libcamera/base/signal.h>
#include <libcamera/base/utils.h>
diff --git a/include/libcamera/base/timer.h b/include/libcamera/base/timer.h
index e79e85f1..79882161 100644
--- a/include/libcamera/base/timer.h
+++ b/include/libcamera/base/timer.h
@@ -10,6 +10,8 @@
#include <chrono>
#include <stdint.h>
+#include <libcamera/base/private.h>
+
#include <libcamera/base/object.h>
#include <libcamera/base/signal.h>
diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h
index d1aaff65..07685045 100644
--- a/include/libcamera/base/utils.h
+++ b/include/libcamera/base/utils.h
@@ -19,6 +19,8 @@
#include <utility>
#include <vector>
+#include <libcamera/base/private.h>
+
#ifndef __DOXYGEN__
/* uClibc and uClibc-ng don't provide O_TMPFILE */
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)
diff --git a/test/camera/meson.build b/test/camera/meson.build
index 9cb95aff..002a87b5 100644
--- a/test/camera/meson.build
+++ b/test/camera/meson.build
@@ -12,7 +12,7 @@ camera_tests = [
foreach t : camera_tests
exe = executable(t[0], t[1],
- dependencies : libcamera_dep,
+ dependencies : libcamera_private,
link_with : test_libraries,
include_directories : test_includes_internal)
test(t[0], exe, suite : 'camera', is_parallel : false)
diff --git a/test/ipa/meson.build b/test/ipa/meson.build
index e8a041b5..7938633e 100644
--- a/test/ipa/meson.build
+++ b/test/ipa/meson.build
@@ -7,7 +7,7 @@ ipa_test = [
foreach t : ipa_test
exe = executable(t[0], [t[1], libcamera_generated_ipa_headers],
- dependencies : libcamera_dep,
+ dependencies : libcamera_private,
link_with : [libipa, test_libraries],
include_directories : [libipa_includes, test_includes_internal])
diff --git a/test/ipc/meson.build b/test/ipc/meson.build
index ad47b2fe..2a6cd7fb 100644
--- a/test/ipc/meson.build
+++ b/test/ipc/meson.build
@@ -7,7 +7,7 @@ ipc_tests = [
foreach t : ipc_tests
exe = executable(t[0], t[1],
- dependencies : libcamera_dep,
+ dependencies : libcamera_private,
link_with : test_libraries,
include_directories : test_includes_internal)
diff --git a/test/libtest/meson.build b/test/libtest/meson.build
index 542335ea..351629f3 100644
--- a/test/libtest/meson.build
+++ b/test/libtest/meson.build
@@ -18,7 +18,7 @@ test_includes_internal = [
]
libtest = static_library('libtest', libtest_sources,
- dependencies : libcamera_dep,
+ dependencies : libcamera_private,
include_directories : test_includes_internal)
test_libraries = [libtest]
diff --git a/test/log/meson.build b/test/log/meson.build
index 8cd664e0..ac87841a 100644
--- a/test/log/meson.build
+++ b/test/log/meson.build
@@ -7,7 +7,7 @@ log_test = [
foreach t : log_test
exe = executable(t[0], t[1],
- dependencies : libcamera_dep,
+ dependencies : libcamera_private,
link_with : test_libraries,
include_directories : test_includes_internal)
diff --git a/test/media_device/meson.build b/test/media_device/meson.build
index 1dfcdd8b..83dfe8f1 100644
--- a/test/media_device/meson.build
+++ b/test/media_device/meson.build
@@ -11,12 +11,12 @@ media_device_tests = [
]
lib_mdev_test = static_library('lib_mdev_test', lib_mdev_test_sources,
- dependencies : libcamera_dep,
+ dependencies : libcamera_private,
include_directories : test_includes_internal)
foreach t : media_device_tests
exe = executable(t[0], t[1],
- dependencies : libcamera_dep,
+ dependencies : libcamera_private,
link_with : [test_libraries, lib_mdev_test],
include_directories : test_includes_internal)
diff --git a/test/meson.build b/test/meson.build
index 045ad2a2..b8615e0f 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -64,7 +64,7 @@ endforeach
foreach t : internal_tests
exe = executable(t[0], t[1],
- dependencies : libcamera_dep,
+ dependencies : libcamera_private,
link_with : test_libraries,
include_directories : test_includes_internal)
diff --git a/test/pipeline/ipu3/meson.build b/test/pipeline/ipu3/meson.build
index d062ecd2..16701080 100644
--- a/test/pipeline/ipu3/meson.build
+++ b/test/pipeline/ipu3/meson.build
@@ -6,7 +6,7 @@ ipu3_test = [
foreach t : ipu3_test
exe = executable(t[0], t[1],
- dependencies : libcamera_dep,
+ dependencies : libcamera_private,
link_with : test_libraries,
include_directories : test_includes_internal)
diff --git a/test/pipeline/rkisp1/meson.build b/test/pipeline/rkisp1/meson.build
index ece147b0..364b5711 100644
--- a/test/pipeline/rkisp1/meson.build
+++ b/test/pipeline/rkisp1/meson.build
@@ -6,7 +6,7 @@ rkisp1_test = [
foreach t : rkisp1_test
exe = executable(t[0], t[1],
- dependencies : libcamera_dep,
+ dependencies : libcamera_private,
link_with : test_libraries,
include_directories : test_includes_internal)
diff --git a/test/process/meson.build b/test/process/meson.build
index d2272d50..af86b277 100644
--- a/test/process/meson.build
+++ b/test/process/meson.build
@@ -6,7 +6,7 @@ process_tests = [
foreach t : process_tests
exe = executable(t[0], t[1],
- dependencies : libcamera_dep,
+ dependencies : libcamera_private,
link_with : test_libraries,
include_directories : test_includes_internal)
diff --git a/test/serialization/generated_serializer/meson.build b/test/serialization/generated_serializer/meson.build
index 2460e0b1..9fb9cd1d 100644
--- a/test/serialization/generated_serializer/meson.build
+++ b/test/serialization/generated_serializer/meson.build
@@ -8,7 +8,7 @@ exe = executable('generated_serializer_test',
generated_test_header,
generated_test_serializer,
],
- dependencies : libcamera_dep,
+ dependencies : libcamera_private,
link_with : test_libraries,
include_directories : [
test_includes_internal,
diff --git a/test/serialization/meson.build b/test/serialization/meson.build
index 60ebf325..5446e490 100644
--- a/test/serialization/meson.build
+++ b/test/serialization/meson.build
@@ -9,7 +9,7 @@ serialization_tests = [
foreach t : serialization_tests
exe = executable(t[0], [t[1], 'serialization_test.cpp'],
- dependencies : libcamera_dep,
+ dependencies : libcamera_private,
link_with : test_libraries,
include_directories : test_includes_internal)
test(t[0], exe, suite : 'serialization', is_parallel : true)
diff --git a/test/v4l2_subdevice/meson.build b/test/v4l2_subdevice/meson.build
index 40d39766..d82be3c6 100644
--- a/test/v4l2_subdevice/meson.build
+++ b/test/v4l2_subdevice/meson.build
@@ -7,7 +7,7 @@ v4l2_subdevice_tests = [
foreach t : v4l2_subdevice_tests
exe = executable(t[0], [t[1], 'v4l2_subdevice_test.cpp'],
- dependencies : libcamera_dep,
+ dependencies : libcamera_private,
link_with : test_libraries,
include_directories : test_includes_internal)
test(t[0], exe, suite : 'v4l2_subdevice', is_parallel : false)
diff --git a/test/v4l2_videodevice/meson.build b/test/v4l2_videodevice/meson.build
index e733518c..643f82ed 100644
--- a/test/v4l2_videodevice/meson.build
+++ b/test/v4l2_videodevice/meson.build
@@ -16,7 +16,7 @@ v4l2_videodevice_tests = [
foreach t : v4l2_videodevice_tests
exe = executable(t[0], [t[1], 'v4l2_videodevice_test.cpp'],
- dependencies : libcamera_dep,
+ dependencies : libcamera_private,
link_with : test_libraries,
include_directories : test_includes_internal)
test(t[0], exe, suite : 'v4l2_videodevice', is_parallel : false)