blob: d0052cd623175749c675ee6f4cb47ce5b17cd8da [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7# Inherit this class in recipes to enable building their introspection files
8
9# python3native is inherited to prevent introspection tools being run with
10# host's python 3 (they need to be run with native python 3)
11#
12# This also sets up autoconf-based recipes to build introspection data (or not),
13# depending on distro and machine features (see gobject-introspection-data class).
14inherit python3native gobject-introspection-data
15
16# meson: default option name to enable/disable introspection. This matches most
17# project's configuration. In doubts - check meson_options.txt in project's
18# source path.
19GIR_MESON_OPTION ?= 'introspection'
20GIR_MESON_ENABLE_FLAG ?= 'true'
21GIR_MESON_DISABLE_FLAG ?= 'false'
22
23# Define g-i options such that they can be disabled completely when GIR_MESON_OPTION is empty
24GIRMESONTARGET = "-D${GIR_MESON_OPTION}=${@bb.utils.contains('GI_DATA_ENABLED', 'True', '${GIR_MESON_ENABLE_FLAG}', '${GIR_MESON_DISABLE_FLAG}', d)} "
25GIRMESONBUILD = "-D${GIR_MESON_OPTION}=${GIR_MESON_DISABLE_FLAG} "
26# Auto enable/disable based on GI_DATA_ENABLED
27EXTRA_OECONF:prepend:class-target = "${@bb.utils.contains('GI_DATA_ENABLED', 'True', '--enable-introspection', '--disable-introspection', d)} "
28EXTRA_OEMESON:prepend:class-target = "${@['', '${GIRMESONTARGET}'][d.getVar('GIR_MESON_OPTION') != '']}"
29# When building native recipes, disable introspection, as it is not necessary,
30# pulls in additional dependencies, and makes build times longer
31EXTRA_OECONF:prepend:class-native = "--disable-introspection "
32EXTRA_OECONF:prepend:class-nativesdk = "--disable-introspection "
33EXTRA_OEMESON:prepend:class-native = "${@['', '${GIRMESONBUILD}'][d.getVar('GIR_MESON_OPTION') != '']}"
34EXTRA_OEMESON:prepend:class-nativesdk = "${@['', '${GIRMESONBUILD}'][d.getVar('GIR_MESON_OPTION') != '']}"
35
36# Generating introspection data depends on a combination of native and target
37# introspection tools, and qemu to run the target tools.
Patrick Williamse760df82023-05-26 11:10:49 -050038DEPENDS:append:class-target = " ${@bb.utils.contains('GI_DATA_ENABLED', 'True', 'gobject-introspection qemu-native', '', d)}"
Patrick Williams92b42cb2022-09-03 06:53:57 -050039
Patrick Williamse760df82023-05-26 11:10:49 -050040# Even when introspection is disabled, the gobject-introspection package is still needed for m4 macros.
41DEPENDS:append = " gobject-introspection-native"
Patrick Williams92b42cb2022-09-03 06:53:57 -050042
43# This is used by introspection tools to find .gir includes
44export XDG_DATA_DIRS = "${STAGING_DATADIR}:${STAGING_LIBDIR}"
45
46do_configure:prepend:class-target () {
Patrick Williamse760df82023-05-26 11:10:49 -050047 # introspection.m4 pre-packaged with upstream tarballs does not yet
48 # have our fixes
49 mkdir -p ${S}/m4
50 cp ${STAGING_DIR_NATIVE}/${datadir}/aclocal/introspection.m4 ${S}/m4
Patrick Williams92b42cb2022-09-03 06:53:57 -050051}
52
Patrick Williams56b44a92024-01-19 08:49:29 -060053do_compile:prepend() {
54 # This prevents g-ir-scanner from writing cache data to $HOME
55 export GI_SCANNER_DISABLE_CACHE=1
56}
57
Patrick Williams92b42cb2022-09-03 06:53:57 -050058# .typelib files are needed at runtime and so they go to the main package (so
59# they'll be together with libraries they support).
60FILES:${PN}:append = " ${libdir}/girepository-*/*.typelib"
61
62# .gir files go to dev package, as they're needed for developing (but not for
63# running) things that depends on introspection.
64FILES:${PN}-dev:append = " ${datadir}/gir-*/*.gir ${libdir}/gir-*/*.gir"