blob: 7dd662bf8682d517cd4f98bdaa97f304edfa24f9 [file] [log] [blame]
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001# Helper class to pull in the right gtk-doc dependencies and configure
2# gtk-doc to enable or disable documentation building (which requries the
3# use of usermode qemu).
4
5# This variable is set to True if api-documentation is in
6# DISTRO_FEATURES and qemu-usermode is in MACHINE_FEATURES, and False otherwise.
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007#
Patrick Williamsc0f7c042017-02-23 20:41:17 -06008# It should be used in recipes to determine whether gtk-doc based documentation should be built,
9# so that qemu use can be avoided when necessary.
10GTKDOC_ENABLED ?= "${@bb.utils.contains('DISTRO_FEATURES', 'api-documentation', \
11 bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'True', 'False', d), 'False', d)}"
12
Brad Bishopc342db32019-05-15 21:57:59 -040013# meson: default option name to enable/disable gtk-doc. This matches most
14# project's configuration. In doubts - check meson_options.txt in project's
15# source path.
16GTKDOC_MESON_OPTION ?= 'docs'
17GTKDOC_MESON_ENABLE_FLAG ?= 'true'
18GTKDOC_MESON_DISABLE_FLAG ?= 'false'
19
20# Auto enable/disable based on GTKDOC_ENABLED
Patrick Williamsc0f7c042017-02-23 20:41:17 -060021EXTRA_OECONF_prepend_class-target = "${@bb.utils.contains('GTKDOC_ENABLED', 'True', '--enable-gtk-doc --enable-gtk-doc-html --disable-gtk-doc-pdf', \
22 '--disable-gtk-doc', d)} "
Brad Bishopc342db32019-05-15 21:57:59 -040023EXTRA_OEMESON_prepend_class-target = "-D${GTKDOC_MESON_OPTION}=${@bb.utils.contains('GTKDOC_ENABLED', 'True', '${GTKDOC_MESON_ENABLE_FLAG}', '${GTKDOC_MESON_DISABLE_FLAG}', d)} "
Patrick Williamsc0f7c042017-02-23 20:41:17 -060024
25# When building native recipes, disable gtkdoc, as it is not necessary,
26# pulls in additional dependencies, and makes build times longer
27EXTRA_OECONF_prepend_class-native = "--disable-gtk-doc "
28EXTRA_OECONF_prepend_class-nativesdk = "--disable-gtk-doc "
Brad Bishopc342db32019-05-15 21:57:59 -040029EXTRA_OEMESON_prepend_class-native = "-D${GTKDOC_MESON_OPTION}=${GTKDOC_MESON_DISABLE_FLAG} "
30EXTRA_OEMESON_prepend_class-nativesdk = "-D${GTKDOC_MESON_OPTION}=${GTKDOC_MESON_DISABLE_FLAG} "
Patrick Williamsc0f7c042017-02-23 20:41:17 -060031
Patrick Williamsc0f7c042017-02-23 20:41:17 -060032# Even though gtkdoc is disabled on -native, gtk-doc package is still
33# needed for m4 macros.
Brad Bishop316dfdd2018-06-25 12:45:53 -040034DEPENDS_append = " gtk-doc-native"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050035
36# The documentation directory, where the infrastructure will be copied.
37# gtkdocize has a default of "." so to handle out-of-tree builds set this to $S.
38GTKDOC_DOCDIR ?= "${S}"
39
Patrick Williamsc0f7c042017-02-23 20:41:17 -060040export STAGING_DIR_HOST
41
Brad Bishop316dfdd2018-06-25 12:45:53 -040042inherit python3native pkgconfig qemu
43DEPENDS_append = "${@' qemu-native' if d.getVar('GTKDOC_ENABLED') == 'True' else ''}"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060044
Brad Bishop316dfdd2018-06-25 12:45:53 -040045do_configure_prepend () {
46 # Need to use ||true as this is only needed if configure.ac both exists
47 # and uses GTK_DOC_CHECK.
48 gtkdocize --srcdir ${S} --docdir ${GTKDOC_DOCDIR} || true
49}
50
51do_compile_prepend_class-target () {
52 if [ ${GTKDOC_ENABLED} = True ]; then
Patrick Williamsc0f7c042017-02-23 20:41:17 -060053 # Write out a qemu wrapper that will be given to gtkdoc-scangobj so that it
54 # can run target helper binaries through that.
Brad Bishop19323692019-04-05 15:28:33 -040055 qemu_binary="${@qemu_wrapper_cmdline(d, '$STAGING_DIR_HOST', ['\\$GIR_EXTRA_LIBS_PATH','$STAGING_DIR_HOST/${libdir}','$STAGING_DIR_HOST/${base_libdir}'])}"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060056 cat > ${B}/gtkdoc-qemuwrapper << EOF
57#!/bin/sh
58# Use a modules directory which doesn't exist so we don't load random things
59# which may then get deleted (or their dependencies) and potentially segfault
60export GIO_MODULE_DIR=${STAGING_LIBDIR}/gio/modules-dummy
61
Brad Bishopd7bf8c12018-02-25 22:55:05 -050062GIR_EXTRA_LIBS_PATH=\`find ${B} -name *.so -printf "%h\n"|sort|uniq| tr '\n' ':'\`\$GIR_EXTRA_LIBS_PATH
Patrick Williamsc0f7c042017-02-23 20:41:17 -060063GIR_EXTRA_LIBS_PATH=\`find ${B} -name .libs| tr '\n' ':'\`\$GIR_EXTRA_LIBS_PATH
64
Brad Bishop19323692019-04-05 15:28:33 -040065# meson sets this wrongly (only to libs in build-dir), qemu-wrapper_cmdline() and GIR_EXTRA_LIBS_PATH take care of it properly
66unset LD_LIBRARY_PATH
67
Brad Bishop6e60e8b2018-02-01 10:27:11 -050068if [ -d ".libs" ]; then
Patrick Williamsc0f7c042017-02-23 20:41:17 -060069 $qemu_binary ".libs/\$@"
70else
71 $qemu_binary "\$@"
72fi
73
74if [ \$? -ne 0 ]; then
75 echo "If the above error message is about missing .so libraries, then setting up GIR_EXTRA_LIBS_PATH in the recipe should help."
76 echo "(typically like this: GIR_EXTRA_LIBS_PATH=\"$""{B}/something/.libs\" )"
77 exit 1
78fi
79EOF
80 chmod +x ${B}/gtkdoc-qemuwrapper
Brad Bishop316dfdd2018-06-25 12:45:53 -040081 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -060082}