Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 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. |
| 16 | GTKDOC_ENABLED:class-native = "False" |
| 17 | GTKDOC_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. |
| 23 | GTKDOC_MESON_OPTION ?= 'docs' |
| 24 | GTKDOC_MESON_ENABLE_FLAG ?= 'true' |
| 25 | GTKDOC_MESON_DISABLE_FLAG ?= 'false' |
| 26 | |
| 27 | # Auto enable/disable based on GTKDOC_ENABLED |
Patrick Williams | 705982a | 2024-01-12 09:51:57 -0600 | [diff] [blame] | 28 | EXTRA_OECONF:prepend = "${@bb.utils.contains('GTKDOC_ENABLED', 'True', '--enable-gtk-doc --enable-gtk-doc-html --disable-gtk-doc-pdf', \ |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 29 | '--disable-gtk-doc', d)} " |
Patrick Williams | 705982a | 2024-01-12 09:51:57 -0600 | [diff] [blame] | 30 | EXTRA_OEMESON:prepend = "-D${GTKDOC_MESON_OPTION}=${@bb.utils.contains('GTKDOC_ENABLED', 'True', '${GTKDOC_MESON_ENABLE_FLAG}', '${GTKDOC_MESON_DISABLE_FLAG}', d)} " |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 31 | |
| 32 | # Even though gtkdoc is disabled on -native, gtk-doc package is still |
| 33 | # needed for m4 macros. |
| 34 | DEPENDS:append = " gtk-doc-native" |
| 35 | |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 36 | export STAGING_DIR_HOST |
| 37 | |
| 38 | inherit python3native pkgconfig qemu |
| 39 | DEPENDS:append = "${@' qemu-native' if d.getVar('GTKDOC_ENABLED') == 'True' else ''}" |
| 40 | |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 41 | do_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 |
| 50 | export GIO_MODULE_DIR=${STAGING_LIBDIR}/gio/modules-dummy |
| 51 | |
| 52 | GIR_EXTRA_LIBS_PATH=\`find ${B} -name *.so -printf "%h\n"|sort|uniq| tr '\n' ':'\`\$GIR_EXTRA_LIBS_PATH |
| 53 | GIR_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 |
| 56 | unset LD_LIBRARY_PATH |
| 57 | |
| 58 | if [ -d ".libs" ]; then |
| 59 | $qemu_binary ".libs/\$@" |
| 60 | else |
| 61 | $qemu_binary "\$@" |
| 62 | fi |
| 63 | |
| 64 | if [ \$? -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 |
| 68 | fi |
| 69 | EOF |
| 70 | chmod +x ${B}/gtkdoc-qemuwrapper |
| 71 | fi |
| 72 | } |