|
| 1 | +#!/bin/sh |
| 2 | +#===-- build-docs.sh - Tag the LLVM release candidates ---------------------===# |
| 3 | +# |
| 4 | +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | +# See https://llvm.org/LICENSE.txt for license information. |
| 6 | +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 | +# |
| 8 | +#===------------------------------------------------------------------------===# |
| 9 | +# |
| 10 | +# Build documentation for LLVM releases. |
| 11 | +# |
| 12 | +# Required Packages: |
| 13 | +# * Fedora: |
| 14 | +# * dnf install doxygen python3-sphinx texlive-epstopdf ghostscript \ |
| 15 | +# ninja-build gcc-c++ |
| 16 | +# * pip install sphinx-markdown-tables |
| 17 | +# * Ubuntu: |
| 18 | +# * apt-get install doxygen sphinx-common python3-recommonmark \ |
| 19 | +# ninja-build graphviz texlive-font-utils |
| 20 | +# * pip install sphinx-markdown-tables |
| 21 | +#===------------------------------------------------------------------------===# |
| 22 | + |
| 23 | +set -ex |
| 24 | + |
| 25 | +builddir=docs-build |
| 26 | +srcdir=$(readlink -f $(dirname "$(readlink -f "$0")")/../..) |
| 27 | + |
| 28 | +usage() { |
| 29 | + echo "Build the documentation for an LLVM release. This only needs to be " |
| 30 | + echo "done for -final releases." |
| 31 | + echo "usage: `basename $0`" |
| 32 | + echo " " |
| 33 | + echo " -release <num> Fetch the tarball for release <num> and build the " |
| 34 | + echo " documentation from that source." |
| 35 | + echo " -srcdir <dir> Path to llvm source directory with CMakeLists.txt" |
| 36 | + echo " (optional) default: $srcdir" |
| 37 | +} |
| 38 | + |
| 39 | +package_doxygen() { |
| 40 | + |
| 41 | + project=$1 |
| 42 | + proj_dir=$2 |
| 43 | + output=${project}_doxygen-$release |
| 44 | + |
| 45 | + mv $builddir/$proj_dir/docs/doxygen/html $output |
| 46 | + tar -cJf $output.tar.xz $output |
| 47 | +} |
| 48 | + |
| 49 | + |
| 50 | +while [ $# -gt 0 ]; do |
| 51 | + case $1 in |
| 52 | + -release ) |
| 53 | + shift |
| 54 | + release=$1 |
| 55 | + ;; |
| 56 | + -srcdir ) |
| 57 | + shift |
| 58 | + custom_srcdir=$1 |
| 59 | + ;; |
| 60 | + * ) |
| 61 | + echo "unknown option: $1" |
| 62 | + usage |
| 63 | + exit 1 |
| 64 | + ;; |
| 65 | + esac |
| 66 | + shift |
| 67 | +done |
| 68 | + |
| 69 | +if [ -n "$release" -a -n "$custom_srcdir" ]; then |
| 70 | + echo "error: Cannot specify both -srcdir and -release options" |
| 71 | + exit 1 |
| 72 | +fi |
| 73 | + |
| 74 | +if [ -n "$custom_srcdir" ]; then |
| 75 | + srcdir="$custom_srcdir" |
| 76 | +fi |
| 77 | + |
| 78 | +# Set default source directory if one is not supplied |
| 79 | +if [ -n "$release" ]; then |
| 80 | + git_ref=llvmorg-$release |
| 81 | + if [ -d llvm-project ]; then |
| 82 | + echo "error llvm-project directory already exists" |
| 83 | + exit 1 |
| 84 | + fi |
| 85 | + mkdir -p llvm-project |
| 86 | + pushd llvm-project |
| 87 | + curl -L https://github.com/llvm/llvm-project/archive/$git_ref.tar.gz | tar --strip-components=1 -xzf - |
| 88 | + popd |
| 89 | + srcdir="./llvm-project/llvm" |
| 90 | +fi |
| 91 | + |
| 92 | +cmake -G Ninja $srcdir -B $builddir \ |
| 93 | + -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;libcxx;polly;flang" \ |
| 94 | + -DCMAKE_BUILD_TYPE=Release \ |
| 95 | + -DLLVM_ENABLE_DOXYGEN=ON \ |
| 96 | + -DLLVM_ENABLE_SPHINX=ON \ |
| 97 | + -DLLVM_BUILD_DOCS=ON \ |
| 98 | + -DLLVM_DOXYGEN_SVG=ON \ |
| 99 | + -DSPHINX_WARNINGS_AS_ERRORS=OFF |
| 100 | + |
| 101 | +ninja -C $builddir \ |
| 102 | + docs-clang-html \ |
| 103 | + docs-clang-tools-html \ |
| 104 | + docs-flang-html \ |
| 105 | + docs-libcxx-html \ |
| 106 | + docs-lld-html \ |
| 107 | + docs-llvm-html \ |
| 108 | + docs-polly-html \ |
| 109 | + doxygen-clang \ |
| 110 | + doxygen-clang-tools \ |
| 111 | + doxygen-flang \ |
| 112 | + doxygen-llvm \ |
| 113 | + doxygen-mlir \ |
| 114 | + doxygen-polly |
| 115 | + |
| 116 | + |
| 117 | +package_doxygen llvm . |
| 118 | +package_doxygen clang tools/clang |
| 119 | +package_doxygen clang-tools-extra tools/clang/tools/extra |
| 120 | +package_doxygen flang tools/flang |
| 121 | + |
| 122 | +html_dir=$builddir/html-export/ |
| 123 | + |
| 124 | +for d in docs/ tools/clang/docs/ tools/lld/docs/ tools/clang/tools/extra/docs/ projects/libcxx/docs/ tools/polly/docs/ tools/flang/docs/; do |
| 125 | + mkdir -p $html_dir/$d |
| 126 | + mv $builddir/$d/html/* $html_dir/$d/ |
| 127 | +done |
0 commit comments