1*4882a593Smuzhiyun# Inherit this class in recipes to enable building their introspection files 2*4882a593Smuzhiyun 3*4882a593Smuzhiyun# python3native is inherited to prevent introspection tools being run with 4*4882a593Smuzhiyun# host's python 3 (they need to be run with native python 3) 5*4882a593Smuzhiyun# 6*4882a593Smuzhiyun# This also sets up autoconf-based recipes to build introspection data (or not), 7*4882a593Smuzhiyun# depending on distro and machine features (see gobject-introspection-data class). 8*4882a593Smuzhiyuninherit python3native gobject-introspection-data 9*4882a593Smuzhiyun 10*4882a593Smuzhiyun# meson: default option name to enable/disable introspection. This matches most 11*4882a593Smuzhiyun# project's configuration. In doubts - check meson_options.txt in project's 12*4882a593Smuzhiyun# source path. 13*4882a593SmuzhiyunGIR_MESON_OPTION ?= 'introspection' 14*4882a593SmuzhiyunGIR_MESON_ENABLE_FLAG ?= 'true' 15*4882a593SmuzhiyunGIR_MESON_DISABLE_FLAG ?= 'false' 16*4882a593Smuzhiyun 17*4882a593Smuzhiyun# Define g-i options such that they can be disabled completely when GIR_MESON_OPTION is empty 18*4882a593SmuzhiyunGIRMESONTARGET = "-D${GIR_MESON_OPTION}=${@bb.utils.contains('GI_DATA_ENABLED', 'True', '${GIR_MESON_ENABLE_FLAG}', '${GIR_MESON_DISABLE_FLAG}', d)} " 19*4882a593SmuzhiyunGIRMESONBUILD = "-D${GIR_MESON_OPTION}=${GIR_MESON_DISABLE_FLAG} " 20*4882a593Smuzhiyun# Auto enable/disable based on GI_DATA_ENABLED 21*4882a593SmuzhiyunEXTRA_OECONF:prepend:class-target = "${@bb.utils.contains('GI_DATA_ENABLED', 'True', '--enable-introspection', '--disable-introspection', d)} " 22*4882a593SmuzhiyunEXTRA_OEMESON:prepend:class-target = "${@['', '${GIRMESONTARGET}'][d.getVar('GIR_MESON_OPTION') != '']}" 23*4882a593Smuzhiyun# When building native recipes, disable introspection, as it is not necessary, 24*4882a593Smuzhiyun# pulls in additional dependencies, and makes build times longer 25*4882a593SmuzhiyunEXTRA_OECONF:prepend:class-native = "--disable-introspection " 26*4882a593SmuzhiyunEXTRA_OECONF:prepend:class-nativesdk = "--disable-introspection " 27*4882a593SmuzhiyunEXTRA_OEMESON:prepend:class-native = "${@['', '${GIRMESONBUILD}'][d.getVar('GIR_MESON_OPTION') != '']}" 28*4882a593SmuzhiyunEXTRA_OEMESON:prepend:class-nativesdk = "${@['', '${GIRMESONBUILD}'][d.getVar('GIR_MESON_OPTION') != '']}" 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun# Generating introspection data depends on a combination of native and target 31*4882a593Smuzhiyun# introspection tools, and qemu to run the target tools. 32*4882a593SmuzhiyunDEPENDS:append:class-target = " gobject-introspection gobject-introspection-native qemu-native" 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun# Even though introspection is disabled on -native, gobject-introspection package is still 35*4882a593Smuzhiyun# needed for m4 macros. 36*4882a593SmuzhiyunDEPENDS:append:class-native = " gobject-introspection-native" 37*4882a593SmuzhiyunDEPENDS:append:class-nativesdk = " gobject-introspection-native" 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun# This is used by introspection tools to find .gir includes 40*4882a593Smuzhiyunexport XDG_DATA_DIRS = "${STAGING_DATADIR}:${STAGING_LIBDIR}" 41*4882a593Smuzhiyun 42*4882a593Smuzhiyundo_configure:prepend:class-target () { 43*4882a593Smuzhiyun # introspection.m4 pre-packaged with upstream tarballs does not yet 44*4882a593Smuzhiyun # have our fixes 45*4882a593Smuzhiyun mkdir -p ${S}/m4 46*4882a593Smuzhiyun cp ${STAGING_DIR_TARGET}/${datadir}/aclocal/introspection.m4 ${S}/m4 47*4882a593Smuzhiyun} 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun# .typelib files are needed at runtime and so they go to the main package (so 50*4882a593Smuzhiyun# they'll be together with libraries they support). 51*4882a593SmuzhiyunFILES:${PN}:append = " ${libdir}/girepository-*/*.typelib" 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun# .gir files go to dev package, as they're needed for developing (but not for 54*4882a593Smuzhiyun# running) things that depends on introspection. 55*4882a593SmuzhiyunFILES:${PN}-dev:append = " ${datadir}/gir-*/*.gir ${libdir}/gir-*/*.gir" 56