author | wenzelm |
Fri, 16 Aug 2013 21:33:36 +0200 | |
changeset 53043 | 8cbfbeb566a4 |
parent 52740 | bceec99254b0 |
child 53208 | bec95e287d26 |
permissions | -rwxr-xr-x |
48972 | 1 |
#!/usr/bin/env bash |
2 |
# |
|
3 |
# Author: Makarius |
|
4 |
# |
|
5 |
# DESCRIPTION: build Isabelle documentation |
|
6 |
||
7 |
||
8 |
## diagnostics |
|
9 |
||
10 |
PRG="$(basename "$0")" |
|
11 |
||
12 |
function usage() |
|
13 |
{ |
|
14 |
echo |
|
15 |
echo "Usage: isabelle $PRG [OPTIONS] [SESSIONS ...]" |
|
16 |
echo |
|
17 |
echo " Options are:" |
|
18 |
echo " -a select all doc sessions" |
|
19 |
echo " -j INT maximum number of parallel jobs (default 1)" |
|
20 |
echo |
|
21 |
echo " Build Isabelle documentation from (doc) sessions." |
|
22 |
echo |
|
23 |
exit 1 |
|
24 |
} |
|
25 |
||
26 |
function fail() |
|
27 |
{ |
|
28 |
echo "$1" >&2 |
|
29 |
exit 2 |
|
30 |
} |
|
31 |
||
32 |
function check_number() |
|
33 |
{ |
|
34 |
[ -n "$1" -a -z "$(echo "$1" | tr -d '[0-9]')" ] || fail "Bad number: \"$1\"" |
|
35 |
} |
|
36 |
||
37 |
||
38 |
## process command line |
|
39 |
||
49131 | 40 |
# options |
41 |
||
48972 | 42 |
ALL_DOCS="false" |
43 |
JOBS="" |
|
44 |
||
52740 | 45 |
while getopts "aj:" OPT |
48972 | 46 |
do |
47 |
case "$OPT" in |
|
48 |
a) |
|
49 |
ALL_DOCS="true" |
|
50 |
;; |
|
51 |
j) |
|
52 |
check_number "$OPTARG" |
|
53 |
JOBS="-j $OPTARG" |
|
54 |
;; |
|
55 |
\?) |
|
56 |
usage |
|
57 |
;; |
|
58 |
esac |
|
59 |
done |
|
60 |
||
61 |
shift $(($OPTIND - 1)) |
|
62 |
||
49131 | 63 |
|
64 |
# arguments |
|
65 |
||
48972 | 66 |
if [ "$ALL_DOCS" = true ]; then |
49131 | 67 |
declare -a BUILD_ARGS=(-g doc) |
48972 | 68 |
else |
49131 | 69 |
declare -a BUILD_ARGS=() |
49073 | 70 |
[ "$#" -eq 0 ] && usage |
48972 | 71 |
fi |
72 |
||
49131 | 73 |
BUILD_ARGS["${#BUILD_ARGS[@]}"]="--" |
74 |
||
75 |
while [ "$#" -ne 0 ]; do |
|
76 |
BUILD_ARGS["${#BUILD_ARGS[@]}"]="$1" |
|
77 |
shift |
|
78 |
done |
|
79 |
||
48972 | 80 |
|
81 |
## main |
|
82 |
||
83 |
OUTPUT="$ISABELLE_TMP_PREFIX$$" |
|
84 |
mkdir -p "$OUTPUT" || fail "Bad directory: \"$OUTPUT\"" |
|
85 |
||
49131 | 86 |
"$ISABELLE_TOOL" build -R -b $JOBS "${BUILD_ARGS[@]}" |
87 |
RC=$? |
|
88 |
||
52740 | 89 |
if [ "$RC" = 0 ]; then |
90 |
"$ISABELLE_TOOL" build -o browser_info=false -o "document=pdf" \ |
|
91 |
-o "document_output=$OUTPUT" -c $JOBS "${BUILD_ARGS[@]}" |
|
92 |
RC=$? |
|
49005
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
93 |
fi |
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
94 |
|
48972 | 95 |
if [ "$RC" = 0 ]; then |
52740 | 96 |
cp -f "$OUTPUT"/*.pdf "$ISABELLE_HOME/doc" |
48972 | 97 |
fi |
98 |
||
99 |
rm -rf "$OUTPUT" |
|
100 |
||
101 |
exit $RC |