From patchwork Thu May 27 05:32:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12435 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 1B992BDB80 for ; Thu, 27 May 2021 05:32:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 920DF68924; Thu, 27 May 2021 07:32:54 +0200 (CEST) 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="JLI9ORCp"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5C1DF6891F for ; Thu, 27 May 2021 07:32:53 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D1CF78DE; Thu, 27 May 2021 07:32:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1622093573; bh=B+vcNZDxjfiHzqQxZGDB1Jevljx3n/7Lk2ch6jO7TvY=; h=From:To:Cc:Subject:Date:From; b=JLI9ORCpnyGkRyh2JzlSesMgbdSgoty7Ix56rpjWR0RCahozzsHmzlNjOYg0C1OMt uD6myg106LlU0pJ23uFJtZYDbCZntxRpS9xEd/RtzBgpQVzqDGLhZrqlHgTLXctJd3 tN3aMbyfP1rlu4IpXOBKf8VGW1QjSTRmRa//zHKw= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 27 May 2021 14:32:30 +0900 Message-Id: <20210527053230.1329602-1-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] utils: ipc: mojo: Error if ControlInfoMap/List doesn't prefix libcamera 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" The mojo parser is fine if there are types that are used in array/map members that it does not know about. These are usually caught by the C++ compiler, because the generated code refers to unknown types. This feature is necessary for us for supporting FrameBuffer::Plane as an array/map member, since as long as the type has an IPADataSerializer and the struct defined in C++, the generated code will run fine (FrameBuffer::Plane is not defined anywhere in mojom but is used as an array member in IPABuffer). The types that are defined in controls.h (or any header included in ipa_interface.h) will all be compiled by the C++ compiler fine, since the generated files all include controls.h. The types that are there that are not ControlInfoMap or ControlList (like ControlValue) will still fail at the linker stage. For example: struct A { array a; }; will compile fine, but will fail to link, since IPADataSerializer doesn't exist. This behavior, although not the best, is acceptable. The issue is that if ControlInfoMap or ControlList are used as array/map members without the libcamera prefix, the compiler will not complain, as the types are valid, and the linker will also not complain, as IPADataSerializer and IPADataSerializer both exist. However, the code generator will not recognize them as types that require a ControlSerializer (since mojo doesn't recognize them, so they are different from the ones that it does recognize with the libcamera namespace), and so the ControlSerializer will not be passed to the serializer in the generated code. This is the cause of the FATAL breakage: FATAL IPADataSerializer ipa_data_serializer.cpp:437 ControlSerializer not provided for serialization of ControlInfoMap Since ControlInfoMap and ControlList are the only types that will run into this issue, we solve this by simply detecting if they are used without the prefix, and produce an error at that point in the code generator. As the code generator stage no longer has information on the source code file and line, we output the struct name in which the error was found (ninja will output the file name). Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- utils/ipc/generators/mojom_libcamera_generator.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/utils/ipc/generators/mojom_libcamera_generator.py b/utils/ipc/generators/mojom_libcamera_generator.py index effdfed6..25cacf9a 100644 --- a/utils/ipc/generators/mojom_libcamera_generator.py +++ b/utils/ipc/generators/mojom_libcamera_generator.py @@ -129,6 +129,10 @@ def GetAllAttrs(element): def NeedsControlSerializer(element): types = GetAllTypes(element) + if 'x:ControlList' in types: + raise Exception(f'Unknown type "ControlList" in {element.mojom_name}, did you mean "libcamera.ControlList"?') + if 'x:ControlInfoMap' in types: + raise Exception(f'Unknown type "ControlInfoMap" in {element.mojom_name}, did you mean "libcamera.ControlInfoMap"?') return "ControlList" in types or "ControlInfoMap" in types def HasFd(element):