commit:     76bc068be542c46ac73264a306c78a1ac8142003
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 26 11:32:26 2020 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Oct 26 16:48:40 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=76bc068b

llvm.org.eclass: Add manpage build/install utilities

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/llvm.org.eclass | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/eclass/llvm.org.eclass b/eclass/llvm.org.eclass
index ec2c73c7276..c6f4d2a56c1 100644
--- a/eclass/llvm.org.eclass
+++ b/eclass/llvm.org.eclass
@@ -82,6 +82,13 @@ inherit multiprocessing
 # @DESCRIPTION:
 # List of additional components needed for tests.
 
+# @ECLASS-VARIABLE: LLVM_MANPAGES
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Set to 'build', include the dependency on dev-python/sphinx to build
+# the manpages.  If set to 'pregenerated', fetch and install
+# pregenerated manpages from the archive.
+
 
 # == global scope logic ==
 
@@ -118,6 +125,26 @@ llvm.org_set_globals() {
                RESTRICT+=" !test? ( test )"
        fi
 
+       case ${LLVM_MANPAGES:-__unset__} in
+               __unset__)
+                       # no manpage support
+                       ;;
+               build)
+                       IUSE+=" doc"
+                       # NB: this is not always the correct dep but it does no 
harm
+                       BDEPEND+=" dev-python/sphinx"
+                       ;;
+               pregenerated)
+                       IUSE+=" doc"
+                       SRC_URI+="
+                               !doc? (
+                                       
https://dev.gentoo.org/~mgorny/dist/llvm/llvm-${PV}-manpages.tar.bz2
+                               )"
+                       ;;
+               *)
+                       die "Invalid LLVM_MANPAGES=${LLVM_MANPAGES}"
+       esac
+
        # === useful defaults for cmake-based packages ===
 
        # least intrusive of all
@@ -204,3 +231,23 @@ llvm.org_src_prepare() {
 get_lit_flags() {
        echo "-vv;-j;${LIT_JOBS:-$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")}"
 }
+
+# @FUNCTION: llvm_are_manpages_built
+# @DESCRIPTION:
+# Return true (0) if manpages are going to be built from source,
+# false (1) if preinstalled manpages will be used.
+llvm_are_manpages_built() {
+       use doc || [[ ${LLVM_MANPAGES} == build ]]
+}
+
+# @FUNCTION: llvm_install_manpages
+# @DESCRIPTION:
+# Install pregenerated manpages if available.  No-op otherwise.
+llvm_install_manpages() {
+       # install pre-generated manpages
+       if ! llvm_are_manpages_built; then
+               # (doman does not support custom paths)
+               insinto "/usr/lib/llvm/${SLOT}/share/man/man1"
+               doins "${WORKDIR}/llvm-${PV}-manpages/${LLVM_COMPONENTS[0]}"/*.1
+       fi
+}

Reply via email to