[libcamera-devel] [PATCH 05/23] meson: ipa, proxy: Generate headers and proxy with mojo
Paul Elder
paul.elder at ideasonboard.com
Tue Sep 15 16:20:20 CEST 2020
Run mojo from meson to generate the header, serializer, and proxy files
for every pipeline's mojom data definition file. So far we only have the
raspberrypi mojom file.
Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
---
Dictionaries with non-literal keys is apparently a meson 0.53 feature.
include/libcamera/ipa/meson.build | 87 ++++++++++++++++++++++++++
src/libcamera/proxy/meson.build | 21 +++++++
src/libcamera/proxy/worker/meson.build | 25 +++++++-
3 files changed, 131 insertions(+), 2 deletions(-)
diff --git a/include/libcamera/ipa/meson.build b/include/libcamera/ipa/meson.build
index 508c6bd1..f61a5a8f 100644
--- a/include/libcamera/ipa/meson.build
+++ b/include/libcamera/ipa/meson.build
@@ -8,3 +8,90 @@ libcamera_ipa_headers = files([
install_headers(libcamera_ipa_headers,
subdir: join_paths(libcamera_include_dir, 'ipa'))
+
+#
+# Prepare IPA/IPC generation components
+#
+
+ipa_mojom_files = []
+
+mojom_generator = find_program('../../../utils/ipc/generate.py')
+
+mojom_template = custom_target('mojom_template',
+ output : 'dummy',
+ command : [mojom_generator, 'precompile'])
+
+mojom_parser = find_program('../../../utils/ipc/mojo/public/tools/mojom/mojom_parser.py')
+
+# {pipeline}.mojom-module
+ipa_mojoms = {}
+
+foreach file : ipa_mojom_files
+ name = file.split('.')[0]
+ mojom = custom_target(file.split('.')[0] + '_mojom_module',
+ input : file,
+ output : file + '-module',
+ command : [mojom_parser,
+ '--output-root', meson.build_root(),
+ '--input-root', meson.source_root(),
+ '--mojoms', '@INPUT@'
+ ])
+ ipa_mojoms += { name: mojom }
+endforeach
+
+#
+# Generate headers from templates.
+#
+
+# {pipeline}_generated.h
+# generate {pipeline}_serializer.h
+# generate ipa_proxy_{pipeline}.h
+ipa_headers = {}
+ipa_serializers = {}
+ipa_proxy_headers = {}
+
+foreach name, mojom : ipa_mojoms
+ header = custom_target(name + '_generated_h',
+ input : mojom,
+ output : name + '_generated.h',
+ depends : mojom_template,
+ command : [mojom_generator, 'generate',
+ '-g', 'libcamera',
+ '--bytecode_path', '.',
+ '--libcamera_generate_header',
+ '--libcamera_output_path=@OUTPUT@',
+ './' +'@INPUT@'
+ ])
+
+ serializer = custom_target(name + '_serializer_h',
+ input : mojom,
+ output : name + '_serializer.h',
+ depends : mojom_template,
+ command : [mojom_generator, 'generate',
+ '-g', 'libcamera',
+ '--bytecode_path', '.',
+ '--libcamera_generate_serializer',
+ '--libcamera_output_path=@OUTPUT@',
+ './' +'@INPUT@'
+ ])
+
+ proxy_header = custom_target(name + '_proxy_h',
+ input : mojom,
+ output : 'ipa_proxy_' + name + '.h',
+ depends : mojom_template,
+ command : [mojom_generator, 'generate',
+ '-g', 'libcamera',
+ '--bytecode_path', '.',
+ '--libcamera_generate_proxy_h',
+ '--libcamera_output_path=@OUTPUT@',
+ './' +'@INPUT@'
+ ])
+
+ ipa_headers += { name: header }
+ ipa_serializers += { name: serializer }
+ ipa_proxy_headers += { name: proxy_header }
+endforeach
+
+libcamera_internal_headers += ipa_proxy_headers
+libcamera_internal_headers += ipa_headers
+libcamera_internal_headers += ipa_serializers
diff --git a/src/libcamera/proxy/meson.build b/src/libcamera/proxy/meson.build
index bd804750..b0d35646 100644
--- a/src/libcamera/proxy/meson.build
+++ b/src/libcamera/proxy/meson.build
@@ -4,3 +4,24 @@ libcamera_sources += files([
'ipa_proxy_linux.cpp',
'ipa_proxy_thread.cpp',
])
+
+# generate ipa_proxy_{pipeline}.cpp
+ipa_proxy_sources = []
+
+foreach name, mojom : ipa_mojoms
+ ipa_proxy_sources += custom_target(name + '_proxy_cpp',
+ input : mojom,
+ output : 'ipa_proxy_' + name + '.cpp',
+ depends : [mojom_template,
+ ipa_headers[name],
+ ipa_serializers[name],
+ ipa_proxy_headers[name]],
+ command : [mojom_generator, 'generate',
+ '-g', 'libcamera',
+ '--bytecode_path', '.',
+ '--libcamera_generate_proxy_cpp',
+ '--libcamera_output_path=@OUTPUT@',
+ './' + '@INPUT@'])
+endforeach
+
+libcamera_sources += ipa_proxy_sources
diff --git a/src/libcamera/proxy/worker/meson.build b/src/libcamera/proxy/worker/meson.build
index ac0310a7..c35be70c 100644
--- a/src/libcamera/proxy/worker/meson.build
+++ b/src/libcamera/proxy/worker/meson.build
@@ -4,10 +4,31 @@ ipa_proxy_sources = [
['ipa_proxy_linux', 'ipa_proxy_linux_worker.cpp']
]
+# generate ipa_proxy_{pipeline}_worker.cpp
+ipa_proxy_sources = {}
+
+foreach name, mojom : ipa_mojoms
+ worker = custom_target(name + '_proxy_worker',
+ input : mojom,
+ output : 'ipa_proxy_' + name + '_worker.cpp',
+ depends : [mojom_template,
+ ipa_headers[name],
+ ipa_serializers[name],
+ ipa_proxy_headers[name]],
+ command : [mojom_generator, 'generate',
+ '-g', 'libcamera',
+ '--bytecode_path', '.',
+ '--libcamera_generate_proxy_worker',
+ '--libcamera_output_path=@OUTPUT@',
+ './' + '@INPUT@'
+ ])
+ ipa_proxy_sources += { 'ipa_proxy_' + name : worker }
+endforeach
+
proxy_install_dir = join_paths(get_option('libexecdir'), 'libcamera')
-foreach t : ipa_proxy_sources
- proxy = executable(t[0], t[1],
+foreach k, t : ipa_proxy_sources
+ proxy = executable(k, t,
install : true,
install_dir : proxy_install_dir,
dependencies : libcamera_dep)
--
2.27.0
More information about the libcamera-devel
mailing list