[libcamera-devel] [PATCH 11/38] meson: ipa, proxy: Generate headers and proxy with mojo
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Tue Sep 29 06:20:33 CEST 2020
Hi Paul,
Thank you for the patch.
On Tue, Sep 22, 2020 at 10:35:10PM +0900, Paul Elder wrote:
> Run mojo from meson to generate the header, serializer, and proxy files
> for every pipeline's mojom data definition file.
>
> Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
>
> ---
> This patch depends on the patch series "Unify utils locations".
This has now been merged :-)
> Changes in v2:
> - clean up loops
> - remove non-literal keys in maps
> - move loading the mojom scripts to utils/
> - declare the template files in meson
> - add the generated headers into libcamera_generated_headers instead of
> libcamera_internal_headers
> - add libcamera_generated_headers to libcamera_sources
> ---
> include/libcamera/ipa/meson.build | 74 +++++++++++++++++++
> src/libcamera/meson.build | 1 +
> src/libcamera/proxy/meson.build | 16 ++++
> src/libcamera/proxy/worker/meson.build | 18 ++++-
> .../libcamera_templates/meson.build | 11 +++
> utils/ipc/generators/meson.build | 3 +
> utils/ipc/meson.build | 14 ++++
> utils/meson.build | 1 +
> 8 files changed, 136 insertions(+), 2 deletions(-)
> create mode 100644 utils/ipc/generators/libcamera_templates/meson.build
> create mode 100644 utils/ipc/generators/meson.build
> create mode 100644 utils/ipc/meson.build
>
> diff --git a/include/libcamera/ipa/meson.build b/include/libcamera/ipa/meson.build
> index 508c6bd1..c6231f2c 100644
> --- a/include/libcamera/ipa/meson.build
> +++ b/include/libcamera/ipa/meson.build
> @@ -8,3 +8,77 @@ libcamera_ipa_headers = files([
>
> install_headers(libcamera_ipa_headers,
> subdir: join_paths(libcamera_include_dir, 'ipa'))
> +
> +#
> +# Prepare IPA/IPC generation components
> +#
> +
> +ipa_mojom_files = []
> +
> +ipa_mojoms = []
> +
> +#
> +# Generate headers from templates.
> +#
> +
> +libcamera_generated_headers = []
> +
> +foreach file : ipa_mojom_files
> + name = file.split('.')[0]
> +
> + # {pipeline}.mojom-module
> + 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@'
> + ])
I wonder if this would be a bit more readable.
command : [
mojom_parser,
'--output-root', meson.build_root(),
'--input-root', meson.source_root(),
'--mojoms', '@INPUT@'
])
Up to you (and if you like it, the comment applies to multiple locations
below).
> +
> + # {pipeline}_generated.h
> + header = custom_target(name + '_generated_h',
> + input : mojom,
> + output : name + '_generated.h',
> + depends : mojom_template,
> + command : [mojom_generator, 'generate',
> + '-g', 'libcamera',
> + '--bytecode_path', mojom_templates_dir,
> + '--libcamera_generate_header',
> + '--libcamera_output_path=@OUTPUT@',
> + './' +'@INPUT@'
> + ])
> +
> + # {pipeline}_serializer.h
> + serializer = custom_target(name + '_serializer_h',
> + input : mojom,
> + output : name + '_serializer.h',
> + depends : mojom_template,
> + command : [mojom_generator, 'generate',
> + '-g', 'libcamera',
> + '--bytecode_path', mojom_templates_dir,
> + '--libcamera_generate_serializer',
> + '--libcamera_output_path=@OUTPUT@',
> + './' +'@INPUT@'
> + ])
> +
> + # ipa_proxy_{pipeline}.h
> + 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', mojom_templates_dir,
> + '--libcamera_generate_proxy_h',
> + '--libcamera_output_path=@OUTPUT@',
> + './' +'@INPUT@'
> + ])
> +
> + ipa_mojoms += {
> + 'name': name,
> + 'mojom': mojom,
> + }
> +
> + libcamera_generated_headers += [header, serializer, proxy_header]
> +endforeach
> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> index 27182bfc..9d7442fa 100644
> --- a/src/libcamera/meson.build
> +++ b/src/libcamera/meson.build
> @@ -54,6 +54,7 @@ libcamera_sources = files([
>
> libcamera_sources += libcamera_public_headers
> libcamera_sources += libcamera_internal_headers
> +libcamera_sources += libcamera_generated_headers
>
> includes = [
> libcamera_includes,
> diff --git a/src/libcamera/proxy/meson.build b/src/libcamera/proxy/meson.build
> index bd804750..bacf800f 100644
> --- a/src/libcamera/proxy/meson.build
> +++ b/src/libcamera/proxy/meson.build
> @@ -4,3 +4,19 @@ libcamera_sources += files([
> 'ipa_proxy_linux.cpp',
> 'ipa_proxy_thread.cpp',
> ])
> +
> +# generate ipa_proxy_{pipeline}.cpp
> +foreach mojom : ipa_mojoms
> + proxy = custom_target(mojom['name'] + '_proxy_cpp',
> + input : mojom['mojom'],
> + output : 'ipa_proxy_' + mojom['name'] + '.cpp',
> + depends : [mojom_template],
> + command : [mojom_generator, 'generate',
> + '-g', 'libcamera',
> + '--bytecode_path', mojom_templates_dir,
> + '--libcamera_generate_proxy_cpp',
> + '--libcamera_output_path=@OUTPUT@',
> + './' + '@INPUT@'])
> +
> + libcamera_sources += proxy
> +endforeach
> diff --git a/src/libcamera/proxy/worker/meson.build b/src/libcamera/proxy/worker/meson.build
> index ac0310a7..836d1759 100644
> --- a/src/libcamera/proxy/worker/meson.build
> +++ b/src/libcamera/proxy/worker/meson.build
> @@ -6,8 +6,22 @@ ipa_proxy_sources = [
>
> proxy_install_dir = join_paths(get_option('libexecdir'), 'libcamera')
>
> -foreach t : ipa_proxy_sources
> - proxy = executable(t[0], t[1],
> +# generate ipa_proxy_{pipeline}_worker.cpp
> +foreach mojom : ipa_mojoms
> + worker = custom_target(mojom['name'] + '_proxy_worker',
> + input : mojom['mojom'],
> + output : 'ipa_proxy_' + mojom['name'] + '_worker.cpp',
> + depends : [mojom_template],
> + command : [mojom_generator, 'generate',
> + '-g', 'libcamera',
> + '--bytecode_path', mojom_templates_dir,
> + '--libcamera_generate_proxy_worker',
> + '--libcamera_output_path=@OUTPUT@',
> + './' + '@INPUT@'
> + ])
> +
> + proxy = executable('ipa_proxy_' + mojom['name'],
> + [worker, libcamera_generated_headers],
> install : true,
> install_dir : proxy_install_dir,
> dependencies : libcamera_dep)
> diff --git a/utils/ipc/generators/libcamera_templates/meson.build b/utils/ipc/generators/libcamera_templates/meson.build
> new file mode 100644
> index 00000000..d0a7449f
> --- /dev/null
> +++ b/utils/ipc/generators/libcamera_templates/meson.build
> @@ -0,0 +1,11 @@
> +# SPDX-License-Identifier: CC0-1.0
> +
> +mojom_template_files = files([
> + 'module_generated.h.tmpl',
> + 'module_ipa_proxy.cpp.tmpl',
> + 'module_ipa_proxy.h.tmpl',
> + 'module_ipa_proxy_worker.cpp.tmpl',
> + 'module_serializer.h.tmpl',
> + 'proxy_functions.tmpl',
> + 'serializer.tmpl',
> +])
> diff --git a/utils/ipc/generators/meson.build b/utils/ipc/generators/meson.build
> new file mode 100644
> index 00000000..504f1a46
> --- /dev/null
> +++ b/utils/ipc/generators/meson.build
> @@ -0,0 +1,3 @@
> +# SPDX-License-Identifier: CC0-1.0
> +
> +subdir('libcamera_templates')
> diff --git a/utils/ipc/meson.build b/utils/ipc/meson.build
> new file mode 100644
> index 00000000..9f7b7cc0
> --- /dev/null
> +++ b/utils/ipc/meson.build
> @@ -0,0 +1,14 @@
> +# SPDX-License-Identifier: CC0-1.0
> +
> +subdir('generators')
> +
> +mojom_parser = find_program('./mojo/public/tools/mojom/mojom_parser.py')
I'm afraid you will need to add a parser.py wrapper to set
sys.dont_write_bytecode.
> +
> +mojom_generator = find_program('./generate.py')
> +
> +mojom_template = custom_target('mojom_template',
Maybe mojom_templates, as it contains all templates ?
I remember when you told me you had to fight against meson. It seems the
two of you have not only reached a truce, but became friends. Nice :-)
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> + input : mojom_template_files,
> + output : 'libcamera_templates.zip',
> + command : [mojom_generator, '-o', '@OUTDIR@', 'precompile'])
> +
> +mojom_templates_dir = meson.current_build_dir()
> diff --git a/utils/meson.build b/utils/meson.build
> index a069e1ca..5dfb0741 100644
> --- a/utils/meson.build
> +++ b/utils/meson.build
> @@ -1,5 +1,6 @@
> # SPDX-License-Identifier: CC0-1.0
>
> +subdir('ipc')
> subdir('ipu3')
>
> ## Generates control_ids.h and property_ids.h
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list