blob: 0ae2729c0a001708114dd2d4b4ffa6bf0970fe47 [file] [log] [blame]
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001# 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 Williamsc124f4f2015-09-15 14:41:29 -05007#
Patrick Williamsc0f7c042017-02-23 20:41:17 -06008# 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.
10GTKDOC_ENABLED ?= "${@bb.utils.contains('DISTRO_FEATURES', 'api-documentation', \
11 bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'True', 'False', d), 'False', d)}"
12
13EXTRA_OECONF_prepend_class-target = "${@bb.utils.contains('GTKDOC_ENABLED', 'True', '--enable-gtk-doc --enable-gtk-doc-html --disable-gtk-doc-pdf', \
14 '--disable-gtk-doc', d)} "
15
16# When building native recipes, disable gtkdoc, as it is not necessary,
17# pulls in additional dependencies, and makes build times longer
18EXTRA_OECONF_prepend_class-native = "--disable-gtk-doc "
19EXTRA_OECONF_prepend_class-nativesdk = "--disable-gtk-doc "
20
21DEPENDS_append_class-target = " gtk-doc-native qemu-native"
22
23# Even though gtkdoc is disabled on -native, gtk-doc package is still
24# needed for m4 macros.
25DEPENDS_append_class-native = " gtk-doc-native"
26DEPENDS_append_class-nativesdk = " gtk-doc-native"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027
28# The documentation directory, where the infrastructure will be copied.
29# gtkdocize has a default of "." so to handle out-of-tree builds set this to $S.
30GTKDOC_DOCDIR ?= "${S}"
31
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032do_configure_prepend () {
Patrick Williamsc0f7c042017-02-23 20:41:17 -060033 ( cd ${S}; gtkdocize --docdir ${GTKDOC_DOCDIR} || true )
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034}
35
Patrick Williamsc0f7c042017-02-23 20:41:17 -060036inherit qemu
37
38export STAGING_DIR_HOST
39
40do_compile_prepend_class-target () {
41
42 # Write out a qemu wrapper that will be given to gtkdoc-scangobj so that it
43 # can run target helper binaries through that.
44 qemu_binary="${@qemu_wrapper_cmdline(d, '$STAGING_DIR_HOST', ['\$GIR_EXTRA_LIBS_PATH','$STAGING_DIR_HOST/${libdir}','$STAGING_DIR_HOST/${base_libdir}'])}"
45 cat > ${B}/gtkdoc-qemuwrapper << EOF
46#!/bin/sh
47# Use a modules directory which doesn't exist so we don't load random things
48# which may then get deleted (or their dependencies) and potentially segfault
49export GIO_MODULE_DIR=${STAGING_LIBDIR}/gio/modules-dummy
50
51GIR_EXTRA_LIBS_PATH=\`find ${B} -name .libs| tr '\n' ':'\`\$GIR_EXTRA_LIBS_PATH
52
Brad Bishop6e60e8b2018-02-01 10:27:11 -050053if [ -d ".libs" ]; then
Patrick Williamsc0f7c042017-02-23 20:41:17 -060054 $qemu_binary ".libs/\$@"
55else
56 $qemu_binary "\$@"
57fi
58
59if [ \$? -ne 0 ]; then
60 echo "If the above error message is about missing .so libraries, then setting up GIR_EXTRA_LIBS_PATH in the recipe should help."
61 echo "(typically like this: GIR_EXTRA_LIBS_PATH=\"$""{B}/something/.libs\" )"
62 exit 1
63fi
64EOF
65 chmod +x ${B}/gtkdoc-qemuwrapper
66}
67
68
Patrick Williamsc124f4f2015-09-15 14:41:29 -050069inherit pkgconfig