gtk-doc.bbclass 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #
  2. # Copyright OpenEmbedded Contributors
  3. #
  4. # Helper class to pull in the right gtk-doc dependencies and configure
  5. # gtk-doc to enable or disable documentation building (which requries the
  6. # use of usermode qemu).
  7. # This variable is set to True if api-documentation is in
  8. # DISTRO_FEATURES and qemu-usermode is in MACHINE_FEATURES, and False otherwise.
  9. #
  10. # It should be used in recipes to determine whether gtk-doc based documentation should be built,
  11. # so that qemu use can be avoided when necessary.
  12. GTKDOC_ENABLED:class-native = "False"
  13. GTKDOC_ENABLED ?= "${@bb.utils.contains('DISTRO_FEATURES', 'api-documentation', \
  14. bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'True', 'False', d), 'False', d)}"
  15. # meson: default option name to enable/disable gtk-doc. This matches most
  16. # project's configuration. In doubts - check meson_options.txt in project's
  17. # source path.
  18. GTKDOC_MESON_OPTION ?= 'docs'
  19. GTKDOC_MESON_ENABLE_FLAG ?= 'true'
  20. GTKDOC_MESON_DISABLE_FLAG ?= 'false'
  21. # Auto enable/disable based on GTKDOC_ENABLED
  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)} "
  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)} "
  25. # When building native recipes, disable gtkdoc, as it is not necessary,
  26. # pulls in additional dependencies, and makes build times longer
  27. EXTRA_OECONF:prepend:class-native = "--disable-gtk-doc "
  28. EXTRA_OECONF:prepend:class-nativesdk = "--disable-gtk-doc "
  29. EXTRA_OEMESON:prepend:class-native = "-D${GTKDOC_MESON_OPTION}=${GTKDOC_MESON_DISABLE_FLAG} "
  30. EXTRA_OEMESON:prepend:class-nativesdk = "-D${GTKDOC_MESON_OPTION}=${GTKDOC_MESON_DISABLE_FLAG} "
  31. # Even though gtkdoc is disabled on -native, gtk-doc package is still
  32. # needed for m4 macros.
  33. DEPENDS:append = " gtk-doc-native"
  34. # The documentation directory, where the infrastructure will be copied.
  35. # gtkdocize has a default of "." so to handle out-of-tree builds set this to $S.
  36. GTKDOC_DOCDIR ?= "${S}"
  37. export STAGING_DIR_HOST
  38. inherit python3native pkgconfig qemu
  39. DEPENDS:append = "${@' qemu-native' if d.getVar('GTKDOC_ENABLED') == 'True' else ''}"
  40. do_configure:prepend () {
  41. # Need to use ||true as this is only needed if configure.ac both exists
  42. # and uses GTK_DOC_CHECK.
  43. gtkdocize --srcdir ${S} --docdir ${GTKDOC_DOCDIR} || true
  44. }
  45. do_compile:prepend:class-target () {
  46. if [ ${GTKDOC_ENABLED} = True ]; then
  47. # Write out a qemu wrapper that will be given to gtkdoc-scangobj so that it
  48. # can run target helper binaries through that.
  49. qemu_binary="${@qemu_wrapper_cmdline(d, '$STAGING_DIR_HOST', ['\\$GIR_EXTRA_LIBS_PATH','$STAGING_DIR_HOST/${libdir}','$STAGING_DIR_HOST/${base_libdir}'])}"
  50. cat > ${B}/gtkdoc-qemuwrapper << EOF
  51. #!/bin/sh
  52. # Use a modules directory which doesn't exist so we don't load random things
  53. # which may then get deleted (or their dependencies) and potentially segfault
  54. export GIO_MODULE_DIR=${STAGING_LIBDIR}/gio/modules-dummy
  55. GIR_EXTRA_LIBS_PATH=\`find ${B} -name *.so -printf "%h\n"|sort|uniq| tr '\n' ':'\`\$GIR_EXTRA_LIBS_PATH
  56. GIR_EXTRA_LIBS_PATH=\`find ${B} -name .libs| tr '\n' ':'\`\$GIR_EXTRA_LIBS_PATH
  57. # meson sets this wrongly (only to libs in build-dir), qemu_wrapper_cmdline() and GIR_EXTRA_LIBS_PATH take care of it properly
  58. unset LD_LIBRARY_PATH
  59. if [ -d ".libs" ]; then
  60. $qemu_binary ".libs/\$@"
  61. else
  62. $qemu_binary "\$@"
  63. fi
  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. }