]> git.proxmox.com Git - ceph.git/blob - ceph/admin/build-doc
add subtree-ish sources for 12.0.3
[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 $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 -p python2
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 $TOPDIR/src/pybind/${bind}
90 # rgwfile_version(), librgw_create(), rgw_mount()
91 nm $vdir/lib/python*/*-packages/${bind}.so | grep -E "U (lib)?${bind}" | \
92 awk '{ print "void "$2"(void) {}" }' | \
93 gcc -shared -o $vdir/lib/lib${bind}.so.1 -xc -
94 if [ ${bind} != rados ]; then
95 rm -f $TOPDIR/src/pybind/${bind}/rados.pxd
96 fi
97 done
98
99 if [ -z "$@" ]; then
100 sphinx_targets="html man"
101 else
102 sphinx_targets=$@
103 fi
104 for target in $sphinx_targets; do
105 builder=$target
106 case $target in
107 html)
108 builder=dirhtml
109 ;;
110 man)
111 extra_opt="-t man"
112 ;;
113 esac
114 $vdir/bin/sphinx-build -a -b $builder $extra_opt -d doctrees \
115 $TOPDIR/doc $TOPDIR/build-doc/output/$target
116 done
117
118 #
119 # Build and install JavaDocs
120 #
121 JAVADIR=$TOPDIR/src/java
122
123 # Clean and build JavaDocs
124 rm -rf $JAVADIR/doc
125 ant -buildfile $JAVADIR/build.xml docs
126
127 # Create clean target directory
128 JAVA_OUTDIR=$TOPDIR/build-doc/output/html/api/libcephfs-java/javadoc
129 rm -rf $JAVA_OUTDIR
130 mkdir $JAVA_OUTDIR
131
132 # Copy JavaDocs to target directory
133 cp -a $JAVADIR/doc/* $JAVA_OUTDIR/