2019-12-16 23:21:30 +00:00
|
|
|
#!/bin/sh -e
|
2015-02-11 12:56:34 +00:00
|
|
|
|
2011-08-19 23:43:21 +00:00
|
|
|
cd "$(dirname "$0")"
|
|
|
|
cd ..
|
2012-10-26 16:35:14 +00:00
|
|
|
TOPDIR=`pwd`
|
2011-08-19 23:43:21 +00:00
|
|
|
|
2011-08-29 22:43:41 +00:00
|
|
|
install -d -m0755 build-doc
|
|
|
|
|
2011-12-06 20:04:03 +00:00
|
|
|
if command -v dpkg >/dev/null; then
|
2016-05-24 06:08:05 +00:00
|
|
|
packages=`cat ${TOPDIR}/doc_deps.deb.txt`
|
2016-05-16 15:35:18 +00:00
|
|
|
for package in $packages; do
|
|
|
|
if [ "$(dpkg --status -- $package 2>&1 | sed -n 's/^Status: //p')" != "install ok installed" ]; then
|
|
|
|
# add a space after old values
|
|
|
|
missing="${missing:+$missing }$package"
|
|
|
|
fi
|
2011-12-06 20:04:03 +00:00
|
|
|
done
|
|
|
|
if [ -n "$missing" ]; then
|
2016-05-16 15:35:18 +00:00
|
|
|
echo "$0: missing required packages, please install them:" 1>&2
|
|
|
|
echo "sudo apt-get install -o APT::Install-Recommends=true $missing" 1>&2
|
|
|
|
exit 1
|
2011-12-06 20:04:03 +00:00
|
|
|
fi
|
2015-02-11 13:18:53 +00:00
|
|
|
elif command -v yum >/dev/null; then
|
2020-01-09 11:44:47 +00:00
|
|
|
for package in ant ditaa doxygen libxslt-devel libxml2-devel graphviz python3-devel python3-pip python3-virtualenv python3-Cython; do
|
2018-01-04 14:55:16 +00:00
|
|
|
if ! rpm -q --whatprovides $package >/dev/null ; then
|
2015-02-11 13:18:53 +00:00
|
|
|
missing="${missing:+$missing }$package"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ -n "$missing" ]; then
|
|
|
|
echo "$0: missing required packages, please install them:" 1>&2
|
|
|
|
echo "yum install $missing"
|
|
|
|
exit 1
|
|
|
|
fi
|
2011-12-06 20:04:03 +00:00
|
|
|
else
|
2015-12-01 14:20:01 +00:00
|
|
|
for command in virtualenv doxygen ant ditaa cython; do
|
2014-03-12 17:09:59 +00:00
|
|
|
command -v "$command" > /dev/null;
|
|
|
|
ret_code=$?
|
|
|
|
if [ $ret_code -ne 0 ]; then
|
2011-12-06 20:04:03 +00:00
|
|
|
# add a space after old values
|
2014-03-12 17:09:59 +00:00
|
|
|
missing="${missing:+$missing }$command"
|
2011-12-06 20:04:03 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ -n "$missing" ]; then
|
|
|
|
echo "$0: missing required command, please install them:" 1>&2
|
|
|
|
echo "$missing"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-06-03 09:09:09 +00:00
|
|
|
# Don't enable -e until after running all the potentially-erroring checks
|
|
|
|
# for availability of commands
|
|
|
|
set -e
|
|
|
|
|
2019-04-12 00:59:10 +00:00
|
|
|
cat $TOPDIR/src/osd/PeeringState.h $TOPDIR/src/osd/PeeringState.cc | $TOPDIR/doc/scripts/gen_state_diagram.py > $TOPDIR/doc/dev/peering_graph.generated.dot
|
2011-11-30 00:24:35 +00:00
|
|
|
|
2011-08-19 23:43:21 +00:00
|
|
|
cd build-doc
|
|
|
|
|
2016-01-05 23:49:18 +00:00
|
|
|
[ -z "$vdir" ] && vdir="$TOPDIR/build-doc/virtualenv"
|
2012-03-12 23:46:31 +00:00
|
|
|
|
|
|
|
if [ ! -e $vdir ]; then
|
2019-12-16 23:21:30 +00:00
|
|
|
virtualenv --python=python3 $vdir
|
2011-08-19 23:43:21 +00:00
|
|
|
fi
|
2016-01-05 23:49:18 +00:00
|
|
|
$vdir/bin/pip install --quiet -r $TOPDIR/admin/doc-requirements.txt
|
2011-08-19 23:43:21 +00:00
|
|
|
|
|
|
|
install -d -m0755 \
|
2016-01-05 23:49:18 +00:00
|
|
|
$TOPDIR/build-doc/output/html \
|
|
|
|
$TOPDIR/build-doc/output/man
|
2015-12-01 14:30:01 +00:00
|
|
|
|
|
|
|
# To avoid having to build librbd to build the Python bindings to build the docs,
|
|
|
|
# create a dummy librbd.so that allows the module to be imported by sphinx.
|
2016-08-09 07:17:18 +00:00
|
|
|
# the module are imported by the "automodule::" directive.
|
2015-12-01 14:30:01 +00:00
|
|
|
mkdir -p $vdir/lib
|
|
|
|
export LD_LIBRARY_PATH="$vdir/lib"
|
2016-01-05 23:49:18 +00:00
|
|
|
export PYTHONPATH=$TOPDIR/src/pybind
|
2016-02-17 09:13:31 +00:00
|
|
|
|
|
|
|
# FIXME(sileht): I dunno how to pass the include-dirs correctly with pip
|
|
|
|
# for build_ext step, it should be:
|
|
|
|
# --global-option=build_ext --global-option="--cython-include-dirs $TOPDIR/src/pybind/rados/"
|
|
|
|
# but that doesn't work, so copying the file in the rbd module directly, that's ok for docs
|
2016-11-08 09:12:26 +00:00
|
|
|
for bind in rados rbd cephfs rgw; do
|
|
|
|
if [ ${bind} != rados ]; then
|
|
|
|
cp -f $TOPDIR/src/pybind/rados/rados.pxd $TOPDIR/src/pybind/${bind}/
|
|
|
|
fi
|
|
|
|
ln -sf lib${bind}.so.1 $vdir/lib/lib${bind}.so
|
|
|
|
gcc -shared -o $vdir/lib/lib${bind}.so.1 -xc /dev/null
|
|
|
|
BUILD_DOC=1 \
|
|
|
|
CFLAGS="-iquote$TOPDIR/src/include" \
|
|
|
|
CPPFLAGS="-iquote$TOPDIR/src/include" \
|
|
|
|
LDFLAGS="-L$vdir/lib -Wl,--no-as-needed" \
|
2018-03-05 21:46:37 +00:00
|
|
|
$vdir/bin/pip install --upgrade $TOPDIR/src/pybind/${bind}
|
2016-11-08 09:12:26 +00:00
|
|
|
# rgwfile_version(), librgw_create(), rgw_mount()
|
2017-09-11 13:53:57 +00:00
|
|
|
# since py3.5, distutils adds postfix in between ${bind} and so
|
|
|
|
lib_fn=$vdir/lib/python*/*-packages/${bind}.*.so
|
|
|
|
if [ ! -e $lib_fn ]; then
|
|
|
|
lib_fn=$vdir/lib/python*/*-packages/${bind}.so
|
|
|
|
fi
|
|
|
|
nm $lib_fn | grep -E "U (lib)?${bind}" | \
|
2016-11-08 09:12:26 +00:00
|
|
|
awk '{ print "void "$2"(void) {}" }' | \
|
|
|
|
gcc -shared -o $vdir/lib/lib${bind}.so.1 -xc -
|
|
|
|
if [ ${bind} != rados ]; then
|
|
|
|
rm -f $TOPDIR/src/pybind/${bind}/rados.pxd
|
|
|
|
fi
|
|
|
|
done
|
2016-02-17 09:13:31 +00:00
|
|
|
|
2017-03-21 04:22:57 +00:00
|
|
|
if [ -z "$@" ]; then
|
|
|
|
sphinx_targets="html man"
|
|
|
|
else
|
|
|
|
sphinx_targets=$@
|
|
|
|
fi
|
|
|
|
for target in $sphinx_targets; do
|
|
|
|
builder=$target
|
|
|
|
case $target in
|
|
|
|
html)
|
|
|
|
builder=dirhtml
|
2018-02-08 10:50:31 +00:00
|
|
|
extra_opt="-D graphviz_output_format=svg"
|
2017-03-21 04:22:57 +00:00
|
|
|
;;
|
|
|
|
man)
|
|
|
|
extra_opt="-t man"
|
|
|
|
;;
|
|
|
|
esac
|
2017-08-15 11:48:51 +00:00
|
|
|
# Build with -W so that warnings are treated as errors and this fails
|
2019-03-19 12:49:53 +00:00
|
|
|
$vdir/bin/sphinx-build -W --keep-going -a -b $builder $extra_opt -d doctrees \
|
2017-03-21 04:22:57 +00:00
|
|
|
$TOPDIR/doc $TOPDIR/build-doc/output/$target
|
2017-08-15 11:48:51 +00:00
|
|
|
|
|
|
|
|
2017-03-21 04:22:57 +00:00
|
|
|
done
|
2012-10-26 16:35:14 +00:00
|
|
|
|
2018-10-01 23:54:19 +00:00
|
|
|
# build the releases.json. this reads in the yaml version and dumps
|
|
|
|
# out the json representation of the same file. the resulting releases.json
|
|
|
|
# should be served from the root of hosted site.
|
|
|
|
$vdir/bin/python << EOF > $TOPDIR/build-doc/output/html/releases.json
|
|
|
|
from __future__ import print_function
|
|
|
|
import datetime
|
|
|
|
import json
|
|
|
|
import yaml
|
|
|
|
|
|
|
|
def json_serialize(obj):
|
|
|
|
if isinstance(obj, datetime.date):
|
|
|
|
return obj.isoformat()
|
|
|
|
|
|
|
|
with open("$TOPDIR/doc/releases/releases.yml", 'r') as fp:
|
2019-06-09 14:10:51 +00:00
|
|
|
releases = yaml.safe_load(fp)
|
2018-10-01 23:54:19 +00:00
|
|
|
print(json.dumps(releases, indent=2, default=json_serialize))
|
|
|
|
EOF
|
|
|
|
|
2012-10-26 16:35:14 +00:00
|
|
|
#
|
|
|
|
# Build and install JavaDocs
|
|
|
|
#
|
|
|
|
JAVADIR=$TOPDIR/src/java
|
|
|
|
|
|
|
|
# Clean and build JavaDocs
|
|
|
|
rm -rf $JAVADIR/doc
|
|
|
|
ant -buildfile $JAVADIR/build.xml docs
|
|
|
|
|
|
|
|
# Create clean target directory
|
2016-01-05 23:49:18 +00:00
|
|
|
JAVA_OUTDIR=$TOPDIR/build-doc/output/html/api/libcephfs-java/javadoc
|
2012-10-26 16:35:14 +00:00
|
|
|
rm -rf $JAVA_OUTDIR
|
|
|
|
mkdir $JAVA_OUTDIR
|
|
|
|
|
|
|
|
# Copy JavaDocs to target directory
|
|
|
|
cp -a $JAVADIR/doc/* $JAVA_OUTDIR/
|
2019-12-16 23:21:30 +00:00
|
|
|
|
|
|
|
echo "SUCCESS"
|