1*4882a593SmuzhiyunSUMMARY = "Middleware layer between GObject-using C libraries and language bindings" 2*4882a593SmuzhiyunDESCRIPTION = "GObject Introspection is a project for providing machine \ 3*4882a593Smuzhiyunreadable introspection data of the API of C libraries. This introspection \ 4*4882a593Smuzhiyundata can be used in several different use cases, for example automatic code \ 5*4882a593Smuzhiyungeneration for bindings, API verification and documentation generation." 6*4882a593SmuzhiyunHOMEPAGE = "https://wiki.gnome.org/action/show/Projects/GObjectIntrospection" 7*4882a593SmuzhiyunBUGTRACKER = "https://gitlab.gnome.org/GNOME/gobject-introspection/issues" 8*4882a593SmuzhiyunSECTION = "libs" 9*4882a593SmuzhiyunLICENSE = "LGPL-2.0-or-later & GPL-2.0-or-later & MIT" 10*4882a593SmuzhiyunLIC_FILES_CHKSUM = "file://COPYING;md5=c434e8128a68bedd59b80b2ac1eb1c4a \ 11*4882a593Smuzhiyun file://tools/compiler.c;endline=20;md5=fc5007fc20022720e6c0b0cdde41fabd \ 12*4882a593Smuzhiyun file://giscanner/sourcescanner.c;endline=22;md5=194d6e0c1d00662f32d030ce44de8d39 \ 13*4882a593Smuzhiyun file://girepository/giregisteredtypeinfo.c;endline=21;md5=661847611ae6979465415f31a759ba27 \ 14*4882a593Smuzhiyun " 15*4882a593Smuzhiyun 16*4882a593SmuzhiyunSRC_URI = "${GNOME_MIRROR}/${BPN}/${@oe.utils.trim_version("${PV}", 2)}/${BPN}-${PV}.tar.xz \ 17*4882a593Smuzhiyun file://0001-g-ir-tool-template.in-fix-girdir-path.patch \ 18*4882a593Smuzhiyun " 19*4882a593Smuzhiyun 20*4882a593SmuzhiyunSRC_URI[sha256sum] = "02fe8e590861d88f83060dd39cda5ccaa60b2da1d21d0f95499301b186beaabc" 21*4882a593Smuzhiyun 22*4882a593SmuzhiyunSRC_URI:append:class-native = " file://0001-Relocate-the-repository-directory-for-native-builds.patch" 23*4882a593Smuzhiyun 24*4882a593Smuzhiyuninherit meson pkgconfig gtk-doc python3native qemu gobject-introspection-data upstream-version-is-even multilib_script 25*4882a593Smuzhiyun 26*4882a593SmuzhiyunGTKDOC_MESON_OPTION = "gtk_doc" 27*4882a593Smuzhiyun 28*4882a593SmuzhiyunMULTILIB_SCRIPTS = "${PN}:${bindir}/g-ir-annotation-tool ${PN}:${bindir}/g-ir-scanner" 29*4882a593Smuzhiyun 30*4882a593SmuzhiyunDEPENDS += " libffi zlib glib-2.0 python3 flex-native bison-native autoconf-archive" 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun# target build needs qemu to run temporary introspection binaries created 33*4882a593Smuzhiyun# on the fly by g-ir-scanner and a native version of itself to run 34*4882a593Smuzhiyun# native versions of its own tools during build. 35*4882a593SmuzhiyunDEPENDS:append:class-target = " gobject-introspection-native qemu-native" 36*4882a593Smuzhiyun 37*4882a593Smuzhiyun# needed for writing out the qemu wrapper script 38*4882a593Smuzhiyunexport STAGING_DIR_HOST 39*4882a593Smuzhiyunexport B 40*4882a593Smuzhiyun 41*4882a593SmuzhiyunPACKAGECONFIG ?= "" 42*4882a593SmuzhiyunPACKAGECONFIG[doctool] = "-Ddoctool=enabled,-Ddoctool=disabled,python3-mako," 43*4882a593Smuzhiyun 44*4882a593Smuzhiyun# Configure target build to use native tools of itself and to use a qemu wrapper 45*4882a593Smuzhiyun# and optionally to generate introspection data 46*4882a593SmuzhiyunEXTRA_OEMESON:class-target = " \ 47*4882a593Smuzhiyun -Dgi_cross_use_prebuilt_gi=true \ 48*4882a593Smuzhiyun -Dgi_cross_binary_wrapper=${B}/g-ir-scanner-qemuwrapper \ 49*4882a593Smuzhiyun -Dgi_cross_ldd_wrapper=${B}/g-ir-scanner-lddwrapper \ 50*4882a593Smuzhiyun -Dgi_cross_pkgconfig_sysroot_path=${PKG_CONFIG_SYSROOT_DIR} \ 51*4882a593Smuzhiyun ${@bb.utils.contains('GI_DATA_ENABLED', 'True', '-Dbuild_introspection_data=true', '-Dbuild_introspection_data=false', d)} \ 52*4882a593Smuzhiyun ${@'-Dgir_dir_prefix=${libdir}' if d.getVar('MULTILIBS') else ''} \ 53*4882a593Smuzhiyun" 54*4882a593Smuzhiyun 55*4882a593Smuzhiyundo_configure:prepend:class-native() { 56*4882a593Smuzhiyun # Tweak the native python scripts so that they don't refer to the 57*4882a593Smuzhiyun # full path of native python binary (the solution is taken from glib-2.0 recipe) 58*4882a593Smuzhiyun # This removes the risk of exceeding Linux kernel's shebang line limit (128 bytes) 59*4882a593Smuzhiyun sed -i -e '1s,#!.*,#!${USRBINPATH}/env python3,' ${S}/tools/g-ir-tool-template.in 60*4882a593Smuzhiyun} 61*4882a593Smuzhiyun 62*4882a593Smuzhiyundo_configure:prepend:class-target() { 63*4882a593Smuzhiyun # Write out a qemu wrapper that will be given to gi-scanner so that it 64*4882a593Smuzhiyun # can run target helper binaries through that. 65*4882a593Smuzhiyun qemu_binary="${@qemu_wrapper_cmdline(d, '$STAGING_DIR_HOST', ['\\$GIR_EXTRA_LIBS_PATH','.libs','$STAGING_DIR_HOST/${libdir}','$STAGING_DIR_HOST/${base_libdir}'])}" 66*4882a593Smuzhiyun cat > ${B}/g-ir-scanner-qemuwrapper << EOF 67*4882a593Smuzhiyun#!/bin/sh 68*4882a593Smuzhiyun# Use a modules directory which doesn't exist so we don't load random things 69*4882a593Smuzhiyun# which may then get deleted (or their dependencies) and potentially segfault 70*4882a593Smuzhiyunexport GIO_MODULE_DIR=${STAGING_LIBDIR}/gio/modules-dummy 71*4882a593Smuzhiyun 72*4882a593Smuzhiyun$qemu_binary "\$@" 73*4882a593Smuzhiyunif [ \$? -ne 0 ]; then 74*4882a593Smuzhiyun echo "If the above error message is about missing .so libraries, then setting up GIR_EXTRA_LIBS_PATH in the recipe should help." 75*4882a593Smuzhiyun echo "(typically like this: GIR_EXTRA_LIBS_PATH=\"$""{B}/something/.libs\" )" 76*4882a593Smuzhiyun exit 1 77*4882a593Smuzhiyunfi 78*4882a593SmuzhiyunEOF 79*4882a593Smuzhiyun chmod +x ${B}/g-ir-scanner-qemuwrapper 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun # Write out a wrapper for g-ir-scanner itself, which will be used when building introspection files 82*4882a593Smuzhiyun # for glib-based packages. This wrapper calls the native version of the scanner, and tells it to use 83*4882a593Smuzhiyun # a qemu wrapper for running transient target binaries produced by the scanner, and an include directory 84*4882a593Smuzhiyun # from the target sysroot. 85*4882a593Smuzhiyun cat > ${B}/g-ir-scanner-wrapper << EOF 86*4882a593Smuzhiyun#!/bin/sh 87*4882a593Smuzhiyun# This prevents g-ir-scanner from writing cache data to user's HOME dir 88*4882a593Smuzhiyunexport GI_SCANNER_DISABLE_CACHE=1 89*4882a593Smuzhiyun 90*4882a593Smuzhiyung-ir-scanner --lib-dirs-envvar=GIR_EXTRA_LIBS_PATH --use-binary-wrapper=${STAGING_BINDIR}/g-ir-scanner-qemuwrapper --use-ldd-wrapper=${STAGING_BINDIR}/g-ir-scanner-lddwrapper --add-include-path=${STAGING_DATADIR}/gir-1.0 --add-include-path=${STAGING_LIBDIR}/gir-1.0 "\$@" 91*4882a593SmuzhiyunEOF 92*4882a593Smuzhiyun chmod +x ${B}/g-ir-scanner-wrapper 93*4882a593Smuzhiyun 94*4882a593Smuzhiyun # Write out a wrapper for g-ir-compiler, which runs the target version of it through qemu. 95*4882a593Smuzhiyun # g-ir-compiler writes out the raw content of a C struct to disk, and therefore is architecture dependent. 96*4882a593Smuzhiyun cat > ${B}/g-ir-compiler-wrapper << EOF 97*4882a593Smuzhiyun#!/bin/sh 98*4882a593Smuzhiyun${STAGING_BINDIR}/g-ir-scanner-qemuwrapper ${STAGING_BINDIR}/g-ir-compiler "\$@" 99*4882a593SmuzhiyunEOF 100*4882a593Smuzhiyun chmod +x ${B}/g-ir-compiler-wrapper 101*4882a593Smuzhiyun 102*4882a593Smuzhiyun # Write out a wrapper to use instead of ldd, which does not work when a binary is built 103*4882a593Smuzhiyun # for a different architecture 104*4882a593Smuzhiyun cat > ${B}/g-ir-scanner-lddwrapper << EOF 105*4882a593Smuzhiyun#!/bin/sh 106*4882a593Smuzhiyun$OBJDUMP -p "\$@" 107*4882a593SmuzhiyunEOF 108*4882a593Smuzhiyun chmod +x ${B}/g-ir-scanner-lddwrapper 109*4882a593Smuzhiyun 110*4882a593Smuzhiyun # Also tweak the target python scripts so that they don't refer to the 111*4882a593Smuzhiyun # native version of python binary (the solution is taken from glib-2.0 recipe) 112*4882a593Smuzhiyun sed -i -e '1s,#!.*,#!${USRBINPATH}/env python3,' ${S}/tools/g-ir-tool-template.in 113*4882a593Smuzhiyun} 114*4882a593Smuzhiyun 115*4882a593Smuzhiyundo_compile:prepend() { 116*4882a593Smuzhiyun # Needed to run g-ir unit tests, which won't be able to find the built libraries otherwise 117*4882a593Smuzhiyun export GIR_EXTRA_LIBS_PATH=$B/.libs 118*4882a593Smuzhiyun} 119*4882a593Smuzhiyun 120*4882a593Smuzhiyundo_install:prepend() { 121*4882a593Smuzhiyun # This prevents g-ir-scanner from writing cache data to $HOME 122*4882a593Smuzhiyun export GI_SCANNER_DISABLE_CACHE=1 123*4882a593Smuzhiyun} 124*4882a593Smuzhiyun 125*4882a593Smuzhiyun# Our wrappers need to be available system-wide, because they will be used 126*4882a593Smuzhiyun# to build introspection files for all other gobject-based packages 127*4882a593Smuzhiyundo_install:append:class-target() { 128*4882a593Smuzhiyun install -d ${D}${bindir}/ 129*4882a593Smuzhiyun install ${B}/g-ir-scanner-qemuwrapper ${D}${bindir}/ 130*4882a593Smuzhiyun install ${B}/g-ir-scanner-wrapper ${D}${bindir}/ 131*4882a593Smuzhiyun install ${B}/g-ir-compiler-wrapper ${D}${bindir}/ 132*4882a593Smuzhiyun install ${B}/g-ir-scanner-lddwrapper ${D}${bindir}/ 133*4882a593Smuzhiyun} 134*4882a593Smuzhiyun 135*4882a593Smuzhiyun# we need target versions of introspection tools in sysroot so that they can be run via qemu 136*4882a593Smuzhiyun# when building introspection files in other packages 137*4882a593SmuzhiyunSYSROOT_DIRS:append:class-target = " ${bindir}" 138*4882a593Smuzhiyun 139*4882a593SmuzhiyunSYSROOT_PREPROCESS_FUNCS:append:class-target = " gi_binaries_sysroot_preprocess" 140*4882a593Smuzhiyungi_binaries_sysroot_preprocess() { 141*4882a593Smuzhiyun # Tweak the binary names in the introspection pkgconfig file, so that it 142*4882a593Smuzhiyun # picks up our wrappers which do the cross-compile and qemu magic. 143*4882a593Smuzhiyun sed -i \ 144*4882a593Smuzhiyun -e "s|g_ir_scanner=.*|g_ir_scanner=${bindir}/g-ir-scanner-wrapper|" \ 145*4882a593Smuzhiyun -e "s|g_ir_compiler=.*|g_ir_compiler=${bindir}/g-ir-compiler-wrapper|" \ 146*4882a593Smuzhiyun ${SYSROOT_DESTDIR}${libdir}/pkgconfig/gobject-introspection-1.0.pc 147*4882a593Smuzhiyun} 148*4882a593Smuzhiyun 149*4882a593SmuzhiyunSYSROOT_PREPROCESS_FUNCS:append = " gi_ldsoconf_sysroot_preprocess" 150*4882a593Smuzhiyungi_ldsoconf_sysroot_preprocess () { 151*4882a593Smuzhiyun mkdir -p ${SYSROOT_DESTDIR}${bindir} 152*4882a593Smuzhiyun dest=${SYSROOT_DESTDIR}${bindir}/postinst-ldsoconf-${PN} 153*4882a593Smuzhiyun echo "#!/bin/sh" > $dest 154*4882a593Smuzhiyun echo "mkdir -p ${STAGING_DIR_TARGET}${sysconfdir}" >> $dest 155*4882a593Smuzhiyun echo "echo ${base_libdir} >> ${STAGING_DIR_TARGET}${sysconfdir}/ld.so.conf" >> $dest 156*4882a593Smuzhiyun echo "echo ${libdir} >> ${STAGING_DIR_TARGET}${sysconfdir}/ld.so.conf" >> $dest 157*4882a593Smuzhiyun chmod 755 $dest 158*4882a593Smuzhiyun} 159*4882a593Smuzhiyun 160*4882a593Smuzhiyun# Remove wrapper files from the package, only used for cross-compiling 161*4882a593SmuzhiyunPACKAGE_PREPROCESS_FUNCS += "gi_package_preprocess" 162*4882a593Smuzhiyungi_package_preprocess() { 163*4882a593Smuzhiyun rm -f ${PKGD}${bindir}/g-ir-scanner-qemuwrapper 164*4882a593Smuzhiyun rm -f ${PKGD}${bindir}/g-ir-scanner-wrapper 165*4882a593Smuzhiyun rm -f ${PKGD}${bindir}/g-ir-compiler-wrapper 166*4882a593Smuzhiyun rm -f ${PKGD}${bindir}/g-ir-scanner-lddwrapper 167*4882a593Smuzhiyun} 168*4882a593Smuzhiyun 169*4882a593SmuzhiyunSSTATE_SCAN_FILES += "g-ir-scanner-qemuwrapper g-ir-scanner-wrapper g-ir-compiler-wrapper g-ir-scanner-lddwrapper Gio-2.0.gir postinst-ldsoconf-${PN}" 170*4882a593Smuzhiyun 171*4882a593Smuzhiyun# .typelib files are needed at runtime and so they go to the main package 172*4882a593SmuzhiyunFILES:${PN}:append = " ${libdir}/girepository-*/*.typelib" 173*4882a593Smuzhiyun 174*4882a593Smuzhiyun# .gir files go to dev package, as they're needed for developing (but not for running) 175*4882a593Smuzhiyun# things that depends on introspection. 176*4882a593SmuzhiyunFILES:${PN}-dev:append = " ${datadir}/gir-*/*.gir ${libdir}/gir-*/*.gir" 177*4882a593SmuzhiyunFILES:${PN}-dev:append = " ${datadir}/gir-*/*.rnc" 178*4882a593Smuzhiyun 179*4882a593Smuzhiyun# These are used by gobject-based packages 180*4882a593Smuzhiyun# to generate transient introspection binaries 181*4882a593SmuzhiyunFILES:${PN}-dev:append = " ${datadir}/gobject-introspection-1.0/gdump.c \ 182*4882a593Smuzhiyun ${datadir}/gobject-introspection-1.0/Makefile.introspection" 183*4882a593Smuzhiyun 184*4882a593Smuzhiyun# These are used by dependent packages (e.g. pygobject) to build their 185*4882a593Smuzhiyun# testsuites. 186*4882a593SmuzhiyunFILES:${PN}-dev:append = " ${datadir}/gobject-introspection-1.0/tests/*.c \ 187*4882a593Smuzhiyun ${datadir}/gobject-introspection-1.0/tests/*.h" 188*4882a593Smuzhiyun 189*4882a593SmuzhiyunFILES:${PN}-dbg += "${libdir}/gobject-introspection/giscanner/.debug/" 190*4882a593SmuzhiyunFILES:${PN}-staticdev += "${libdir}/gobject-introspection/giscanner/*.a" 191*4882a593Smuzhiyun 192*4882a593SmuzhiyunRDEPENDS:${PN} = "python3-pickle python3-xml" 193*4882a593Smuzhiyun 194*4882a593SmuzhiyunBBCLASSEXTEND = "native" 195