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