gtk-doc.bbclass 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. # This variable is set to True if api-documentation is in
  5. # DISTRO_FEATURES and qemu-usermode is in MACHINE_FEATURES, and False otherwise.
  6. #
  7. # It should be used in recipes to determine whether gtk-doc based documentation should be built,
  8. # so that qemu use can be avoided when necessary.
  9. GTKDOC_ENABLED ?= "${@bb.utils.contains('DISTRO_FEATURES', 'api-documentation', \
  10. bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'True', 'False', d), 'False', d)}"
  11. # meson: default option name to enable/disable gtk-doc. This matches most
  12. # project's configuration. In doubts - check meson_options.txt in project's
  13. # source path.
  14. GTKDOC_MESON_OPTION ?= 'docs'
  15. GTKDOC_MESON_ENABLE_FLAG ?= 'true'
  16. GTKDOC_MESON_DISABLE_FLAG ?= 'false'
  17. # Auto enable/disable based on GTKDOC_ENABLED
  18. EXTRA_OECONF_prepend_class-target = "${@bb.utils.contains('GTKDOC_ENABLED', 'True', '--enable-gtk-doc --enable-gtk-doc-html --disable-gtk-doc-pdf', \
  19. '--disable-gtk-doc', d)} "
  20. EXTRA_OEMESON_prepend_class-target = "-D${GTKDOC_MESON_OPTION}=${@bb.utils.contains('GTKDOC_ENABLED', 'True', '${GTKDOC_MESON_ENABLE_FLAG}', '${GTKDOC_MESON_DISABLE_FLAG}', d)} "
  21. # When building native recipes, disable gtkdoc, as it is not necessary,
  22. # pulls in additional dependencies, and makes build times longer
  23. EXTRA_OECONF_prepend_class-native = "--disable-gtk-doc "
  24. EXTRA_OECONF_prepend_class-nativesdk = "--disable-gtk-doc "
  25. EXTRA_OEMESON_prepend_class-native = "-D${GTKDOC_MESON_OPTION}=${GTKDOC_MESON_DISABLE_FLAG} "
  26. EXTRA_OEMESON_prepend_class-nativesdk = "-D${GTKDOC_MESON_OPTION}=${GTKDOC_MESON_DISABLE_FLAG} "
  27. # Even though gtkdoc is disabled on -native, gtk-doc package is still
  28. # needed for m4 macros.
  29. DEPENDS_append = " gtk-doc-native"
  30. # The documentation directory, where the infrastructure will be copied.
  31. # gtkdocize has a default of "." so to handle out-of-tree builds set this to $S.
  32. GTKDOC_DOCDIR ?= "${S}"
  33. export STAGING_DIR_HOST
  34. inherit python3native pkgconfig qemu
  35. DEPENDS_append = "${@' qemu-native' if d.getVar('GTKDOC_ENABLED') == 'True' else ''}"
  36. do_configure_prepend () {
  37. # Need to use ||true as this is only needed if configure.ac both exists
  38. # and uses GTK_DOC_CHECK.
  39. gtkdocize --srcdir ${S} --docdir ${GTKDOC_DOCDIR} || true
  40. }
  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. GIR_EXTRA_LIBS_PATH=\`find ${B} -name *.so -printf "%h\n"|sort|uniq| tr '\n' ':'\`\$GIR_EXTRA_LIBS_PATH
  52. GIR_EXTRA_LIBS_PATH=\`find ${B} -name .libs| tr '\n' ':'\`\$GIR_EXTRA_LIBS_PATH
  53. # meson sets this wrongly (only to libs in build-dir), qemu-wrapper_cmdline() and GIR_EXTRA_LIBS_PATH take care of it properly
  54. unset LD_LIBRARY_PATH
  55. if [ -d ".libs" ]; then
  56. $qemu_binary ".libs/\$@"
  57. else
  58. $qemu_binary "\$@"
  59. fi
  60. if [ \$? -ne 0 ]; then
  61. echo "If the above error message is about missing .so libraries, then setting up GIR_EXTRA_LIBS_PATH in the recipe should help."
  62. echo "(typically like this: GIR_EXTRA_LIBS_PATH=\"$""{B}/something/.libs\" )"
  63. exit 1
  64. fi
  65. EOF
  66. chmod +x ${B}/gtkdoc-qemuwrapper
  67. fi
  68. }