| 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. | 
|  | 38 | DEPENDS:append:class-target = " gobject-introspection gobject-introspection-native qemu-native" | 
|  | 39 |  | 
|  | 40 | # Even though introspection is disabled on -native, gobject-introspection package is still | 
|  | 41 | # needed for m4 macros. | 
|  | 42 | DEPENDS:append:class-native = " gobject-introspection-native" | 
|  | 43 | DEPENDS:append:class-nativesdk = " gobject-introspection-native" | 
|  | 44 |  | 
|  | 45 | # This is used by introspection tools to find .gir includes | 
|  | 46 | export XDG_DATA_DIRS = "${STAGING_DATADIR}:${STAGING_LIBDIR}" | 
|  | 47 |  | 
|  | 48 | do_configure:prepend:class-target () { | 
|  | 49 | # introspection.m4 pre-packaged with upstream tarballs does not yet | 
|  | 50 | # have our fixes | 
|  | 51 | mkdir -p ${S}/m4 | 
|  | 52 | cp ${STAGING_DIR_TARGET}/${datadir}/aclocal/introspection.m4 ${S}/m4 | 
|  | 53 | } | 
|  | 54 |  | 
|  | 55 | # .typelib files are needed at runtime and so they go to the main package (so | 
|  | 56 | # they'll be together with libraries they support). | 
|  | 57 | FILES:${PN}:append = " ${libdir}/girepository-*/*.typelib" | 
|  | 58 |  | 
|  | 59 | # .gir files go to dev package, as they're needed for developing (but not for | 
|  | 60 | # running) things that depends on introspection. | 
|  | 61 | FILES:${PN}-dev:append = " ${datadir}/gir-*/*.gir ${libdir}/gir-*/*.gir" |