Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1 | # |
| 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). |
| 14 | inherit 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. |
| 19 | GIR_MESON_OPTION ?= 'introspection' |
| 20 | GIR_MESON_ENABLE_FLAG ?= 'true' |
| 21 | GIR_MESON_DISABLE_FLAG ?= 'false' |
| 22 | |
| 23 | # Define g-i options such that they can be disabled completely when GIR_MESON_OPTION is empty |
| 24 | GIRMESONTARGET = "-D${GIR_MESON_OPTION}=${@bb.utils.contains('GI_DATA_ENABLED', 'True', '${GIR_MESON_ENABLE_FLAG}', '${GIR_MESON_DISABLE_FLAG}', d)} " |
| 25 | GIRMESONBUILD = "-D${GIR_MESON_OPTION}=${GIR_MESON_DISABLE_FLAG} " |
| 26 | # Auto enable/disable based on GI_DATA_ENABLED |
| 27 | EXTRA_OECONF:prepend:class-target = "${@bb.utils.contains('GI_DATA_ENABLED', 'True', '--enable-introspection', '--disable-introspection', d)} " |
| 28 | EXTRA_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 |
| 31 | EXTRA_OECONF:prepend:class-native = "--disable-introspection " |
| 32 | EXTRA_OECONF:prepend:class-nativesdk = "--disable-introspection " |
| 33 | EXTRA_OEMESON:prepend:class-native = "${@['', '${GIRMESONBUILD}'][d.getVar('GIR_MESON_OPTION') != '']}" |
| 34 | EXTRA_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 Williams | e760df8 | 2023-05-26 11:10:49 -0500 | [diff] [blame] | 38 | DEPENDS:append:class-target = " ${@bb.utils.contains('GI_DATA_ENABLED', 'True', 'gobject-introspection qemu-native', '', d)}" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 39 | |
Patrick Williams | e760df8 | 2023-05-26 11:10:49 -0500 | [diff] [blame] | 40 | # Even when introspection is disabled, the gobject-introspection package is still needed for m4 macros. |
| 41 | DEPENDS:append = " gobject-introspection-native" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 42 | |
| 43 | # This is used by introspection tools to find .gir includes |
| 44 | export XDG_DATA_DIRS = "${STAGING_DATADIR}:${STAGING_LIBDIR}" |
| 45 | |
| 46 | do_configure:prepend:class-target () { |
Patrick Williams | e760df8 | 2023-05-26 11:10:49 -0500 | [diff] [blame] | 47 | # 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 Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | # .typelib files are needed at runtime and so they go to the main package (so |
| 54 | # they'll be together with libraries they support). |
| 55 | FILES:${PN}:append = " ${libdir}/girepository-*/*.typelib" |
| 56 | |
| 57 | # .gir files go to dev package, as they're needed for developing (but not for |
| 58 | # running) things that depends on introspection. |
| 59 | FILES:${PN}-dev:append = " ${datadir}/gir-*/*.gir ${libdir}/gir-*/*.gir" |