From patchwork Fri Aug 9 00:59:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20851 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 E261CBE173 for ; Fri, 9 Aug 2024 00:59:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 19C3B633BD; Fri, 9 Aug 2024 02:59:44 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="rThDv1Pb"; 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 4F4176337E for ; Fri, 9 Aug 2024 02:59:40 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 59DA083F for ; Fri, 9 Aug 2024 02:58:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1723165126; bh=Cg8pAQzex1NdRaF1U100ZMUm9brX4D/j6NRkEQDwsOs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=rThDv1PbHjY8pUTC+XoA1fRHj8BxXh7cEZRJxVn+yEkismiDK1WYc2FDIteRkoldj 0/rE6XP1Pp7xz0d9YJGQ/VMUTDavcBXZ7qOxdG+wOoUDmA1K+hMewSA+eRWC4j/Dy2 0lgIFmV5CdouGrxT+fX12+jvVd627oiJXGkxCLNA= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH 01/10] meson: Store controls and properties YAML files in variables Date: Fri, 9 Aug 2024 03:59:05 +0300 Message-ID: <20240809005914.20662-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240809005914.20662-1-laurent.pinchart@ideasonboard.com> References: <20240809005914.20662-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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" When generating control headers, the YAML files to be used are determined dynamically based on the selected pipeline handlers. As part of this process, the build system populates an array of meson File objects used an an input for the control headers generation custom target, as well as an array of file names (as strings). The file names array is later used to generate the control source files for the libcamera core, as well as the source code for controls support in the Python bindings. Both of the source code generators manually turn the array of file names into File objects. This duplicates code and reduces readability. A third similar implementation has also been proposed to generate control support sources in the GStreamer element, making the issue worse. To simplify this, store File objects instead of file names in the controls_files array. As the meson configuration summary doesn't support File objects, create a separate controls_files_names to store the file names for that sole purpose. The exact same process occurs for properties, address them the same way. Signed-off-by: Laurent Pinchart Reviewed-by: Daniel Scally Reviewed-by: Paul Elder --- include/libcamera/meson.build | 8 ++++++-- meson.build | 4 ++-- src/libcamera/meson.build | 2 -- src/py/libcamera/meson.build | 15 ++------------- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index c8c900eba66a..36de1c2a393c 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -47,7 +47,9 @@ controls_map = { control_headers = [] controls_files = [] +controls_files_names = [] properties_files = [] +properties_files_names = [] foreach mode, entry : controls_map files_list = [] @@ -70,10 +72,12 @@ foreach mode, entry : controls_map outfile = '' if mode == 'controls' outfile = 'control_ids.h' - controls_files += files_list + controls_files += input_files + controls_files_names += files_list else outfile = 'property_ids.h' - properties_files += files_list + properties_files += input_files + properties_files_names += files_list endif template_file = files(outfile + '.in') diff --git a/meson.build b/meson.build index 59293e478b00..432ae1337b4a 100644 --- a/meson.build +++ b/meson.build @@ -278,8 +278,8 @@ py_mod.find_installation('python3', modules : py_modules) summary({ 'Enabled pipelines': pipelines, 'Enabled IPA modules': enabled_ipa_names, - 'Controls files': controls_files, - 'Properties files': properties_files, + 'Controls files': controls_files_names, + 'Properties files': properties_files_names, 'Hotplug support': libudev.found(), 'Tracing support': tracing_enabled, 'Android support': android_enabled, diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index c3efc5278ec8..79b8cbaf1311 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -134,8 +134,6 @@ controls_mode_files = { } foreach mode, input_files : controls_mode_files - input_files = files(input_files) - if mode == 'controls' template_file = files('control_ids.cpp.in') else diff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build index 4807ca7d75ed..2e67407598db 100644 --- a/src/py/libcamera/meson.build +++ b/src/py/libcamera/meson.build @@ -28,32 +28,21 @@ pycamera_sources = files([ # Generate controls -gen_py_controls_input_files = [] gen_py_controls_template = files('py_controls_generated.cpp.in') - gen_py_controls = files('gen-py-controls.py') -foreach file : controls_files - gen_py_controls_input_files += files('../../libcamera/' + file) -endforeach - pycamera_sources += custom_target('py_gen_controls', - input : gen_py_controls_input_files, + input : controls_files, output : ['py_controls_generated.cpp'], command : [gen_py_controls, '--mode', 'controls', '-o', '@OUTPUT@', '-t', gen_py_controls_template, '@INPUT@']) # Generate properties -gen_py_property_enums_input_files = [] gen_py_properties_template = files('py_properties_generated.cpp.in') -foreach file : properties_files - gen_py_property_enums_input_files += files('../../libcamera/' + file) -endforeach - pycamera_sources += custom_target('py_gen_properties', - input : gen_py_property_enums_input_files, + input : properties_files, output : ['py_properties_generated.cpp'], command : [gen_py_controls, '--mode', 'properties', '-o', '@OUTPUT@', '-t', gen_py_properties_template, '@INPUT@'])