Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1 | # 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7 | # |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8 | # 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. |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame^] | 10 | GTKDOC_ENABLED_class-native = "False" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 11 | GTKDOC_ENABLED ?= "${@bb.utils.contains('DISTRO_FEATURES', 'api-documentation', \ |
| 12 | bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'True', 'False', d), 'False', d)}" |
| 13 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 14 | # meson: default option name to enable/disable gtk-doc. This matches most |
| 15 | # project's configuration. In doubts - check meson_options.txt in project's |
| 16 | # source path. |
| 17 | GTKDOC_MESON_OPTION ?= 'docs' |
| 18 | GTKDOC_MESON_ENABLE_FLAG ?= 'true' |
| 19 | GTKDOC_MESON_DISABLE_FLAG ?= 'false' |
| 20 | |
| 21 | # Auto enable/disable based on GTKDOC_ENABLED |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 22 | EXTRA_OECONF_prepend_class-target = "${@bb.utils.contains('GTKDOC_ENABLED', 'True', '--enable-gtk-doc --enable-gtk-doc-html --disable-gtk-doc-pdf', \ |
| 23 | '--disable-gtk-doc', d)} " |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 24 | EXTRA_OEMESON_prepend_class-target = "-D${GTKDOC_MESON_OPTION}=${@bb.utils.contains('GTKDOC_ENABLED', 'True', '${GTKDOC_MESON_ENABLE_FLAG}', '${GTKDOC_MESON_DISABLE_FLAG}', d)} " |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 25 | |
| 26 | # When building native recipes, disable gtkdoc, as it is not necessary, |
| 27 | # pulls in additional dependencies, and makes build times longer |
| 28 | EXTRA_OECONF_prepend_class-native = "--disable-gtk-doc " |
| 29 | EXTRA_OECONF_prepend_class-nativesdk = "--disable-gtk-doc " |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 30 | EXTRA_OEMESON_prepend_class-native = "-D${GTKDOC_MESON_OPTION}=${GTKDOC_MESON_DISABLE_FLAG} " |
| 31 | EXTRA_OEMESON_prepend_class-nativesdk = "-D${GTKDOC_MESON_OPTION}=${GTKDOC_MESON_DISABLE_FLAG} " |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 32 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 33 | # Even though gtkdoc is disabled on -native, gtk-doc package is still |
| 34 | # needed for m4 macros. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 35 | DEPENDS_append = " gtk-doc-native" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 36 | |
| 37 | # The documentation directory, where the infrastructure will be copied. |
| 38 | # gtkdocize has a default of "." so to handle out-of-tree builds set this to $S. |
| 39 | GTKDOC_DOCDIR ?= "${S}" |
| 40 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 41 | export STAGING_DIR_HOST |
| 42 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 43 | inherit python3native pkgconfig qemu |
| 44 | DEPENDS_append = "${@' qemu-native' if d.getVar('GTKDOC_ENABLED') == 'True' else ''}" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 45 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 46 | do_configure_prepend () { |
| 47 | # Need to use ||true as this is only needed if configure.ac both exists |
| 48 | # and uses GTK_DOC_CHECK. |
| 49 | gtkdocize --srcdir ${S} --docdir ${GTKDOC_DOCDIR} || true |
| 50 | } |
| 51 | |
| 52 | do_compile_prepend_class-target () { |
| 53 | if [ ${GTKDOC_ENABLED} = True ]; then |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 54 | # Write out a qemu wrapper that will be given to gtkdoc-scangobj so that it |
| 55 | # can run target helper binaries through that. |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 56 | qemu_binary="${@qemu_wrapper_cmdline(d, '$STAGING_DIR_HOST', ['\\$GIR_EXTRA_LIBS_PATH','$STAGING_DIR_HOST/${libdir}','$STAGING_DIR_HOST/${base_libdir}'])}" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 57 | cat > ${B}/gtkdoc-qemuwrapper << EOF |
| 58 | #!/bin/sh |
| 59 | # Use a modules directory which doesn't exist so we don't load random things |
| 60 | # which may then get deleted (or their dependencies) and potentially segfault |
| 61 | export GIO_MODULE_DIR=${STAGING_LIBDIR}/gio/modules-dummy |
| 62 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 63 | GIR_EXTRA_LIBS_PATH=\`find ${B} -name *.so -printf "%h\n"|sort|uniq| tr '\n' ':'\`\$GIR_EXTRA_LIBS_PATH |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 64 | GIR_EXTRA_LIBS_PATH=\`find ${B} -name .libs| tr '\n' ':'\`\$GIR_EXTRA_LIBS_PATH |
| 65 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 66 | # meson sets this wrongly (only to libs in build-dir), qemu-wrapper_cmdline() and GIR_EXTRA_LIBS_PATH take care of it properly |
| 67 | unset LD_LIBRARY_PATH |
| 68 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 69 | if [ -d ".libs" ]; then |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 70 | $qemu_binary ".libs/\$@" |
| 71 | else |
| 72 | $qemu_binary "\$@" |
| 73 | fi |
| 74 | |
| 75 | if [ \$? -ne 0 ]; then |
| 76 | echo "If the above error message is about missing .so libraries, then setting up GIR_EXTRA_LIBS_PATH in the recipe should help." |
| 77 | echo "(typically like this: GIR_EXTRA_LIBS_PATH=\"$""{B}/something/.libs\" )" |
| 78 | exit 1 |
| 79 | fi |
| 80 | EOF |
| 81 | chmod +x ${B}/gtkdoc-qemuwrapper |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 82 | fi |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 83 | } |