blob: a9739cc552b8a724e541276c648a57ca249f2a69 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001SUMMARY = "Middleware layer between GObject-using C libraries and language bindings"
Brad Bishop64c979e2019-11-04 13:55:29 -05002DESCRIPTION = "GObject Introspection is a project for providing machine \
3readable introspection data of the API of C libraries. This introspection \
4data can be used in several different use cases, for example automatic code \
5generation for bindings, API verification and documentation generation."
Brad Bishopc342db32019-05-15 21:57:59 -04006HOMEPAGE = "https://wiki.gnome.org/action/show/Projects/GObjectIntrospection"
Brad Bishop64c979e2019-11-04 13:55:29 -05007BUGTRACKER = "https://gitlab.gnome.org/GNOME/gobject-introspection/issues"
Brad Bishopc342db32019-05-15 21:57:59 -04008SECTION = "libs"
9LICENSE = "LGPLv2+ & GPLv2+"
10LIC_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
16SRC_URI = "${GNOME_MIRROR}/${BPN}/${@oe.utils.trim_version("${PV}", 2)}/${BPN}-${PV}.tar.xz \
Brad Bishopc342db32019-05-15 21:57:59 -040017 file://0003-giscanner-add-use-binary-wrapper-option.patch \
18 file://0004-giscanner-add-a-use-ldd-wrapper-option.patch \
19 file://0005-Prefix-pkg-config-paths-with-PKG_CONFIG_SYSROOT_DIR-.patch \
20 file://0001-giscanner-add-a-lib-dirs-envvar-option.patch \
21 file://0001-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch \
22 file://0001-Port-cross-compilation-support-to-meson.patch \
23 file://0001-meson.build-disable-tests-when-cross-compiling.patch \
24 "
25
Brad Bishopf3f93bb2019-10-16 14:33:32 -040026SRC_URI[md5sum] = "37278eab3704e42234b6080b8cf241f1"
27SRC_URI[sha256sum] = "b1ee7ed257fdbc008702bdff0ff3e78a660e7e602efa8f211dc89b9d1e7d90a2"
Brad Bishopc342db32019-05-15 21:57:59 -040028
29SRC_URI_append_class-native = " file://0001-Relocate-the-repository-directory-for-native-builds.patch"
30
31inherit meson pkgconfig gtk-doc python3native qemu gobject-introspection-data upstream-version-is-even multilib_script
32
33GTKDOC_MESON_OPTION = "gtk_doc"
34
35MULTILIB_SCRIPTS = "${PN}:${bindir}/g-ir-annotation-tool ${PN}:${bindir}/g-ir-scanner"
36
37DEPENDS_append = " libffi zlib glib-2.0 python3 flex-native bison-native autoconf-archive"
38
39# target build needs qemu to run temporary introspection binaries created
40# on the fly by g-ir-scanner and a native version of itself to run
41# native versions of its own tools during build.
42# Also prelink-rtld is used to find out library dependencies of introspection binaries
43# (standard ldd doesn't work when cross-compiling).
44DEPENDS_class-target_append = " gobject-introspection-native qemu-native prelink-native"
45
46# needed for writing out the qemu wrapper script
47export STAGING_DIR_HOST
48export B
49
50PACKAGECONFIG ?= ""
51PACKAGECONFIG[doctool] = "-Ddoctool=true,-Ddoctool=false,python3-mako,"
52
53# Configure target build to use native tools of itself and to use a qemu wrapper
54# and optionally to generate introspection data
55EXTRA_OEMESON_class-target = " \
56 -Denable-host-gi=true \
57 -Denable-gi-cross-wrapper=${B}/g-ir-scanner-qemuwrapper \
58 -Denable-gi-ldd-wrapper=${B}/g-ir-scanner-lddwrapper \
59 -Dpkgconfig-sysroot-path=${PKG_CONFIG_SYSROOT_DIR} \
60 ${@bb.utils.contains('GI_DATA_ENABLED', 'True', '-Denable-introspection-data=true', '-Denable-introspection-data=false', d)} \
61 ${@'-Dgir_dir_prefix=${libdir}' if d.getVar('MULTILIBS') else ''} \
62"
63
64# Need to ensure ld.so.conf exists so prelink-native works
65# both before we build and if we install from sstate
66do_configure[prefuncs] += "gobject_introspection_preconfigure"
67python gobject_introspection_preconfigure () {
68 oe.utils.write_ld_so_conf(d)
69}
70
71do_configure_prepend_class-native() {
72 # Tweak the native python scripts so that they don't refer to the
73 # full path of native python binary (the solution is taken from glib-2.0 recipe)
74 # This removes the risk of exceeding Linux kernel's shebang line limit (128 bytes)
75 sed -i -e '1s,#!.*,#!${USRBINPATH}/env python3,' ${S}/tools/g-ir-tool-template.in
76}
77
78do_configure_prepend_class-target() {
79 # Write out a qemu wrapper that will be given to gi-scanner so that it
80 # can run target helper binaries through that.
81 qemu_binary="${@qemu_wrapper_cmdline(d, '$STAGING_DIR_HOST', ['\\$GIR_EXTRA_LIBS_PATH','.libs','$STAGING_DIR_HOST/${libdir}','$STAGING_DIR_HOST/${base_libdir}'])}"
82 cat > ${B}/g-ir-scanner-qemuwrapper << EOF
83#!/bin/sh
84# Use a modules directory which doesn't exist so we don't load random things
85# which may then get deleted (or their dependencies) and potentially segfault
86export GIO_MODULE_DIR=${STAGING_LIBDIR}/gio/modules-dummy
87
88$qemu_binary "\$@"
89if [ \$? -ne 0 ]; then
90 echo "If the above error message is about missing .so libraries, then setting up GIR_EXTRA_LIBS_PATH in the recipe should help."
91 echo "(typically like this: GIR_EXTRA_LIBS_PATH=\"$""{B}/something/.libs\" )"
92 exit 1
93fi
94EOF
95 chmod +x ${B}/g-ir-scanner-qemuwrapper
96
97 # Write out a wrapper for g-ir-scanner itself, which will be used when building introspection files
98 # for glib-based packages. This wrapper calls the native version of the scanner, and tells it to use
Brad Bishop64c979e2019-11-04 13:55:29 -050099 # a qemu wrapper for running transient target binaries produced by the scanner, and an include directory
Brad Bishopc342db32019-05-15 21:57:59 -0400100 # from the target sysroot.
101 cat > ${B}/g-ir-scanner-wrapper << EOF
102#!/bin/sh
103# This prevents g-ir-scanner from writing cache data to $HOME
104export GI_SCANNER_DISABLE_CACHE=1
105
106g-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 "\$@"
107EOF
108 chmod +x ${B}/g-ir-scanner-wrapper
109
110 # Write out a wrapper for g-ir-compiler, which runs the target version of it through qemu.
111 # g-ir-compiler writes out the raw content of a C struct to disk, and therefore is architecture dependent.
112 cat > ${B}/g-ir-compiler-wrapper << EOF
113#!/bin/sh
114${STAGING_BINDIR}/g-ir-scanner-qemuwrapper ${STAGING_BINDIR}/g-ir-compiler "\$@"
115EOF
116 chmod +x ${B}/g-ir-compiler-wrapper
117
118 # Write out a wrapper to use instead of ldd, which does not work when a binary is built
119 # for a different architecture
120 cat > ${B}/g-ir-scanner-lddwrapper << EOF
121#!/bin/sh
122prelink-rtld --root=$STAGING_DIR_HOST "\$@"
123EOF
124 chmod +x ${B}/g-ir-scanner-lddwrapper
125
126 # Also tweak the target python scripts so that they don't refer to the
127 # native version of python binary (the solution is taken from glib-2.0 recipe)
128 sed -i -e '1s,#!.*,#!${USRBINPATH}/env python3,' ${S}/tools/g-ir-tool-template.in
129}
130
131do_compile_prepend() {
132 # This prevents g-ir-scanner from writing cache data to $HOME
133 export GI_SCANNER_DISABLE_CACHE=1
134
135 # Needed to run g-ir unit tests, which won't be able to find the built libraries otherwise
136 export GIR_EXTRA_LIBS_PATH=$B/.libs
137}
138
Brad Bishop64c979e2019-11-04 13:55:29 -0500139# Our wrappers need to be available system-wide, because they will be used
Brad Bishopc342db32019-05-15 21:57:59 -0400140# to build introspection files for all other gobject-based packages
141do_install_append_class-target() {
142 install -d ${D}${bindir}/
143 install ${B}/g-ir-scanner-qemuwrapper ${D}${bindir}/
144 install ${B}/g-ir-scanner-wrapper ${D}${bindir}/
145 install ${B}/g-ir-compiler-wrapper ${D}${bindir}/
146 install ${B}/g-ir-scanner-lddwrapper ${D}${bindir}/
147}
148
149# we need target versions of introspection tools in sysroot so that they can be run via qemu
150# when building introspection files in other packages
151SYSROOT_DIRS_append_class-target = " ${bindir}"
152
153SYSROOT_PREPROCESS_FUNCS_append_class-target = " gi_binaries_sysroot_preprocess"
154gi_binaries_sysroot_preprocess() {
155 # Tweak the binary names in the introspection pkgconfig file, so that it
156 # picks up our wrappers which do the cross-compile and qemu magic.
157 sed -i \
158 -e "s|g_ir_scanner=.*|g_ir_scanner=${bindir}/g-ir-scanner-wrapper|" \
159 -e "s|g_ir_compiler=.*|g_ir_compiler=${bindir}/g-ir-compiler-wrapper|" \
160 ${SYSROOT_DESTDIR}${libdir}/pkgconfig/gobject-introspection-1.0.pc
161}
162
163SYSROOT_PREPROCESS_FUNCS_append = " gi_ldsoconf_sysroot_preprocess"
164gi_ldsoconf_sysroot_preprocess () {
165 mkdir -p ${SYSROOT_DESTDIR}${bindir}
166 dest=${SYSROOT_DESTDIR}${bindir}/postinst-ldsoconf-${PN}
167 echo "#!/bin/sh" > $dest
168 echo "mkdir -p ${STAGING_DIR_TARGET}${sysconfdir}" >> $dest
169 echo "echo ${base_libdir} >> ${STAGING_DIR_TARGET}${sysconfdir}/ld.so.conf" >> $dest
170 echo "echo ${libdir} >> ${STAGING_DIR_TARGET}${sysconfdir}/ld.so.conf" >> $dest
171 chmod 755 $dest
172}
173
174# Remove wrapper files from the package, only used for cross-compiling
175PACKAGE_PREPROCESS_FUNCS += "gi_package_preprocess"
176gi_package_preprocess() {
177 rm -f ${PKGD}${bindir}/g-ir-scanner-qemuwrapper
178 rm -f ${PKGD}${bindir}/g-ir-scanner-wrapper
179 rm -f ${PKGD}${bindir}/g-ir-compiler-wrapper
180 rm -f ${PKGD}${bindir}/g-ir-scanner-lddwrapper
181}
182
183SSTATE_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}"
184
185# .typelib files are needed at runtime and so they go to the main package
186FILES_${PN}_append = " ${libdir}/girepository-*/*.typelib"
187
188# .gir files go to dev package, as they're needed for developing (but not for running)
189# things that depends on introspection.
190FILES_${PN}-dev_append = " ${datadir}/gir-*/*.gir ${libdir}/gir-*/*.gir"
191FILES_${PN}-dev_append = " ${datadir}/gir-*/*.rnc"
192
193# These are used by gobject-based packages
194# to generate transient introspection binaries
195FILES_${PN}-dev_append = " ${datadir}/gobject-introspection-1.0/gdump.c \
196 ${datadir}/gobject-introspection-1.0/Makefile.introspection"
197
198# These are used by dependent packages (e.g. pygobject) to build their
199# testsuites.
200FILES_${PN}-dev_append = " ${datadir}/gobject-introspection-1.0/tests/*.c \
201 ${datadir}/gobject-introspection-1.0/tests/*.h"
202
203FILES_${PN}-dbg += "${libdir}/gobject-introspection/giscanner/.debug/"
204FILES_${PN}-staticdev += "${libdir}/gobject-introspection/giscanner/*.a"
205
206RDEPENDS_${PN} = "python3-pickle python3-xml"
207
208BBCLASSEXTEND = "native"