libcamera/utils
Paul Elder ae7419869a utils: ipc: mojo: Error if ControlInfoMap/List doesn't prefix libcamera
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<ControlValue> a;
};

will compile fine, but will fail to link, since
IPADataSerializer<ControlValue> 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<ControlList> and IPADataSerializer<ControlInfoMap>
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 <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-06-01 18:52:05 +09:00
..
hooks utils: hooks: pre-push: Reject commits with a Change-Id 2020-11-02 01:03:31 +02:00
ipc utils: ipc: mojo: Error if ControlInfoMap/List doesn't prefix libcamera 2021-06-01 18:52:05 +09:00
ipu3 licenses: License all meson files under CC0-1.0 2020-05-13 16:46:24 +03:00
raspberrypi utils: raspberrypi: Add a DelayedControls log parser 2021-03-12 14:12:55 +00:00
rkisp1 utils: rkisp1: Don't enable immutable link 2020-03-20 01:44:57 +01:00
tracepoints utils: tracepoints: Add simple statistics script 2020-11-03 11:33:41 +09:00
checkstyle.py utils: checkstyle.py: Handle renamed files in header add checker 2021-02-16 12:30:39 +02:00
gen-controls.py utils: gen-controls: Fix enumerators documentation 2020-12-27 12:28:00 +02:00
gen-formats.py utils: gen-formats: Support big-endian DRM formats 2021-02-01 22:33:55 +02:00
gen-header.sh libcamera: Move Header generation utilities to utils 2020-09-24 10:55:49 +01:00
gen-ipa-priv-key.sh libcamera: ipa: Move key generation to utils 2020-09-24 10:56:22 +01:00
gen-ipa-pub-key.py libcamera: ipa: Move key generation to utils 2020-09-24 10:56:22 +01:00
gen-version.sh libcamera: Add build time to version string for dirty builds 2020-08-06 16:20:15 +02:00
meson.build README, meson: Add dependency on ply and jinja2 for IPA interface generation 2020-11-11 19:23:16 +09:00
update-kernel-headers.sh utils: Add kernel headers update script 2021-03-08 16:54:29 +02:00
update-mojo.sh utils: update-mojo.sh: Add script for updating mojo 2021-05-26 13:03:12 +09:00