]> git.proxmox.com Git - ceph.git/blob - ceph/admin/build-doc
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / admin / build-doc
1 #!/bin/sh
2
3 cd "$(dirname "$0")"
4 cd ..
5 TOPDIR=`pwd`
6
7 install -d -m0755 build-doc
8
9 if 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
22 elif command -v yum >/dev/null; then
23 for package in python-devel python-pip python-virtualenv doxygen ditaa ant libxml2-devel libxslt-devel Cython graphviz; do
24 if ! rpm -q --whatprovides $package >/dev/null ; then
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
33 else
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
47 fi
48
49 # Don't enable -e until after running all the potentially-erroring checks
50 # for availability of commands
51 set -e
52
53 cat $TOPDIR/src/osd/PG.h $TOPDIR/src/osd/PG.cc | $TOPDIR/doc/scripts/gen_state_diagram.py > $TOPDIR/doc/dev/peering_graph.generated.dot
54
55 cd build-doc
56
57 [ -z "$vdir" ] && vdir="$TOPDIR/build-doc/virtualenv"
58
59 if [ ! -e $vdir ]; then
60 virtualenv --system-site-packages $vdir
61 fi
62 $vdir/bin/pip install --quiet -r $TOPDIR/admin/doc-requirements.txt
63
64 install -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.
71 mkdir -p $vdir/lib
72 export LD_LIBRARY_PATH="$vdir/lib"
73 export 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
79 for 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" \
88 LDFLAGS="-L$vdir/lib -Wl,--no-as-needed" \
89 $vdir/bin/pip install --upgrade $TOPDIR/src/pybind/${bind}
90 # rgwfile_version(), librgw_create(), rgw_mount()
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
96 nm $lib_fn | grep -E "U (lib)?${bind}" | \
97 awk '{ print "void "$2"(void) {}" }' | \
98 gcc -shared -o $vdir/lib/lib${bind}.so.1 -xc -
99 if [ ${bind} != rados ]; then
100 rm -f $TOPDIR/src/pybind/${bind}/rados.pxd
101 fi
102 done
103
104 if [ -z "$@" ]; then
105 sphinx_targets="html man"
106 else
107 sphinx_targets=$@
108 fi
109 for target in $sphinx_targets; do
110 builder=$target
111 case $target in
112 html)
113 builder=dirhtml
114 extra_opt="-D graphviz_output_format=svg"
115 ;;
116 man)
117 extra_opt="-t man"
118 ;;
119 esac
120 # Build with -W so that warnings are treated as errors and this fails
121 $vdir/bin/sphinx-build -W -a -b $builder $extra_opt -d doctrees \
122 $TOPDIR/doc $TOPDIR/build-doc/output/$target
123
124
125 done
126
127 # build the releases.json. this reads in the yaml version and dumps
128 # out the json representation of the same file. the resulting releases.json
129 # should be served from the root of hosted site.
130 $vdir/bin/python << EOF > $TOPDIR/build-doc/output/html/releases.json
131 from __future__ import print_function
132 import datetime
133 import json
134 import yaml
135
136 def json_serialize(obj):
137 if isinstance(obj, datetime.date):
138 return obj.isoformat()
139
140 with open("$TOPDIR/doc/releases/releases.yml", 'r') as fp:
141 releases = yaml.load(fp)
142 print(json.dumps(releases, indent=2, default=json_serialize))
143 EOF
144
145 #
146 # Build and install JavaDocs
147 #
148 JAVADIR=$TOPDIR/src/java
149
150 # Clean and build JavaDocs
151 rm -rf $JAVADIR/doc
152 ant -buildfile $JAVADIR/build.xml docs
153
154 # Create clean target directory
155 JAVA_OUTDIR=$TOPDIR/build-doc/output/html/api/libcephfs-java/javadoc
156 rm -rf $JAVA_OUTDIR
157 mkdir $JAVA_OUTDIR
158
159 # Copy JavaDocs to target directory
160 cp -a $JAVADIR/doc/* $JAVA_OUTDIR/