diff options
Diffstat (limited to 'meta/classes-recipe/gtk-doc.bbclass')
-rw-r--r-- | meta/classes-recipe/gtk-doc.bbclass | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/meta/classes-recipe/gtk-doc.bbclass b/meta/classes-recipe/gtk-doc.bbclass new file mode 100644 index 0000000000..68fa2cc745 --- /dev/null +++ b/meta/classes-recipe/gtk-doc.bbclass | |||
@@ -0,0 +1,89 @@ | |||
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 | ||
28 | EXTRA_OECONF:prepend:class-target = "${@bb.utils.contains('GTKDOC_ENABLED', 'True', '--enable-gtk-doc --enable-gtk-doc-html --disable-gtk-doc-pdf', \ | ||
29 | '--disable-gtk-doc', d)} " | ||
30 | EXTRA_OEMESON:prepend:class-target = "-D${GTKDOC_MESON_OPTION}=${@bb.utils.contains('GTKDOC_ENABLED', 'True', '${GTKDOC_MESON_ENABLE_FLAG}', '${GTKDOC_MESON_DISABLE_FLAG}', d)} " | ||
31 | |||
32 | # When building native recipes, disable gtkdoc, as it is not necessary, | ||
33 | # pulls in additional dependencies, and makes build times longer | ||
34 | EXTRA_OECONF:prepend:class-native = "--disable-gtk-doc " | ||
35 | EXTRA_OECONF:prepend:class-nativesdk = "--disable-gtk-doc " | ||
36 | EXTRA_OEMESON:prepend:class-native = "-D${GTKDOC_MESON_OPTION}=${GTKDOC_MESON_DISABLE_FLAG} " | ||
37 | EXTRA_OEMESON:prepend:class-nativesdk = "-D${GTKDOC_MESON_OPTION}=${GTKDOC_MESON_DISABLE_FLAG} " | ||
38 | |||
39 | # Even though gtkdoc is disabled on -native, gtk-doc package is still | ||
40 | # needed for m4 macros. | ||
41 | DEPENDS:append = " gtk-doc-native" | ||
42 | |||
43 | # The documentation directory, where the infrastructure will be copied. | ||
44 | # gtkdocize has a default of "." so to handle out-of-tree builds set this to $S. | ||
45 | GTKDOC_DOCDIR ?= "${S}" | ||
46 | |||
47 | export STAGING_DIR_HOST | ||
48 | |||
49 | inherit python3native pkgconfig qemu | ||
50 | DEPENDS:append = "${@' qemu-native' if d.getVar('GTKDOC_ENABLED') == 'True' else ''}" | ||
51 | |||
52 | do_configure:prepend () { | ||
53 | # Need to use ||true as this is only needed if configure.ac both exists | ||
54 | # and uses GTK_DOC_CHECK. | ||
55 | gtkdocize --srcdir ${S} --docdir ${GTKDOC_DOCDIR} || true | ||
56 | } | ||
57 | |||
58 | do_compile:prepend:class-target () { | ||
59 | if [ ${GTKDOC_ENABLED} = True ]; then | ||
60 | # Write out a qemu wrapper that will be given to gtkdoc-scangobj so that it | ||
61 | # can run target helper binaries through that. | ||
62 | qemu_binary="${@qemu_wrapper_cmdline(d, '$STAGING_DIR_HOST', ['\\$GIR_EXTRA_LIBS_PATH','$STAGING_DIR_HOST/${libdir}','$STAGING_DIR_HOST/${base_libdir}'])}" | ||
63 | cat > ${B}/gtkdoc-qemuwrapper << EOF | ||
64 | #!/bin/sh | ||
65 | # Use a modules directory which doesn't exist so we don't load random things | ||
66 | # which may then get deleted (or their dependencies) and potentially segfault | ||
67 | export GIO_MODULE_DIR=${STAGING_LIBDIR}/gio/modules-dummy | ||
68 | |||
69 | GIR_EXTRA_LIBS_PATH=\`find ${B} -name *.so -printf "%h\n"|sort|uniq| tr '\n' ':'\`\$GIR_EXTRA_LIBS_PATH | ||
70 | GIR_EXTRA_LIBS_PATH=\`find ${B} -name .libs| tr '\n' ':'\`\$GIR_EXTRA_LIBS_PATH | ||
71 | |||
72 | # meson sets this wrongly (only to libs in build-dir), qemu_wrapper_cmdline() and GIR_EXTRA_LIBS_PATH take care of it properly | ||
73 | unset LD_LIBRARY_PATH | ||
74 | |||
75 | if [ -d ".libs" ]; then | ||
76 | $qemu_binary ".libs/\$@" | ||
77 | else | ||
78 | $qemu_binary "\$@" | ||
79 | fi | ||
80 | |||
81 | if [ \$? -ne 0 ]; then | ||
82 | echo "If the above error message is about missing .so libraries, then setting up GIR_EXTRA_LIBS_PATH in the recipe should help." | ||
83 | echo "(typically like this: GIR_EXTRA_LIBS_PATH=\"$""{B}/something/.libs\" )" | ||
84 | exit 1 | ||
85 | fi | ||
86 | EOF | ||
87 | chmod +x ${B}/gtkdoc-qemuwrapper | ||
88 | fi | ||
89 | } | ||