blob: 822a226d5f148c0d4e2566fe330d94ff2fd8d5c8 [file] [log] [blame]
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001# Inherit this class in recipes to enable building their introspection files
2
Patrick Williamsc0f7c042017-02-23 20:41:17 -06003# python3native is inherited to prevent introspection tools being run with
4# host's python 3 (they need to be run with native python 3)
5#
6# This also sets up autoconf-based recipes to build introspection data (or not),
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05007# depending on distro and machine features (see gobject-introspection-data class).
Patrick Williamsc0f7c042017-02-23 20:41:17 -06008inherit python3native gobject-introspection-data
Brad Bishopc342db32019-05-15 21:57:59 -04009
10# meson: default option name to enable/disable introspection. This matches most
11# project's configuration. In doubts - check meson_options.txt in project's
12# source path.
13GIR_MESON_OPTION ?= 'introspection'
14GIR_MESON_ENABLE_FLAG ?= 'true'
15GIR_MESON_DISABLE_FLAG ?= 'false'
16
17# Auto enable/disable based on GI_DATA_ENABLED
Patrick Williams213cb262021-08-07 19:21:33 -050018EXTRA_OECONF:prepend:class-target = "${@bb.utils.contains('GI_DATA_ENABLED', 'True', '--enable-introspection', '--disable-introspection', d)} "
19EXTRA_OEMESON:prepend:class-target = "-D${GIR_MESON_OPTION}=${@bb.utils.contains('GI_DATA_ENABLED', 'True', '${GIR_MESON_ENABLE_FLAG}', '${GIR_MESON_DISABLE_FLAG}', d)} "
Patrick Williamsc0f7c042017-02-23 20:41:17 -060020
21# When building native recipes, disable introspection, as it is not necessary,
22# pulls in additional dependencies, and makes build times longer
Patrick Williams213cb262021-08-07 19:21:33 -050023EXTRA_OECONF:prepend:class-native = "--disable-introspection "
24EXTRA_OECONF:prepend:class-nativesdk = "--disable-introspection "
25EXTRA_OEMESON:prepend:class-native = "-D${GIR_MESON_OPTION}=${GIR_MESON_DISABLE_FLAG} "
26EXTRA_OEMESON:prepend:class-nativesdk = "-D${GIR_MESON_OPTION}=${GIR_MESON_DISABLE_FLAG} "
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050027
28# Generating introspection data depends on a combination of native and target
29# introspection tools, and qemu to run the target tools.
Patrick Williams213cb262021-08-07 19:21:33 -050030DEPENDS:append:class-target = " gobject-introspection gobject-introspection-native qemu-native prelink-native"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050031
Patrick Williamsc0f7c042017-02-23 20:41:17 -060032# Even though introspection is disabled on -native, gobject-introspection package is still
33# needed for m4 macros.
Patrick Williams213cb262021-08-07 19:21:33 -050034DEPENDS:append:class-native = " gobject-introspection-native"
35DEPENDS:append:class-nativesdk = " gobject-introspection-native"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050036
37# This is used by introspection tools to find .gir includes
Brad Bishop19323692019-04-05 15:28:33 -040038export XDG_DATA_DIRS = "${STAGING_DATADIR}:${STAGING_LIBDIR}"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050039
Patrick Williams213cb262021-08-07 19:21:33 -050040do_configure:prepend:class-target () {
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050041 # introspection.m4 pre-packaged with upstream tarballs does not yet
42 # have our fixes
43 mkdir -p ${S}/m4
44 cp ${STAGING_DIR_TARGET}/${datadir}/aclocal/introspection.m4 ${S}/m4
45}
46
47# .typelib files are needed at runtime and so they go to the main package (so
48# they'll be together with libraries they support).
Patrick Williams213cb262021-08-07 19:21:33 -050049FILES:${PN}:append = " ${libdir}/girepository-*/*.typelib"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050050
51# .gir files go to dev package, as they're needed for developing (but not for
52# running) things that depends on introspection.
Patrick Williams213cb262021-08-07 19:21:33 -050053FILES:${PN}-dev:append = " ${datadir}/gir-*/*.gir ${libdir}/gir-*/*.gir"