166d755bbSTom Stellard#!/bin/bash 2622346c6STom Stellard#===-- build-docs.sh - Tag the LLVM release candidates ---------------------===# 3622346c6STom Stellard# 4622346c6STom Stellard# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5622346c6STom Stellard# See https://llvm.org/LICENSE.txt for license information. 6622346c6STom Stellard# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7622346c6STom Stellard# 8622346c6STom Stellard#===------------------------------------------------------------------------===# 9622346c6STom Stellard# 10622346c6STom Stellard# Build documentation for LLVM releases. 11622346c6STom Stellard# 12622346c6STom Stellard# Required Packages: 13622346c6STom Stellard# * Fedora: 14*b7ff0320Scor3ntin# * dnf install doxygen texlive-epstopdf ghostscript \ 15622346c6STom Stellard# ninja-build gcc-c++ 16*b7ff0320Scor3ntin# * pip install --user -r ./llvm/docs/requirements.txt 17622346c6STom Stellard# * Ubuntu: 18*b7ff0320Scor3ntin# * apt-get install doxygen \ 19622346c6STom Stellard# ninja-build graphviz texlive-font-utils 20*b7ff0320Scor3ntin# * pip install --user -r ./llvm/docs/requirements.txt 21622346c6STom Stellard#===------------------------------------------------------------------------===# 22622346c6STom Stellard 23fe7fe6d3STobias Hietaset -e 24622346c6STom Stellard 25622346c6STom Stellardbuilddir=docs-build 26622346c6STom Stellardsrcdir=$(readlink -f $(dirname "$(readlink -f "$0")")/../..) 27622346c6STom Stellard 28622346c6STom Stellardusage() { 29622346c6STom Stellard echo "Build the documentation for an LLVM release. This only needs to be " 30622346c6STom Stellard echo "done for -final releases." 31622346c6STom Stellard echo "usage: `basename $0`" 32622346c6STom Stellard echo " " 33622346c6STom Stellard echo " -release <num> Fetch the tarball for release <num> and build the " 34622346c6STom Stellard echo " documentation from that source." 35622346c6STom Stellard echo " -srcdir <dir> Path to llvm source directory with CMakeLists.txt" 36622346c6STom Stellard echo " (optional) default: $srcdir" 37fe7fe6d3STobias Hieta echo " -no-doxygen Don't build Doxygen docs" 38fe7fe6d3STobias Hieta echo " -no-sphinx Don't build Spinx docs" 39622346c6STom Stellard} 40622346c6STom Stellard 41622346c6STom Stellardpackage_doxygen() { 42622346c6STom Stellard 43622346c6STom Stellard project=$1 44622346c6STom Stellard proj_dir=$2 45622346c6STom Stellard output=${project}_doxygen-$release 46622346c6STom Stellard 47622346c6STom Stellard mv $builddir/$proj_dir/docs/doxygen/html $output 48622346c6STom Stellard tar -cJf $output.tar.xz $output 49622346c6STom Stellard} 50622346c6STom Stellard 51622346c6STom Stellard 52622346c6STom Stellardwhile [ $# -gt 0 ]; do 53622346c6STom Stellard case $1 in 54622346c6STom Stellard -release ) 55622346c6STom Stellard shift 56622346c6STom Stellard release=$1 57622346c6STom Stellard ;; 58622346c6STom Stellard -srcdir ) 59622346c6STom Stellard shift 60622346c6STom Stellard custom_srcdir=$1 61622346c6STom Stellard ;; 62fe7fe6d3STobias Hieta -no-doxygen ) 63fe7fe6d3STobias Hieta no_doxygen="yes" 64fe7fe6d3STobias Hieta ;; 65fe7fe6d3STobias Hieta -no-sphinx ) 66fe7fe6d3STobias Hieta no_sphinx="yes" 67fe7fe6d3STobias Hieta ;; 68622346c6STom Stellard * ) 69622346c6STom Stellard echo "unknown option: $1" 70622346c6STom Stellard usage 71622346c6STom Stellard exit 1 72622346c6STom Stellard ;; 73622346c6STom Stellard esac 74622346c6STom Stellard shift 75622346c6STom Stellarddone 76622346c6STom Stellard 77622346c6STom Stellardif [ -n "$release" -a -n "$custom_srcdir" ]; then 78622346c6STom Stellard echo "error: Cannot specify both -srcdir and -release options" 79622346c6STom Stellard exit 1 80622346c6STom Stellardfi 81622346c6STom Stellard 82622346c6STom Stellardif [ -n "$custom_srcdir" ]; then 83622346c6STom Stellard srcdir="$custom_srcdir" 84622346c6STom Stellardfi 85622346c6STom Stellard 86622346c6STom Stellard# Set default source directory if one is not supplied 87622346c6STom Stellardif [ -n "$release" ]; then 88622346c6STom Stellard git_ref=llvmorg-$release 89622346c6STom Stellard if [ -d llvm-project ]; then 90622346c6STom Stellard echo "error llvm-project directory already exists" 91622346c6STom Stellard exit 1 92622346c6STom Stellard fi 93622346c6STom Stellard mkdir -p llvm-project 94622346c6STom Stellard pushd llvm-project 95622346c6STom Stellard curl -L https://github.com/llvm/llvm-project/archive/$git_ref.tar.gz | tar --strip-components=1 -xzf - 96622346c6STom Stellard popd 97622346c6STom Stellard srcdir="./llvm-project/llvm" 98622346c6STom Stellardfi 99622346c6STom Stellard 100fe7fe6d3STobias Hietaif [ "$no_doxygen" == "yes" ] && [ "$no_sphinx" == "yes" ]; then 101fe7fe6d3STobias Hieta echo "You can't specify both -no-doxygen and -no-sphinx, we have nothing to build then!" 102fe7fe6d3STobias Hieta exit 1 103fe7fe6d3STobias Hietafi 104fe7fe6d3STobias Hieta 105fe7fe6d3STobias Hietaif [ "$no_sphinx" != "yes" ]; then 106fe7fe6d3STobias Hieta echo "Sphinx: enabled" 107fe7fe6d3STobias Hieta sphinx_targets="docs-clang-html docs-clang-tools-html docs-flang-html docs-lld-html docs-llvm-html docs-polly-html" 108fe7fe6d3STobias Hieta sphinx_flag=" -DLLVM_ENABLE_SPHINX=ON -DSPHINX_WARNINGS_AS_ERRORS=OFF" 109fe7fe6d3STobias Hietaelse 110fe7fe6d3STobias Hieta echo "Sphinx: disabled" 111fe7fe6d3STobias Hietafi 112fe7fe6d3STobias Hieta 113fe7fe6d3STobias Hietaif [ "$no_doxygen" != "yes" ]; then 114fe7fe6d3STobias Hieta echo "Doxygen: enabled" 115fe7fe6d3STobias Hieta doxygen_targets="$docs_target doxygen-clang doxygen-clang-tools doxygen-flang doxygen-llvm doxygen-mlir doxygen-polly" 116fe7fe6d3STobias Hieta doxygen_flag=" -DLLVM_ENABLE_DOXYGEN=ON -DLLVM_DOXYGEN_SVG=ON" 117fe7fe6d3STobias Hietaelse 118fe7fe6d3STobias Hieta echo "Doxygen: disabled" 119fe7fe6d3STobias Hietafi 120fe7fe6d3STobias Hieta 121622346c6STom Stellardcmake -G Ninja $srcdir -B $builddir \ 122f34f7dfeSLouis Dionne -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;polly;flang" \ 123622346c6STom Stellard -DCMAKE_BUILD_TYPE=Release \ 124622346c6STom Stellard -DLLVM_BUILD_DOCS=ON \ 125fe7fe6d3STobias Hieta $sphinx_flag \ 126fe7fe6d3STobias Hieta $doxygen_flag 127622346c6STom Stellard 128fe7fe6d3STobias Hietaninja -C $builddir $sphinx_targets $doxygen_targets 129622346c6STom Stellard 130f34f7dfeSLouis Dionnecmake -G Ninja $srcdir/../runtimes -B $builddir/runtimes-doc \ 131b27f6de3STobias Hieta -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \ 132f34f7dfeSLouis Dionne -DLLVM_ENABLE_SPHINX=ON \ 133f34f7dfeSLouis Dionne -DSPHINX_WARNINGS_AS_ERRORS=OFF 134f34f7dfeSLouis Dionne 135f34f7dfeSLouis Dionneninja -C $builddir/runtimes-doc \ 136f34f7dfeSLouis Dionne docs-libcxx-html \ 137622346c6STom Stellard 138fe7fe6d3STobias Hietaif [ "$no_doxygen" != "yes" ]; then 139622346c6STom Stellard package_doxygen llvm . 140622346c6STom Stellard package_doxygen clang tools/clang 141622346c6STom Stellard package_doxygen clang-tools-extra tools/clang/tools/extra 142622346c6STom Stellard package_doxygen flang tools/flang 143fe7fe6d3STobias Hietafi 144fe7fe6d3STobias Hieta 145fe7fe6d3STobias Hietaif [ "$no_sphinx" == "yes" ]; then 146fe7fe6d3STobias Hieta exit 0 147fe7fe6d3STobias Hietafi 148622346c6STom Stellard 149622346c6STom Stellardhtml_dir=$builddir/html-export/ 150622346c6STom Stellard 151f34f7dfeSLouis Dionnefor d in docs/ tools/clang/docs/ tools/lld/docs/ tools/clang/tools/extra/docs/ tools/polly/docs/ tools/flang/docs/; do 152622346c6STom Stellard mkdir -p $html_dir/$d 153622346c6STom Stellard mv $builddir/$d/html/* $html_dir/$d/ 154622346c6STom Stellarddone 155f34f7dfeSLouis Dionne 156f34f7dfeSLouis Dionne# Keep the documentation for the runtimes under /projects/ to avoid breaking existing links. 157f34f7dfeSLouis Dionnefor d in libcxx/docs/; do 158f34f7dfeSLouis Dionne mkdir -p $html_dir/projects/$d 159f34f7dfeSLouis Dionne mv $builddir/runtimes-doc/$d/html/* $html_dir/projects/$d/ 160f34f7dfeSLouis Dionnedone 161