]> git.proxmox.com Git - ceph.git/blame - ceph/admin/build-doc
Import ceph 15.2.8
[ceph.git] / ceph / admin / build-doc
CommitLineData
9f95a23c 1#!/bin/sh -e
7c673cae
FG
2
3cd "$(dirname "$0")"
4cd ..
5TOPDIR=`pwd`
6
7install -d -m0755 build-doc
8
9if command -v dpkg >/dev/null; then
10 packages=`cat ${TOPDIR}/doc_deps.deb.txt`
11 for package in $packages; do
12 if [ "$(dpkg --status -- $package 2>&1 | sed -n 's/^Status: //p')" != "install ok installed" ]; then
13 # add a space after old values
14 missing="${missing:+$missing }$package"
15 fi
16 done
17 if [ -n "$missing" ]; then
18 echo "$0: missing required packages, please install them:" 1>&2
19 echo "sudo apt-get install -o APT::Install-Recommends=true $missing" 1>&2
20 exit 1
21 fi
22elif command -v yum >/dev/null; then
9f95a23c 23 for package in ant ditaa doxygen libxslt-devel libxml2-devel graphviz python3-devel python3-pip python3-virtualenv python3-Cython; do
11fdf7f2 24 if ! rpm -q --whatprovides $package >/dev/null ; then
7c673cae
FG
25 missing="${missing:+$missing }$package"
26 fi
27 done
28 if [ -n "$missing" ]; then
29 echo "$0: missing required packages, please install them:" 1>&2
30 echo "yum install $missing"
31 exit 1
32 fi
33else
34 for command in virtualenv doxygen ant ditaa cython; do
35 command -v "$command" > /dev/null;
36 ret_code=$?
37 if [ $ret_code -ne 0 ]; then
38 # add a space after old values
39 missing="${missing:+$missing }$command"
40 fi
41 done
42 if [ -n "$missing" ]; then
43 echo "$0: missing required command, please install them:" 1>&2
44 echo "$missing"
45 exit 1
46 fi
47fi
48
49# Don't enable -e until after running all the potentially-erroring checks
50# for availability of commands
51set -e
52
9f95a23c 53cat $TOPDIR/src/osd/PeeringState.h $TOPDIR/src/osd/PeeringState.cc | $TOPDIR/doc/scripts/gen_state_diagram.py > $TOPDIR/doc/dev/peering_graph.generated.dot
7c673cae
FG
54
55cd build-doc
56
57[ -z "$vdir" ] && vdir="$TOPDIR/build-doc/virtualenv"
58
59if [ ! -e $vdir ]; then
9f95a23c 60 virtualenv --python=python3 $vdir
7c673cae
FG
61fi
62$vdir/bin/pip install --quiet -r $TOPDIR/admin/doc-requirements.txt
63
64install -d -m0755 \
65 $TOPDIR/build-doc/output/html \
66 $TOPDIR/build-doc/output/man
67
68# To avoid having to build librbd to build the Python bindings to build the docs,
69# create a dummy librbd.so that allows the module to be imported by sphinx.
70# the module are imported by the "automodule::" directive.
71mkdir -p $vdir/lib
72export LD_LIBRARY_PATH="$vdir/lib"
73export PYTHONPATH=$TOPDIR/src/pybind
74
75# FIXME(sileht): I dunno how to pass the include-dirs correctly with pip
76# for build_ext step, it should be:
77# --global-option=build_ext --global-option="--cython-include-dirs $TOPDIR/src/pybind/rados/"
78# but that doesn't work, so copying the file in the rbd module directly, that's ok for docs
79for bind in rados rbd cephfs rgw; do
80 if [ ${bind} != rados ]; then
81 cp -f $TOPDIR/src/pybind/rados/rados.pxd $TOPDIR/src/pybind/${bind}/
82 fi
83 ln -sf lib${bind}.so.1 $vdir/lib/lib${bind}.so
84 gcc -shared -o $vdir/lib/lib${bind}.so.1 -xc /dev/null
85 BUILD_DOC=1 \
86 CFLAGS="-iquote$TOPDIR/src/include" \
87 CPPFLAGS="-iquote$TOPDIR/src/include" \
f91f0fd5 88 LDFLAGS="-L$vdir/lib -Wl,--no-as-needed,-rpath=$vdir/lib" \
11fdf7f2 89 $vdir/bin/pip install --upgrade $TOPDIR/src/pybind/${bind}
7c673cae 90 # rgwfile_version(), librgw_create(), rgw_mount()
11fdf7f2
TL
91 # since py3.5, distutils adds postfix in between ${bind} and so
92 lib_fn=$vdir/lib/python*/*-packages/${bind}.*.so
93 if [ ! -e $lib_fn ]; then
94 lib_fn=$vdir/lib/python*/*-packages/${bind}.so
95 fi
f91f0fd5
TL
96 if [ ${bind} = "cephfs" ]; then
97 func_prefix="ceph"
98 else
99 func_prefix="(lib)?${bind}"
100 fi
101 nm $lib_fn | grep -E "U ${func_prefix}" | \
7c673cae
FG
102 awk '{ print "void "$2"(void) {}" }' | \
103 gcc -shared -o $vdir/lib/lib${bind}.so.1 -xc -
104 if [ ${bind} != rados ]; then
105 rm -f $TOPDIR/src/pybind/${bind}/rados.pxd
106 fi
107done
108
109if [ -z "$@" ]; then
110 sphinx_targets="html man"
111else
112 sphinx_targets=$@
113fi
114for target in $sphinx_targets; do
115 builder=$target
116 case $target in
117 html)
118 builder=dirhtml
11fdf7f2 119 extra_opt="-D graphviz_output_format=svg"
7c673cae
FG
120 ;;
121 man)
122 extra_opt="-t man"
123 ;;
124 esac
11fdf7f2 125 # Build with -W so that warnings are treated as errors and this fails
9f95a23c 126 $vdir/bin/sphinx-build -W --keep-going -a -b $builder $extra_opt -d doctrees \
7c673cae 127 $TOPDIR/doc $TOPDIR/build-doc/output/$target
11fdf7f2
TL
128
129
7c673cae
FG
130done
131
11fdf7f2
TL
132# build the releases.json. this reads in the yaml version and dumps
133# out the json representation of the same file. the resulting releases.json
134# should be served from the root of hosted site.
135$vdir/bin/python << EOF > $TOPDIR/build-doc/output/html/releases.json
136from __future__ import print_function
137import datetime
138import json
139import yaml
140
141def json_serialize(obj):
142 if isinstance(obj, datetime.date):
143 return obj.isoformat()
144
145with open("$TOPDIR/doc/releases/releases.yml", 'r') as fp:
9f95a23c 146 releases = yaml.safe_load(fp)
11fdf7f2
TL
147 print(json.dumps(releases, indent=2, default=json_serialize))
148EOF
149
7c673cae
FG
150#
151# Build and install JavaDocs
152#
153JAVADIR=$TOPDIR/src/java
154
155# Clean and build JavaDocs
156rm -rf $JAVADIR/doc
157ant -buildfile $JAVADIR/build.xml docs
158
159# Create clean target directory
160JAVA_OUTDIR=$TOPDIR/build-doc/output/html/api/libcephfs-java/javadoc
161rm -rf $JAVA_OUTDIR
162mkdir $JAVA_OUTDIR
163
164# Copy JavaDocs to target directory
165cp -a $JAVADIR/doc/* $JAVA_OUTDIR/
9f95a23c
TL
166
167echo "SUCCESS"