From patchwork Fri Nov 6 10:36:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 10359 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 2BD3ABDB89 for ; Fri, 6 Nov 2020 10:37:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id ECDAA62D26; Fri, 6 Nov 2020 11:37:47 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jyPGshyW"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E01B462D20 for ; Fri, 6 Nov 2020 11:37:46 +0100 (CET) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 09C6BB16; Fri, 6 Nov 2020 11:37:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1604659066; bh=Z10yAF5WVfGs3xHbsPYNgVSbijfkSNyNsgkRAW25wpY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jyPGshyW9K4Hq3JM7F1LfKiG8iD6W97ErEfAMFSY1rtN9YxQF63reeQ+94FhWSZqa ZdPMVZTuDA0qDdYCCa1JhvFWak5ASatw+nnpMxkCsO9WQCMqcg3PM+S4rG5gpdf/7m PMynqX8F4yN5dXDNzzw012CMeQ4Tv+Ope5xWwO9Q= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Fri, 6 Nov 2020 19:36:41 +0900 Message-Id: <20201106103707.49660-12-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201106103707.49660-1-paul.elder@ideasonboard.com> References: <20201106103707.49660-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 11/37] meson: ipa, proxy: Generate headers and proxy with mojo X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 Reviewed-by: Laurent Pinchart --- Changes in v4: - rename module_generated.h.tmpl to module_ipa_interface.h.tmpl - rename module_serializer.h.tmpl to module_ipa_serializer.h.tmpl - rename libcamera_generated headers to libcamera_generated_ipa_headers in meson Changes in v3: - change parser path to our wrapper parser script, instead of running mojo's directly 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 | 78 +++++++++++++++++++ src/libcamera/meson.build | 1 + src/libcamera/proxy/meson.build | 18 +++++ src/libcamera/proxy/worker/meson.build | 19 ++++- .../libcamera_templates/meson.build | 11 +++ utils/ipc/generators/meson.build | 3 + utils/ipc/meson.build | 13 ++++ 7 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 utils/ipc/generators/libcamera_templates/meson.build create mode 100644 utils/ipc/generators/meson.build diff --git a/include/libcamera/ipa/meson.build b/include/libcamera/ipa/meson.build index 508c6bd1..d7a2b6b2 100644 --- a/include/libcamera/ipa/meson.build +++ b/include/libcamera/ipa/meson.build @@ -8,3 +8,81 @@ 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_ipa_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@' + ]) + + # {pipeline}_generated.h + header = custom_target(name + '_ipa_interface_h', + input : mojom, + output : name + '_ipa_interface.h', + depends : mojom_templates, + 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 + '_ipa_serializer_h', + input : mojom, + output : name + '_ipa_serializer.h', + depends : mojom_templates, + 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_templates, + 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_ipa_headers += [header, serializer, proxy_header] +endforeach diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index d6bd9a05..9c889a4f 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -58,6 +58,7 @@ libcamera_sources = files([ ]) libcamera_sources += libcamera_public_headers +libcamera_sources += libcamera_generated_ipa_headers libcamera_sources += libcamera_tracepoint_header includes = [ diff --git a/src/libcamera/proxy/meson.build b/src/libcamera/proxy/meson.build index bd804750..ac68ad08 100644 --- a/src/libcamera/proxy/meson.build +++ b/src/libcamera/proxy/meson.build @@ -4,3 +4,21 @@ 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_templates], + 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..8e0b978a 100644 --- a/src/libcamera/proxy/worker/meson.build +++ b/src/libcamera/proxy/worker/meson.build @@ -6,8 +6,23 @@ 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_templates], + 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_ipa_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..d7c9dea7 --- /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_ipa_interface.h.tmpl', + 'module_ipa_proxy.cpp.tmpl', + 'module_ipa_proxy.h.tmpl', + 'module_ipa_proxy_worker.cpp.tmpl', + 'module_ipa_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 index 59f097f0..4a41b9c1 100644 --- a/utils/ipc/meson.build +++ b/utils/ipc/meson.build @@ -1,3 +1,16 @@ # SPDX-License-Identifier: CC0-1.0 +subdir('generators') + py_modules += ['jinja2', 'ply'] + +mojom_parser = find_program('./parser.py') + +mojom_generator = find_program('./generate.py') + +mojom_templates = custom_target('mojom_templates', + input : mojom_template_files, + output : 'libcamera_templates.zip', + command : [mojom_generator, '-o', '@OUTDIR@', 'precompile']) + +mojom_templates_dir = meson.current_build_dir()