1*4882a593Smuzhiyun# Helper class to pull in the right gtk-doc dependencies and configure 2*4882a593Smuzhiyun# gtk-doc to enable or disable documentation building (which requries the 3*4882a593Smuzhiyun# use of usermode qemu). 4*4882a593Smuzhiyun 5*4882a593Smuzhiyun# This variable is set to True if api-documentation is in 6*4882a593Smuzhiyun# DISTRO_FEATURES and qemu-usermode is in MACHINE_FEATURES, and False otherwise. 7*4882a593Smuzhiyun# 8*4882a593Smuzhiyun# It should be used in recipes to determine whether gtk-doc based documentation should be built, 9*4882a593Smuzhiyun# so that qemu use can be avoided when necessary. 10*4882a593SmuzhiyunGTKDOC_ENABLED:class-native = "False" 11*4882a593SmuzhiyunGTKDOC_ENABLED ?= "${@bb.utils.contains('DISTRO_FEATURES', 'api-documentation', \ 12*4882a593Smuzhiyun bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'True', 'False', d), 'False', d)}" 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun# meson: default option name to enable/disable gtk-doc. This matches most 15*4882a593Smuzhiyun# project's configuration. In doubts - check meson_options.txt in project's 16*4882a593Smuzhiyun# source path. 17*4882a593SmuzhiyunGTKDOC_MESON_OPTION ?= 'docs' 18*4882a593SmuzhiyunGTKDOC_MESON_ENABLE_FLAG ?= 'true' 19*4882a593SmuzhiyunGTKDOC_MESON_DISABLE_FLAG ?= 'false' 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun# Auto enable/disable based on GTKDOC_ENABLED 22*4882a593SmuzhiyunEXTRA_OECONF:prepend:class-target = "${@bb.utils.contains('GTKDOC_ENABLED', 'True', '--enable-gtk-doc --enable-gtk-doc-html --disable-gtk-doc-pdf', \ 23*4882a593Smuzhiyun '--disable-gtk-doc', d)} " 24*4882a593SmuzhiyunEXTRA_OEMESON:prepend:class-target = "-D${GTKDOC_MESON_OPTION}=${@bb.utils.contains('GTKDOC_ENABLED', 'True', '${GTKDOC_MESON_ENABLE_FLAG}', '${GTKDOC_MESON_DISABLE_FLAG}', d)} " 25*4882a593Smuzhiyun 26*4882a593Smuzhiyun# When building native recipes, disable gtkdoc, as it is not necessary, 27*4882a593Smuzhiyun# pulls in additional dependencies, and makes build times longer 28*4882a593SmuzhiyunEXTRA_OECONF:prepend:class-native = "--disable-gtk-doc " 29*4882a593SmuzhiyunEXTRA_OECONF:prepend:class-nativesdk = "--disable-gtk-doc " 30*4882a593SmuzhiyunEXTRA_OEMESON:prepend:class-native = "-D${GTKDOC_MESON_OPTION}=${GTKDOC_MESON_DISABLE_FLAG} " 31*4882a593SmuzhiyunEXTRA_OEMESON:prepend:class-nativesdk = "-D${GTKDOC_MESON_OPTION}=${GTKDOC_MESON_DISABLE_FLAG} " 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun# Even though gtkdoc is disabled on -native, gtk-doc package is still 34*4882a593Smuzhiyun# needed for m4 macros. 35*4882a593SmuzhiyunDEPENDS:append = " gtk-doc-native" 36*4882a593Smuzhiyun 37*4882a593Smuzhiyun# The documentation directory, where the infrastructure will be copied. 38*4882a593Smuzhiyun# gtkdocize has a default of "." so to handle out-of-tree builds set this to $S. 39*4882a593SmuzhiyunGTKDOC_DOCDIR ?= "${S}" 40*4882a593Smuzhiyun 41*4882a593Smuzhiyunexport STAGING_DIR_HOST 42*4882a593Smuzhiyun 43*4882a593Smuzhiyuninherit python3native pkgconfig qemu 44*4882a593SmuzhiyunDEPENDS:append = "${@' qemu-native' if d.getVar('GTKDOC_ENABLED') == 'True' else ''}" 45*4882a593Smuzhiyun 46*4882a593Smuzhiyundo_configure:prepend () { 47*4882a593Smuzhiyun # Need to use ||true as this is only needed if configure.ac both exists 48*4882a593Smuzhiyun # and uses GTK_DOC_CHECK. 49*4882a593Smuzhiyun gtkdocize --srcdir ${S} --docdir ${GTKDOC_DOCDIR} || true 50*4882a593Smuzhiyun} 51*4882a593Smuzhiyun 52*4882a593Smuzhiyundo_compile:prepend:class-target () { 53*4882a593Smuzhiyun if [ ${GTKDOC_ENABLED} = True ]; then 54*4882a593Smuzhiyun # Write out a qemu wrapper that will be given to gtkdoc-scangobj so that it 55*4882a593Smuzhiyun # can run target helper binaries through that. 56*4882a593Smuzhiyun qemu_binary="${@qemu_wrapper_cmdline(d, '$STAGING_DIR_HOST', ['\\$GIR_EXTRA_LIBS_PATH','$STAGING_DIR_HOST/${libdir}','$STAGING_DIR_HOST/${base_libdir}'])}" 57*4882a593Smuzhiyun cat > ${B}/gtkdoc-qemuwrapper << EOF 58*4882a593Smuzhiyun#!/bin/sh 59*4882a593Smuzhiyun# Use a modules directory which doesn't exist so we don't load random things 60*4882a593Smuzhiyun# which may then get deleted (or their dependencies) and potentially segfault 61*4882a593Smuzhiyunexport GIO_MODULE_DIR=${STAGING_LIBDIR}/gio/modules-dummy 62*4882a593Smuzhiyun 63*4882a593SmuzhiyunGIR_EXTRA_LIBS_PATH=\`find ${B} -name *.so -printf "%h\n"|sort|uniq| tr '\n' ':'\`\$GIR_EXTRA_LIBS_PATH 64*4882a593SmuzhiyunGIR_EXTRA_LIBS_PATH=\`find ${B} -name .libs| tr '\n' ':'\`\$GIR_EXTRA_LIBS_PATH 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun# meson sets this wrongly (only to libs in build-dir), qemu_wrapper_cmdline() and GIR_EXTRA_LIBS_PATH take care of it properly 67*4882a593Smuzhiyununset LD_LIBRARY_PATH 68*4882a593Smuzhiyun 69*4882a593Smuzhiyunif [ -d ".libs" ]; then 70*4882a593Smuzhiyun $qemu_binary ".libs/\$@" 71*4882a593Smuzhiyunelse 72*4882a593Smuzhiyun $qemu_binary "\$@" 73*4882a593Smuzhiyunfi 74*4882a593Smuzhiyun 75*4882a593Smuzhiyunif [ \$? -ne 0 ]; then 76*4882a593Smuzhiyun echo "If the above error message is about missing .so libraries, then setting up GIR_EXTRA_LIBS_PATH in the recipe should help." 77*4882a593Smuzhiyun echo "(typically like this: GIR_EXTRA_LIBS_PATH=\"$""{B}/something/.libs\" )" 78*4882a593Smuzhiyun exit 1 79*4882a593Smuzhiyunfi 80*4882a593SmuzhiyunEOF 81*4882a593Smuzhiyun chmod +x ${B}/gtkdoc-qemuwrapper 82*4882a593Smuzhiyun fi 83*4882a593Smuzhiyun} 84