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