generic-poky/meta/recipes-gnome/gobject-introspection/gobject-introspection_1.50....

179 lines
8.7 KiB
BlitzBasic
Raw Normal View History

SUMMARY = "Middleware layer between GObject-using C libraries and language bindings"
HOMEPAGE = "https://wiki.gnome.org/action/show/Projects/GObjectIntrospection"
BUGTRACKER = "https://bugzilla.gnome.org/"
SECTION = "libs"
LICENSE = "LGPLv2+ & GPLv2+"
LIC_FILES_CHKSUM = "file://COPYING;md5=90d577535a3898e1ae5dbf0ae3509a8c \
file://tools/compiler.c;endline=20;md5=fc5007fc20022720e6c0b0cdde41fabd \
file://giscanner/sourcescanner.c;endline=22;md5=194d6e0c1d00662f32d030ce44de8d39 \
file://girepository/giregisteredtypeinfo.c;endline=21;md5=661847611ae6979465415f31a759ba27"
SRC_URI = "${GNOME_MIRROR}/${BPN}/1.50/${BPN}-${PV}.tar.xz \
file://0001-Revert-an-incomplete-upstream-attempt-at-cross-compi.patch \
file://0002-configure.ac-add-host-gi-gi-cross-wrapper-gi-ldd-wra.patch \
file://0003-giscanner-add-use-binary-wrapper-option.patch \
file://0004-giscanner-add-a-use-ldd-wrapper-option.patch \
file://0005-Prefix-pkg-config-paths-with-PKG_CONFIG_SYSROOT_DIR-.patch \
"
SRC_URI[md5sum] = "5af8d724f25d0c9cfbe6df41b77e5dc0"
SRC_URI[sha256sum] = "1c6597c666f543c70ef3d7c893ab052968afae620efdc080c36657f4226337c5"
inherit autotools pkgconfig gtk-doc python3native qemu gobject-introspection-data upstream-version-is-even
BBCLASSEXTEND = "native"
# needed for writing out the qemu wrapper script
export STAGING_DIR_HOST
export B
DEPENDS_append = " libffi zlib glib-2.0 python3 flex-native bison-native"
# target build needs qemu to run temporary introspection binaries created
# on the fly by g-ir-scanner and a native version of itself to run
# native versions of its own tools during build.
# Also prelink-rtld is used to find out library dependencies of introspection binaries
# (standard ldd doesn't work when cross-compiling).
DEPENDS_class-target_append = " gobject-introspection-native qemu-native prelink-native"
Switch to Recipe Specific Sysroots This patch is comparatively large and invasive. It does only do one thing, switching the system to build using recipe specific sysroots and where changes could be isolated from it, that has been done. With the current single sysroot approach, its possible for software to find things which aren't in their dependencies. This leads to a determinism problem and is a growing issue in several of the market segments where OE makes sense. The way to solve this problem for OE is to have seperate sysroots for each recipe and these will only contain the dependencies for that recipe. Its worth noting that this is not task specific sysroots and that OE's dependencies do vary enormously by task. This did result in some implementation challenges. There is nothing stopping the implementation of task specific sysroots at some later point based on this work but that as deemed a bridge too far right now. Implementation details: * Rather than installing the sysroot artefacts into a combined sysroots, they are now placed in TMPDIR/sysroot-components/PACKAGE_ARCH/PN. * WORKDIR/recipe-sysroot and WORKDIR/recipe-sysroot-native are built by hardlinking in files from the sysroot-component trees. These new directories are known as RECIPE_SYSROOT and RECIPE_SYSROOT_NATIVE. * This construction is primarily done by a new do_prepare_recipe_sysroot task which runs before do_configure and consists of a call to the extend_recipe_sysroot function. * Other tasks need things in the sysroot before/after this, e.g. do_patch needs quilt-native and do_package_write_deb needs dpkg-native. The code therefore inspects the dependencies for each task and adds extend_recipe_sysroot as a prefunc if it has populate_sysroot dependencies. * We have to do a search/replace 'fixme' operation on the files installed into the sysroot to change hardcoded paths into the correct ones. We create a fixmepath file in the component directory which lists the files which need this operation. * Some files have "postinstall" commands which need to run against them, e.g. gdk-pixbuf each time a new loader is added. These are handled by adding files in bindir with the name prefixed by "postinst-" and are run in each sysroot as its created if they're present. This did mean most sstate postinstalls have to be rewritten but there shouldn't be many of them. * Since a recipe can have multiple tasks and these tasks can run against each other at the same time we have to have a lock when we perform write operations against the sysroot. We also have to maintain manifests of what we install against a task checksum of the dependency. If the checksum changes, we remove its files and then add the new ones. * The autotools logic for filtering the view of m4 files is no longer needed (and was the model for the way extend_recipe_sysroot works). * For autotools, we used to build a combined m4 macros directory which had both the native and target m4 files. We can no longer do this so we use the target sysroot as the default and add the native sysroot as an extra backup include path. If we don't do this, we'd have to build target pkg-config before we could built anything using pkg-config for example (ditto gettext). Such dependencies would be painful so we haven't required that. * PKDDATA_DIR was moved out the sysroot and works as before using sstate to build a hybrid copy for each machine. The paths therefore changed, the behaviour did not. * The ccache class had to be reworked to function with rss. * The TCBOOTSTRAP sysroot for compiler bootstrap is no longer needed but the -initial data does have to be filtered out from the main recipe sysroots. Putting "-initial" in a normal recipe name therefore remains a bad idea. * The logic in insane needed tweaks to deal with the new path layout, as did the debug source file extraction code in package.bbclass. * The logic in sstate.bbclass had to be rewritten since it previously only performed search and replace on extracted sstate and we now need this to happen even if the compiled path was "correct". This in theory could cause a mild performance issue but since the sysroot data was the main data that needed this and we'd have to do it there regardless with rss, I've opted just to change the way the class for everything. The built output used to build the sstate output is now retained and installed rather than deleted. * The search and replace logic used in sstate objects also seemed weak/incorrect and didn't hold up against testing. This has been rewritten too. There are some assumptions made about paths, we save the 'proper' search and replace operations to fixmepath.cmd but then ignore this. What is here works but is a little hardcoded and an area for future improvement. * In order to work with eSDK we need a way to build something that looks like the old style sysroot. "bitbake build-sysroots" will construct such a sysroot based on everything in the components directory that matches the current MACHINE. It will allow transition of external tools and can built target or native variants or both. It also supports a clean task. I'd suggest not relying on this for anything other than transitional purposes though. To see XXX in that sysroot, you'd have to have built that in a previous bitbake invocation. * pseudo is run out of its components directory. This is fine as its statically linked. * The hacks for wayland to see allarch dependencies in the multilib case are no longer needed and can be dropped. * wic needed more extensive changes to work with rss and the fixes are in a separate commit series * Various oe-selftest tweaks were needed since tests did assume the location to binaries and the combined sysroot in several cases. * Most missing dependencies this work found have been sent out as separate patches as they were found but a few tweaks are still included here. * A late addition is that extend_recipe_sysroot became multilib aware and able to populate multilib sysroots. I had hoped not to have to add that complexity but the meta-environment recipe forced my hand. That implementation can probably be neater but this is on the list of things to cleanup later at this point. In summary, the impact people will likely see after this change: * Recipes may fail with missing dependencies, particularly native tools like gettext-native, glib-2.0-native and libxml2.0-native. Some hosts have these installed and will mask these errors * Any recipe/class using SSTATEPOSTINSTFUNCS will need that code rewriting into a postinst * There was a separate patch series dealing with roots postinst native dependency issues. Any postinst which expects native tools at rootfs time will need to mark that dependency with PACKAGE_WRITE_DEPS. There could well be other issues. This has been tested repeatedly against our autobuilders and oe-selftest and issues found have been fixed. We believe at least OE-Core is in good shape but that doesn't mean we've found all the issues. Also, the logging is a bit chatty at the moment. It does help if something goes wrong and goes to the task logfiles, not the console so I've intentionally left this like that for now. We can turn it down easily enough in due course. (From OE-Core rev: 809746f56df4b91af014bf6a3f28997d6698ac78) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-12-07 13:54:35 +00:00
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}"
do_configure_prepend_class-native() {
# Tweak the native python scripts so that they don't refer to the
# full path of native python binary (the solution is taken from glib-2.0 recipe)
# This removes the risk of exceeding Linux kernel's shebang line limit (128 bytes)
sed -i -e '1s,#!.*,#!${USRBINPATH}/env python3,' ${S}/tools/g-ir-tool-template.in
}
do_configure_prepend_class-target() {
# Write out a qemu wrapper that will be given to gi-scanner so that it
# can run target helper binaries through that.
qemu_binary="${@qemu_wrapper_cmdline(d, '$STAGING_DIR_HOST', ['\$GIR_EXTRA_LIBS_PATH','.libs','$STAGING_DIR_HOST/${libdir}','$STAGING_DIR_HOST/${base_libdir}'])}"
cat > ${B}/g-ir-scanner-qemuwrapper << EOF
#!/bin/sh
# Use a modules directory which doesn't exist so we don't load random things
# which may then get deleted (or their dependencies) and potentially segfault
export GIO_MODULE_DIR=${STAGING_LIBDIR}/gio/modules-dummy
$qemu_binary "\$@"
if [ \$? -ne 0 ]; then
echo "If the above error message is about missing .so libraries, then setting up GIR_EXTRA_LIBS_PATH in the recipe should help."
echo "(typically like this: GIR_EXTRA_LIBS_PATH=\"$""{B}/something/.libs\" )"
exit 1
fi
EOF
chmod +x ${B}/g-ir-scanner-qemuwrapper
# Write out a wrapper for g-ir-scanner itself, which will be used when building introspection files
# for glib-based packages. This wrapper calls the native version of the scanner, and tells it to use
# a qemu wrapper for running transient target binaries produced by the scanner, and an include directory
# from the target sysroot.
cat > ${B}/g-ir-scanner-wrapper << EOF
#!/bin/sh
# This prevents g-ir-scanner from writing cache data to $HOME
export GI_SCANNER_DISABLE_CACHE=1
g-ir-scanner --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 "\$@"
EOF
chmod +x ${B}/g-ir-scanner-wrapper
# Write out a wrapper for g-ir-compiler, which runs the target version of it through qemu.
# g-ir-compiler writes out the raw content of a C struct to disk, and therefore is architecture dependent.
cat > ${B}/g-ir-compiler-wrapper << EOF
#!/bin/sh
${STAGING_BINDIR}/g-ir-scanner-qemuwrapper ${STAGING_BINDIR}/g-ir-compiler "\$@"
EOF
chmod +x ${B}/g-ir-compiler-wrapper
# Write out a wrapper to use instead of ldd, which does not work when a binary is built
# for a different architecture
cat > ${B}/g-ir-scanner-lddwrapper << EOF
#!/bin/sh
prelink-rtld --root=$STAGING_DIR_HOST "\$@"
EOF
chmod +x ${B}/g-ir-scanner-lddwrapper
# Also tweak the target python scripts so that they don't refer to the
# native version of python binary (the solution is taken from glib-2.0 recipe)
sed -i -e '1s,#!.*,#!${USRBINPATH}/env python3,' ${S}/tools/g-ir-tool-template.in
}
# Configure target build to use native tools of itself and to use a qemu wrapper
# and optionally to generate introspection data
EXTRA_OECONF_class-target += "--enable-host-gi \
--enable-gi-cross-wrapper=${B}/g-ir-scanner-qemuwrapper \
--enable-gi-ldd-wrapper=${B}/g-ir-scanner-lddwrapper \
${@bb.utils.contains('GI_DATA_ENABLED', 'True', '--enable-introspection-data', '--disable-introspection-data', d)} \
"
PACKAGECONFIG ?= ""
PACKAGECONFIG[doctool] = "--enable-doctool,--disable-doctool,python3-mako,"
gobject-introspection: set GI_SCANNER_DISABLE_CACHE for native The native recipe should not write files to $HOME/.cache as target, this can avoid problems when multi builds are running on the same host like: | File "./g-ir-scanner", line 66, in <module> | sys.exit(scanner_main(sys.argv)) | File "../gobject-introspection-1.48.0/giscanner/scannermain.py", line 543, in scanner_main | transformer = create_transformer(namespace, options) | File "../gobject-introspection-1.48.0/giscanner/scannermain.py", line 389, in create_transformer | symbol_filter_cmd=options.symbol_filter_cmd) | File "../gobject-introspection-1.48.0/giscanner/transformer.py", line 54, in __init__ | self._cachestore = CacheStore() | File "../gobject-introspection-1.48.0/giscanner/cachestore.py", line 61, in __init__ | self._check_cache_version() | File "../gobject-introspection-1.48.0/giscanner/cachestore.py", line 89, in _check_cache_version | self._clean() | File "../gobject-introspection-1.48.0/giscanner/cachestore.py", line 141, in _clean | self._remove_filename(os.path.join(self._directory, filename)) | File "../gobject-introspection-1.48.0/giscanner/cachestore.py", line 123, in _remove_filename | os.unlink(filename) | FileNotFoundError: [Errno 2] No such file or directory: '/home/pokybuild/.cache/g-ir-scanner/0a47aa95823c95a0b5d1bd610b60d02f35785f26' | Makefile:3518: recipe for target 'GModule-2.0.gir' failed (From OE-Core rev: d3c48ff7d19e86b2338b1778f9563969bba3d336) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-09-05 06:56:24 +00:00
do_compile_prepend() {
# This prevents g-ir-scanner from writing cache data to $HOME
export GI_SCANNER_DISABLE_CACHE=1
# Needed to run g-ir unit tests, which won't be able to find the built libraries otherwise
export GIR_EXTRA_LIBS_PATH=$B/.libs
}
# Our wrappers need to be available system-wide, because they will be used
# to build introspection files for all other gobject-based packages
do_install_append_class-target() {
install -d ${D}${bindir}/
install ${B}/g-ir-scanner-qemuwrapper ${D}${bindir}/
install ${B}/g-ir-scanner-wrapper ${D}${bindir}/
install ${B}/g-ir-compiler-wrapper ${D}${bindir}/
install ${B}/g-ir-scanner-lddwrapper ${D}${bindir}/
}
# .typelib files are needed at runtime and so they go to the main package
FILES_${PN}_append = " ${libdir}/girepository-*/*.typelib"
# .gir files go to dev package, as they're needed for developing (but not for running)
# things that depends on introspection.
FILES_${PN}-dev_append = " ${datadir}/gir-*/*.gir"
# These are used by gobject-based packages
# to generate transient introspection binaries
FILES_${PN}-dev_append = " ${datadir}/gobject-introspection-1.0/gdump.c \
${datadir}/gobject-introspection-1.0/Makefile.introspection"
# These are used by dependent packages (e.g. pygobject) to build their
# testsuites.
FILES_${PN}-dev_append = " ${datadir}/gobject-introspection-1.0/tests/*.c \
${datadir}/gobject-introspection-1.0/tests/*.h"
FILES_${PN}-dbg += "${libdir}/gobject-introspection/giscanner/.debug/"
FILES_${PN}-staticdev += "${libdir}/gobject-introspection/giscanner/*.a"
# we need target versions of introspection tools in sysroot so that they can be run via qemu
# when building introspection files in other packages
SYSROOT_DIRS_append_class-target = " ${bindir}"
SYSROOT_PREPROCESS_FUNCS_append_class-target = " gi_binaries_sysroot_preprocess"
gi_binaries_sysroot_preprocess() {
# Tweak the binary names in the introspection pkgconfig file, so that it
# picks up our wrappers which do the cross-compile and qemu magic.
sed -i \
-e "s|g_ir_scanner=.*|g_ir_scanner=${bindir}/g-ir-scanner-wrapper|" \
-e "s|g_ir_compiler=.*|g_ir_compiler=${bindir}/g-ir-compiler-wrapper|" \
${SYSROOT_DESTDIR}${libdir}/pkgconfig/gobject-introspection-1.0.pc
}
# Need to ensure ld.so.conf exists so prelink-native works
# both before we build and if we install from sstate
do_configure[prefuncs] += "gobject_introspection_preconfigure"
python gobject_introspection_preconfigure () {
oe.utils.write_ld_so_conf(d)
}
Switch to Recipe Specific Sysroots This patch is comparatively large and invasive. It does only do one thing, switching the system to build using recipe specific sysroots and where changes could be isolated from it, that has been done. With the current single sysroot approach, its possible for software to find things which aren't in their dependencies. This leads to a determinism problem and is a growing issue in several of the market segments where OE makes sense. The way to solve this problem for OE is to have seperate sysroots for each recipe and these will only contain the dependencies for that recipe. Its worth noting that this is not task specific sysroots and that OE's dependencies do vary enormously by task. This did result in some implementation challenges. There is nothing stopping the implementation of task specific sysroots at some later point based on this work but that as deemed a bridge too far right now. Implementation details: * Rather than installing the sysroot artefacts into a combined sysroots, they are now placed in TMPDIR/sysroot-components/PACKAGE_ARCH/PN. * WORKDIR/recipe-sysroot and WORKDIR/recipe-sysroot-native are built by hardlinking in files from the sysroot-component trees. These new directories are known as RECIPE_SYSROOT and RECIPE_SYSROOT_NATIVE. * This construction is primarily done by a new do_prepare_recipe_sysroot task which runs before do_configure and consists of a call to the extend_recipe_sysroot function. * Other tasks need things in the sysroot before/after this, e.g. do_patch needs quilt-native and do_package_write_deb needs dpkg-native. The code therefore inspects the dependencies for each task and adds extend_recipe_sysroot as a prefunc if it has populate_sysroot dependencies. * We have to do a search/replace 'fixme' operation on the files installed into the sysroot to change hardcoded paths into the correct ones. We create a fixmepath file in the component directory which lists the files which need this operation. * Some files have "postinstall" commands which need to run against them, e.g. gdk-pixbuf each time a new loader is added. These are handled by adding files in bindir with the name prefixed by "postinst-" and are run in each sysroot as its created if they're present. This did mean most sstate postinstalls have to be rewritten but there shouldn't be many of them. * Since a recipe can have multiple tasks and these tasks can run against each other at the same time we have to have a lock when we perform write operations against the sysroot. We also have to maintain manifests of what we install against a task checksum of the dependency. If the checksum changes, we remove its files and then add the new ones. * The autotools logic for filtering the view of m4 files is no longer needed (and was the model for the way extend_recipe_sysroot works). * For autotools, we used to build a combined m4 macros directory which had both the native and target m4 files. We can no longer do this so we use the target sysroot as the default and add the native sysroot as an extra backup include path. If we don't do this, we'd have to build target pkg-config before we could built anything using pkg-config for example (ditto gettext). Such dependencies would be painful so we haven't required that. * PKDDATA_DIR was moved out the sysroot and works as before using sstate to build a hybrid copy for each machine. The paths therefore changed, the behaviour did not. * The ccache class had to be reworked to function with rss. * The TCBOOTSTRAP sysroot for compiler bootstrap is no longer needed but the -initial data does have to be filtered out from the main recipe sysroots. Putting "-initial" in a normal recipe name therefore remains a bad idea. * The logic in insane needed tweaks to deal with the new path layout, as did the debug source file extraction code in package.bbclass. * The logic in sstate.bbclass had to be rewritten since it previously only performed search and replace on extracted sstate and we now need this to happen even if the compiled path was "correct". This in theory could cause a mild performance issue but since the sysroot data was the main data that needed this and we'd have to do it there regardless with rss, I've opted just to change the way the class for everything. The built output used to build the sstate output is now retained and installed rather than deleted. * The search and replace logic used in sstate objects also seemed weak/incorrect and didn't hold up against testing. This has been rewritten too. There are some assumptions made about paths, we save the 'proper' search and replace operations to fixmepath.cmd but then ignore this. What is here works but is a little hardcoded and an area for future improvement. * In order to work with eSDK we need a way to build something that looks like the old style sysroot. "bitbake build-sysroots" will construct such a sysroot based on everything in the components directory that matches the current MACHINE. It will allow transition of external tools and can built target or native variants or both. It also supports a clean task. I'd suggest not relying on this for anything other than transitional purposes though. To see XXX in that sysroot, you'd have to have built that in a previous bitbake invocation. * pseudo is run out of its components directory. This is fine as its statically linked. * The hacks for wayland to see allarch dependencies in the multilib case are no longer needed and can be dropped. * wic needed more extensive changes to work with rss and the fixes are in a separate commit series * Various oe-selftest tweaks were needed since tests did assume the location to binaries and the combined sysroot in several cases. * Most missing dependencies this work found have been sent out as separate patches as they were found but a few tweaks are still included here. * A late addition is that extend_recipe_sysroot became multilib aware and able to populate multilib sysroots. I had hoped not to have to add that complexity but the meta-environment recipe forced my hand. That implementation can probably be neater but this is on the list of things to cleanup later at this point. In summary, the impact people will likely see after this change: * Recipes may fail with missing dependencies, particularly native tools like gettext-native, glib-2.0-native and libxml2.0-native. Some hosts have these installed and will mask these errors * Any recipe/class using SSTATEPOSTINSTFUNCS will need that code rewriting into a postinst * There was a separate patch series dealing with roots postinst native dependency issues. Any postinst which expects native tools at rootfs time will need to mark that dependency with PACKAGE_WRITE_DEPS. There could well be other issues. This has been tested repeatedly against our autobuilders and oe-selftest and issues found have been fixed. We believe at least OE-Core is in good shape but that doesn't mean we've found all the issues. Also, the logging is a bit chatty at the moment. It does help if something goes wrong and goes to the task logfiles, not the console so I've intentionally left this like that for now. We can turn it down easily enough in due course. (From OE-Core rev: 809746f56df4b91af014bf6a3f28997d6698ac78) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-12-07 13:54:35 +00:00
SYSROOT_PREPROCESS_FUNCS_append = " gi_ldsoconf_sysroot_preprocess"
gi_ldsoconf_sysroot_preprocess () {
mkdir -p ${SYSROOT_DESTDIR}${bindir}
dest=${SYSROOT_DESTDIR}${bindir}/postinst-ldsoconf-${PN}
echo "#!/bin/sh" > $dest
echo "echo mkdir -p ${STAGING_DIR_TARGET}${sysconfdir} > ${STAGING_DIR_TARGET}${sysconfdir}/ld.so.conf" >> $dest
echo "echo ${base_libdir} >> ${STAGING_DIR_TARGET}${sysconfdir}/ld.so.conf" >> $dest
echo "echo ${libdir} >> ${STAGING_DIR_TARGET}${sysconfdir}/ld.so.conf" >> $dest
chmod 755 $dest
}