1# 2# Copyright OpenEmbedded Contributors 3# 4# SPDX-License-Identifier: MIT 5# 6 7# Helper class to pull in the right gtk-doc dependencies and configure 8# gtk-doc to enable or disable documentation building (which requries the 9# use of usermode qemu). 10 11# This variable is set to True if api-documentation is in 12# DISTRO_FEATURES and qemu-usermode is in MACHINE_FEATURES, and False otherwise. 13# 14# It should be used in recipes to determine whether gtk-doc based documentation should be built, 15# so that qemu use can be avoided when necessary. 16GTKDOC_ENABLED:class-native = "False" 17GTKDOC_ENABLED ?= "${@bb.utils.contains('DISTRO_FEATURES', 'api-documentation', \ 18 bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'True', 'False', d), 'False', d)}" 19 20# meson: default option name to enable/disable gtk-doc. This matches most 21# project's configuration. In doubts - check meson_options.txt in project's 22# source path. 23GTKDOC_MESON_OPTION ?= 'docs' 24GTKDOC_MESON_ENABLE_FLAG ?= 'true' 25GTKDOC_MESON_DISABLE_FLAG ?= 'false' 26 27# Auto enable/disable based on GTKDOC_ENABLED 28EXTRA_OECONF:prepend = "${@bb.utils.contains('GTKDOC_ENABLED', 'True', '--enable-gtk-doc --enable-gtk-doc-html --disable-gtk-doc-pdf', \ 29 '--disable-gtk-doc', d)} " 30EXTRA_OEMESON:prepend = "-D${GTKDOC_MESON_OPTION}=${@bb.utils.contains('GTKDOC_ENABLED', 'True', '${GTKDOC_MESON_ENABLE_FLAG}', '${GTKDOC_MESON_DISABLE_FLAG}', d)} " 31 32# Even though gtkdoc is disabled on -native, gtk-doc package is still 33# needed for m4 macros. 34DEPENDS:append = " gtk-doc-native" 35 36export STAGING_DIR_HOST 37 38inherit python3native pkgconfig qemu 39DEPENDS:append = "${@' qemu-native' if d.getVar('GTKDOC_ENABLED') == 'True' else ''}" 40 41do_compile:prepend:class-target () { 42 if [ ${GTKDOC_ENABLED} = True ]; then 43 # Write out a qemu wrapper that will be given to gtkdoc-scangobj so that it 44 # can run target helper binaries through that. 45 qemu_binary="${@qemu_wrapper_cmdline(d, '$STAGING_DIR_HOST', ['\\$GIR_EXTRA_LIBS_PATH','$STAGING_DIR_HOST/${libdir}','$STAGING_DIR_HOST/${base_libdir}'])}" 46 cat > ${B}/gtkdoc-qemuwrapper << EOF 47#!/bin/sh 48# Use a modules directory which doesn't exist so we don't load random things 49# which may then get deleted (or their dependencies) and potentially segfault 50export GIO_MODULE_DIR=${STAGING_LIBDIR}/gio/modules-dummy 51 52GIR_EXTRA_LIBS_PATH=\`find ${B} -name *.so -printf "%h\n"|sort|uniq| tr '\n' ':'\`\$GIR_EXTRA_LIBS_PATH 53GIR_EXTRA_LIBS_PATH=\`find ${B} -name .libs| tr '\n' ':'\`\$GIR_EXTRA_LIBS_PATH 54 55# meson sets this wrongly (only to libs in build-dir), qemu_wrapper_cmdline() and GIR_EXTRA_LIBS_PATH take care of it properly 56unset LD_LIBRARY_PATH 57 58if [ -d ".libs" ]; then 59 $qemu_binary ".libs/\$@" 60else 61 $qemu_binary "\$@" 62fi 63 64if [ \$? -ne 0 ]; then 65 echo "If the above error message is about missing .so libraries, then setting up GIR_EXTRA_LIBS_PATH in the recipe should help." 66 echo "(typically like this: GIR_EXTRA_LIBS_PATH=\"$""{B}/something/.libs\" )" 67 exit 1 68fi 69EOF 70 chmod +x ${B}/gtkdoc-qemuwrapper 71 fi 72} 73