Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [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" |
Andrew Geissler | 5f35090 | 2021-07-23 13:09:54 -0400 | [diff] [blame] | 9 | LICENSE = "LGPLv2+ & GPLv2+ & MIT" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 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 | |
| 16 | SRC_URI = "${GNOME_MIRROR}/${BPN}/${@oe.utils.trim_version("${PV}", 2)}/${BPN}-${PV}.tar.xz \ |
| 17 | file://0001-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 18 | " |
| 19 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 20 | SRC_URI[sha256sum] = "d229242481a201b84a0c66716de1752bca41db4133672cfcfb37c93eb6e54a27" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 21 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 22 | SRC_URI:append:class-native = " file://0001-Relocate-the-repository-directory-for-native-builds.patch" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 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 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 30 | DEPENDS += " libffi zlib glib-2.0 python3 flex-native bison-native autoconf-archive" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 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 | # Also prelink-rtld is used to find out library dependencies of introspection binaries |
| 36 | # (standard ldd doesn't work when cross-compiling). |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 37 | DEPENDS:append:class-target = " gobject-introspection-native qemu-native prelink-native" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 38 | |
| 39 | # needed for writing out the qemu wrapper script |
| 40 | export STAGING_DIR_HOST |
| 41 | export B |
| 42 | |
| 43 | PACKAGECONFIG ?= "" |
| 44 | PACKAGECONFIG[doctool] = "-Ddoctool=enabled,-Ddoctool=disabled,python3-mako," |
| 45 | |
| 46 | # Configure target build to use native tools of itself and to use a qemu wrapper |
| 47 | # and optionally to generate introspection data |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 48 | EXTRA_OEMESON:class-target = " \ |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 49 | -Dgi_cross_use_prebuilt_gi=true \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 50 | -Dgi_cross_binary_wrapper=${B}/g-ir-scanner-qemuwrapper \ |
| 51 | -Dgi_cross_ldd_wrapper=${B}/g-ir-scanner-lddwrapper \ |
| 52 | -Dgi_cross_pkgconfig_sysroot_path=${PKG_CONFIG_SYSROOT_DIR} \ |
| 53 | ${@bb.utils.contains('GI_DATA_ENABLED', 'True', '-Dbuild_introspection_data=true', '-Dbuild_introspection_data=false', d)} \ |
| 54 | ${@'-Dgir_dir_prefix=${libdir}' if d.getVar('MULTILIBS') else ''} \ |
| 55 | " |
| 56 | |
| 57 | # Need to ensure ld.so.conf exists so prelink-native works |
| 58 | # both before we build and if we install from sstate |
| 59 | do_configure[prefuncs] += "gobject_introspection_preconfigure" |
| 60 | python gobject_introspection_preconfigure () { |
| 61 | oe.utils.write_ld_so_conf(d) |
| 62 | } |
| 63 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 64 | do_configure:prepend:class-native() { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 65 | # Tweak the native python scripts so that they don't refer to the |
| 66 | # full path of native python binary (the solution is taken from glib-2.0 recipe) |
| 67 | # This removes the risk of exceeding Linux kernel's shebang line limit (128 bytes) |
| 68 | sed -i -e '1s,#!.*,#!${USRBINPATH}/env python3,' ${S}/tools/g-ir-tool-template.in |
| 69 | } |
| 70 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 71 | do_configure:prepend:class-target() { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 72 | # Write out a qemu wrapper that will be given to gi-scanner so that it |
| 73 | # can run target helper binaries through that. |
| 74 | qemu_binary="${@qemu_wrapper_cmdline(d, '$STAGING_DIR_HOST', ['\\$GIR_EXTRA_LIBS_PATH','.libs','$STAGING_DIR_HOST/${libdir}','$STAGING_DIR_HOST/${base_libdir}'])}" |
| 75 | cat > ${B}/g-ir-scanner-qemuwrapper << EOF |
| 76 | #!/bin/sh |
| 77 | # Use a modules directory which doesn't exist so we don't load random things |
| 78 | # which may then get deleted (or their dependencies) and potentially segfault |
| 79 | export GIO_MODULE_DIR=${STAGING_LIBDIR}/gio/modules-dummy |
| 80 | |
| 81 | $qemu_binary "\$@" |
| 82 | if [ \$? -ne 0 ]; then |
| 83 | echo "If the above error message is about missing .so libraries, then setting up GIR_EXTRA_LIBS_PATH in the recipe should help." |
| 84 | echo "(typically like this: GIR_EXTRA_LIBS_PATH=\"$""{B}/something/.libs\" )" |
| 85 | exit 1 |
| 86 | fi |
| 87 | EOF |
| 88 | chmod +x ${B}/g-ir-scanner-qemuwrapper |
| 89 | |
| 90 | # Write out a wrapper for g-ir-scanner itself, which will be used when building introspection files |
| 91 | # for glib-based packages. This wrapper calls the native version of the scanner, and tells it to use |
| 92 | # a qemu wrapper for running transient target binaries produced by the scanner, and an include directory |
| 93 | # from the target sysroot. |
| 94 | cat > ${B}/g-ir-scanner-wrapper << EOF |
| 95 | #!/bin/sh |
| 96 | # This prevents g-ir-scanner from writing cache data to $HOME |
| 97 | export GI_SCANNER_DISABLE_CACHE=1 |
| 98 | |
| 99 | 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 "\$@" |
| 100 | EOF |
| 101 | chmod +x ${B}/g-ir-scanner-wrapper |
| 102 | |
| 103 | # Write out a wrapper for g-ir-compiler, which runs the target version of it through qemu. |
| 104 | # g-ir-compiler writes out the raw content of a C struct to disk, and therefore is architecture dependent. |
| 105 | cat > ${B}/g-ir-compiler-wrapper << EOF |
| 106 | #!/bin/sh |
| 107 | ${STAGING_BINDIR}/g-ir-scanner-qemuwrapper ${STAGING_BINDIR}/g-ir-compiler "\$@" |
| 108 | EOF |
| 109 | chmod +x ${B}/g-ir-compiler-wrapper |
| 110 | |
| 111 | # Write out a wrapper to use instead of ldd, which does not work when a binary is built |
| 112 | # for a different architecture |
| 113 | cat > ${B}/g-ir-scanner-lddwrapper << EOF |
| 114 | #!/bin/sh |
| 115 | prelink-rtld --root=$STAGING_DIR_HOST "\$@" |
| 116 | EOF |
| 117 | chmod +x ${B}/g-ir-scanner-lddwrapper |
| 118 | |
| 119 | # Also tweak the target python scripts so that they don't refer to the |
| 120 | # native version of python binary (the solution is taken from glib-2.0 recipe) |
| 121 | sed -i -e '1s,#!.*,#!${USRBINPATH}/env python3,' ${S}/tools/g-ir-tool-template.in |
| 122 | } |
| 123 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 124 | do_compile:prepend() { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 125 | # This prevents g-ir-scanner from writing cache data to $HOME |
| 126 | export GI_SCANNER_DISABLE_CACHE=1 |
| 127 | |
| 128 | # Needed to run g-ir unit tests, which won't be able to find the built libraries otherwise |
| 129 | export GIR_EXTRA_LIBS_PATH=$B/.libs |
| 130 | } |
| 131 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 132 | do_install:prepend() { |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 133 | # This prevents g-ir-scanner from writing cache data to $HOME |
| 134 | export GI_SCANNER_DISABLE_CACHE=1 |
| 135 | } |
| 136 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 137 | # Our wrappers need to be available system-wide, because they will be used |
| 138 | # to build introspection files for all other gobject-based packages |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 139 | do_install:append:class-target() { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 140 | install -d ${D}${bindir}/ |
| 141 | install ${B}/g-ir-scanner-qemuwrapper ${D}${bindir}/ |
| 142 | install ${B}/g-ir-scanner-wrapper ${D}${bindir}/ |
| 143 | install ${B}/g-ir-compiler-wrapper ${D}${bindir}/ |
| 144 | install ${B}/g-ir-scanner-lddwrapper ${D}${bindir}/ |
| 145 | } |
| 146 | |
| 147 | # we need target versions of introspection tools in sysroot so that they can be run via qemu |
| 148 | # when building introspection files in other packages |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 149 | SYSROOT_DIRS:append:class-target = " ${bindir}" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 150 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 151 | SYSROOT_PREPROCESS_FUNCS:append:class-target = " gi_binaries_sysroot_preprocess" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 152 | gi_binaries_sysroot_preprocess() { |
| 153 | # Tweak the binary names in the introspection pkgconfig file, so that it |
| 154 | # picks up our wrappers which do the cross-compile and qemu magic. |
| 155 | sed -i \ |
| 156 | -e "s|g_ir_scanner=.*|g_ir_scanner=${bindir}/g-ir-scanner-wrapper|" \ |
| 157 | -e "s|g_ir_compiler=.*|g_ir_compiler=${bindir}/g-ir-compiler-wrapper|" \ |
| 158 | ${SYSROOT_DESTDIR}${libdir}/pkgconfig/gobject-introspection-1.0.pc |
| 159 | } |
| 160 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 161 | SYSROOT_PREPROCESS_FUNCS:append = " gi_ldsoconf_sysroot_preprocess" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 162 | gi_ldsoconf_sysroot_preprocess () { |
| 163 | mkdir -p ${SYSROOT_DESTDIR}${bindir} |
| 164 | dest=${SYSROOT_DESTDIR}${bindir}/postinst-ldsoconf-${PN} |
| 165 | echo "#!/bin/sh" > $dest |
| 166 | echo "mkdir -p ${STAGING_DIR_TARGET}${sysconfdir}" >> $dest |
| 167 | echo "echo ${base_libdir} >> ${STAGING_DIR_TARGET}${sysconfdir}/ld.so.conf" >> $dest |
| 168 | echo "echo ${libdir} >> ${STAGING_DIR_TARGET}${sysconfdir}/ld.so.conf" >> $dest |
| 169 | chmod 755 $dest |
| 170 | } |
| 171 | |
| 172 | # Remove wrapper files from the package, only used for cross-compiling |
| 173 | PACKAGE_PREPROCESS_FUNCS += "gi_package_preprocess" |
| 174 | gi_package_preprocess() { |
| 175 | rm -f ${PKGD}${bindir}/g-ir-scanner-qemuwrapper |
| 176 | rm -f ${PKGD}${bindir}/g-ir-scanner-wrapper |
| 177 | rm -f ${PKGD}${bindir}/g-ir-compiler-wrapper |
| 178 | rm -f ${PKGD}${bindir}/g-ir-scanner-lddwrapper |
| 179 | } |
| 180 | |
| 181 | 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}" |
| 182 | |
| 183 | # .typelib files are needed at runtime and so they go to the main package |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 184 | FILES:${PN}:append = " ${libdir}/girepository-*/*.typelib" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 185 | |
| 186 | # .gir files go to dev package, as they're needed for developing (but not for running) |
| 187 | # things that depends on introspection. |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 188 | FILES:${PN}-dev:append = " ${datadir}/gir-*/*.gir ${libdir}/gir-*/*.gir" |
| 189 | FILES:${PN}-dev:append = " ${datadir}/gir-*/*.rnc" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 190 | |
| 191 | # These are used by gobject-based packages |
| 192 | # to generate transient introspection binaries |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 193 | FILES:${PN}-dev:append = " ${datadir}/gobject-introspection-1.0/gdump.c \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 194 | ${datadir}/gobject-introspection-1.0/Makefile.introspection" |
| 195 | |
| 196 | # These are used by dependent packages (e.g. pygobject) to build their |
| 197 | # testsuites. |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 198 | FILES:${PN}-dev:append = " ${datadir}/gobject-introspection-1.0/tests/*.c \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 199 | ${datadir}/gobject-introspection-1.0/tests/*.h" |
| 200 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 201 | FILES:${PN}-dbg += "${libdir}/gobject-introspection/giscanner/.debug/" |
| 202 | FILES:${PN}-staticdev += "${libdir}/gobject-introspection/giscanner/*.a" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 203 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 204 | RDEPENDS:${PN} = "python3-pickle python3-xml" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 205 | |
| 206 | BBCLASSEXTEND = "native" |