summaryrefslogtreecommitdiffstats
path: root/documentation/dev-manual/gobject-introspection.rst
diff options
context:
space:
mode:
authorMichael Opdenacker <michael.opdenacker@bootlin.com>2022-11-24 17:50:52 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-12-01 19:20:29 +0000
commit945c669138a76be18c6b4da4f8f907d2a5cfd83f (patch)
treecebff3cae5021d4fcceb5aa51fce1c2aead97ed2 /documentation/dev-manual/gobject-introspection.rst
parent6fe3143800925463279d0664fc7f3372b53c6c52 (diff)
downloadpoky-945c669138a76be18c6b4da4f8f907d2a5cfd83f.tar.gz
manuals: split dev-manual/common-tasks.rst
A 500 KB source file is always harder to manage, and can have section title conflicts. So, the "Common Tasks" document is gone and all its constituents are moved up one level. You now have 40 chapters in the Development Tasks Manual. (From yocto-docs rev: 8a45bc469411410020b8e688c137395fcaf3761b) Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'documentation/dev-manual/gobject-introspection.rst')
-rw-r--r--documentation/dev-manual/gobject-introspection.rst157
1 files changed, 157 insertions, 0 deletions
diff --git a/documentation/dev-manual/gobject-introspection.rst b/documentation/dev-manual/gobject-introspection.rst
new file mode 100644
index 0000000000..89f21b7d10
--- /dev/null
+++ b/documentation/dev-manual/gobject-introspection.rst
@@ -0,0 +1,157 @@
1.. SPDX-License-Identifier: CC-BY-SA-2.0-UK
2
3Enabling GObject Introspection Support
4**************************************
5
6`GObject introspection <https://gi.readthedocs.io/en/latest/>`__
7is the standard mechanism for accessing GObject-based software from
8runtime environments. GObject is a feature of the GLib library that
9provides an object framework for the GNOME desktop and related software.
10GObject Introspection adds information to GObject that allows objects
11created within it to be represented across different programming
12languages. If you want to construct GStreamer pipelines using Python, or
13control UPnP infrastructure using Javascript and GUPnP, GObject
14introspection is the only way to do it.
15
16This section describes the Yocto Project support for generating and
17packaging GObject introspection data. GObject introspection data is a
18description of the API provided by libraries built on top of the GLib
19framework, and, in particular, that framework's GObject mechanism.
20GObject Introspection Repository (GIR) files go to ``-dev`` packages,
21``typelib`` files go to main packages as they are packaged together with
22libraries that are introspected.
23
24The data is generated when building such a library, by linking the
25library with a small executable binary that asks the library to describe
26itself, and then executing the binary and processing its output.
27
28Generating this data in a cross-compilation environment is difficult
29because the library is produced for the target architecture, but its
30code needs to be executed on the build host. This problem is solved with
31the OpenEmbedded build system by running the code through QEMU, which
32allows precisely that. Unfortunately, QEMU does not always work
33perfectly as mentioned in the ":ref:`dev-manual/gobject-introspection:known issues`"
34section.
35
36Enabling the Generation of Introspection Data
37=============================================
38
39Enabling the generation of introspection data (GIR files) in your
40library package involves the following:
41
421. Inherit the
43 :ref:`gobject-introspection <ref-classes-gobject-introspection>`
44 class.
45
462. Make sure introspection is not disabled anywhere in the recipe or
47 from anything the recipe includes. Also, make sure that
48 "gobject-introspection-data" is not in
49 :term:`DISTRO_FEATURES_BACKFILL_CONSIDERED`
50 and that "qemu-usermode" is not in
51 :term:`MACHINE_FEATURES_BACKFILL_CONSIDERED`.
52 In either of these conditions, nothing will happen.
53
543. Try to build the recipe. If you encounter build errors that look like
55 something is unable to find ``.so`` libraries, check where these
56 libraries are located in the source tree and add the following to the
57 recipe::
58
59 GIR_EXTRA_LIBS_PATH = "${B}/something/.libs"
60
61 .. note::
62
63 See recipes in the ``oe-core`` repository that use that
64 :term:`GIR_EXTRA_LIBS_PATH` variable as an example.
65
664. Look for any other errors, which probably mean that introspection
67 support in a package is not entirely standard, and thus breaks down
68 in a cross-compilation environment. For such cases, custom-made fixes
69 are needed. A good place to ask and receive help in these cases is
70 the :ref:`Yocto Project mailing
71 lists <resources-mailinglist>`.
72
73.. note::
74
75 Using a library that no longer builds against the latest Yocto
76 Project release and prints introspection related errors is a good
77 candidate for the previous procedure.
78
79Disabling the Generation of Introspection Data
80==============================================
81
82You might find that you do not want to generate introspection data. Or,
83perhaps QEMU does not work on your build host and target architecture
84combination. If so, you can use either of the following methods to
85disable GIR file generations:
86
87- Add the following to your distro configuration::
88
89 DISTRO_FEATURES_BACKFILL_CONSIDERED = "gobject-introspection-data"
90
91 Adding this statement disables generating introspection data using
92 QEMU but will still enable building introspection tools and libraries
93 (i.e. building them does not require the use of QEMU).
94
95- Add the following to your machine configuration::
96
97 MACHINE_FEATURES_BACKFILL_CONSIDERED = "qemu-usermode"
98
99 Adding this statement disables the use of QEMU when building packages for your
100 machine. Currently, this feature is used only by introspection
101 recipes and has the same effect as the previously described option.
102
103 .. note::
104
105 Future releases of the Yocto Project might have other features
106 affected by this option.
107
108If you disable introspection data, you can still obtain it through other
109means such as copying the data from a suitable sysroot, or by generating
110it on the target hardware. The OpenEmbedded build system does not
111currently provide specific support for these techniques.
112
113Testing that Introspection Works in an Image
114============================================
115
116Use the following procedure to test if generating introspection data is
117working in an image:
118
1191. Make sure that "gobject-introspection-data" is not in
120 :term:`DISTRO_FEATURES_BACKFILL_CONSIDERED`
121 and that "qemu-usermode" is not in
122 :term:`MACHINE_FEATURES_BACKFILL_CONSIDERED`.
123
1242. Build ``core-image-sato``.
125
1263. Launch a Terminal and then start Python in the terminal.
127
1284. Enter the following in the terminal::
129
130 >>> from gi.repository import GLib
131 >>> GLib.get_host_name()
132
1335. For something a little more advanced, enter the following see:
134 https://python-gtk-3-tutorial.readthedocs.io/en/latest/introduction.html
135
136Known Issues
137============
138
139Here are know issues in GObject Introspection Support:
140
141- ``qemu-ppc64`` immediately crashes. Consequently, you cannot build
142 introspection data on that architecture.
143
144- x32 is not supported by QEMU. Consequently, introspection data is
145 disabled.
146
147- musl causes transient GLib binaries to crash on assertion failures.
148 Consequently, generating introspection data is disabled.
149
150- Because QEMU is not able to run the binaries correctly, introspection
151 is disabled for some specific packages under specific architectures
152 (e.g. ``gcr``, ``libsecret``, and ``webkit``).
153
154- QEMU usermode might not work properly when running 64-bit binaries
155 under 32-bit host machines. In particular, "qemumips64" is known to
156 not work under i686.
157