author | wenzelm |
Fri, 14 Feb 2014 20:58:48 +0100 | |
changeset 55496 | 5d2835453ad3 |
parent 53208 | bec95e287d26 |
child 56429 | bc61161a5bd0 |
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)" |
|
53208
bec95e287d26
prefer build_doc -s to avoid heaps left behind in $ISABELLE_HOME_USER (especially relevant to isatest);
wenzelm
parents:
52740
diff
changeset
|
20 |
echo " -s system build mode" |
48972 | 21 |
echo |
22 |
echo " Build Isabelle documentation from (doc) sessions." |
|
23 |
echo |
|
24 |
exit 1 |
|
25 |
} |
|
26 |
||
27 |
function fail() |
|
28 |
{ |
|
29 |
echo "$1" >&2 |
|
30 |
exit 2 |
|
31 |
} |
|
32 |
||
33 |
function check_number() |
|
34 |
{ |
|
35 |
[ -n "$1" -a -z "$(echo "$1" | tr -d '[0-9]')" ] || fail "Bad number: \"$1\"" |
|
36 |
} |
|
37 |
||
38 |
||
39 |
## process command line |
|
40 |
||
53208
bec95e287d26
prefer build_doc -s to avoid heaps left behind in $ISABELLE_HOME_USER (especially relevant to isatest);
wenzelm
parents:
52740
diff
changeset
|
41 |
declare -a BUILD_ARGS=() |
bec95e287d26
prefer build_doc -s to avoid heaps left behind in $ISABELLE_HOME_USER (especially relevant to isatest);
wenzelm
parents:
52740
diff
changeset
|
42 |
|
bec95e287d26
prefer build_doc -s to avoid heaps left behind in $ISABELLE_HOME_USER (especially relevant to isatest);
wenzelm
parents:
52740
diff
changeset
|
43 |
|
49131 | 44 |
# options |
45 |
||
48972 | 46 |
ALL_DOCS="false" |
47 |
||
53208
bec95e287d26
prefer build_doc -s to avoid heaps left behind in $ISABELLE_HOME_USER (especially relevant to isatest);
wenzelm
parents:
52740
diff
changeset
|
48 |
while getopts "aj:s" OPT |
48972 | 49 |
do |
50 |
case "$OPT" in |
|
51 |
a) |
|
52 |
ALL_DOCS="true" |
|
53 |
;; |
|
54 |
j) |
|
55 |
check_number "$OPTARG" |
|
53208
bec95e287d26
prefer build_doc -s to avoid heaps left behind in $ISABELLE_HOME_USER (especially relevant to isatest);
wenzelm
parents:
52740
diff
changeset
|
56 |
BUILD_ARGS["${#BUILD_ARGS[@]}"]="-j" |
bec95e287d26
prefer build_doc -s to avoid heaps left behind in $ISABELLE_HOME_USER (especially relevant to isatest);
wenzelm
parents:
52740
diff
changeset
|
57 |
BUILD_ARGS["${#BUILD_ARGS[@]}"]="$OPTARG" |
bec95e287d26
prefer build_doc -s to avoid heaps left behind in $ISABELLE_HOME_USER (especially relevant to isatest);
wenzelm
parents:
52740
diff
changeset
|
58 |
;; |
bec95e287d26
prefer build_doc -s to avoid heaps left behind in $ISABELLE_HOME_USER (especially relevant to isatest);
wenzelm
parents:
52740
diff
changeset
|
59 |
s) |
bec95e287d26
prefer build_doc -s to avoid heaps left behind in $ISABELLE_HOME_USER (especially relevant to isatest);
wenzelm
parents:
52740
diff
changeset
|
60 |
BUILD_ARGS["${#BUILD_ARGS[@]}"]="-s" |
48972 | 61 |
;; |
62 |
\?) |
|
63 |
usage |
|
64 |
;; |
|
65 |
esac |
|
66 |
done |
|
67 |
||
68 |
shift $(($OPTIND - 1)) |
|
69 |
||
49131 | 70 |
|
71 |
# arguments |
|
72 |
||
48972 | 73 |
if [ "$ALL_DOCS" = true ]; then |
53208
bec95e287d26
prefer build_doc -s to avoid heaps left behind in $ISABELLE_HOME_USER (especially relevant to isatest);
wenzelm
parents:
52740
diff
changeset
|
74 |
BUILD_ARGS["${#BUILD_ARGS[@]}"]="-g" |
bec95e287d26
prefer build_doc -s to avoid heaps left behind in $ISABELLE_HOME_USER (especially relevant to isatest);
wenzelm
parents:
52740
diff
changeset
|
75 |
BUILD_ARGS["${#BUILD_ARGS[@]}"]="doc" |
48972 | 76 |
else |
49073 | 77 |
[ "$#" -eq 0 ] && usage |
48972 | 78 |
fi |
79 |
||
49131 | 80 |
BUILD_ARGS["${#BUILD_ARGS[@]}"]="--" |
81 |
||
82 |
while [ "$#" -ne 0 ]; do |
|
83 |
BUILD_ARGS["${#BUILD_ARGS[@]}"]="$1" |
|
84 |
shift |
|
85 |
done |
|
86 |
||
48972 | 87 |
|
88 |
## main |
|
89 |
||
90 |
OUTPUT="$ISABELLE_TMP_PREFIX$$" |
|
91 |
mkdir -p "$OUTPUT" || fail "Bad directory: \"$OUTPUT\"" |
|
92 |
||
53208
bec95e287d26
prefer build_doc -s to avoid heaps left behind in $ISABELLE_HOME_USER (especially relevant to isatest);
wenzelm
parents:
52740
diff
changeset
|
93 |
"$ISABELLE_TOOL" build -R -b "${BUILD_ARGS[@]}" |
49131 | 94 |
RC=$? |
95 |
||
52740 | 96 |
if [ "$RC" = 0 ]; then |
97 |
"$ISABELLE_TOOL" build -o browser_info=false -o "document=pdf" \ |
|
53208
bec95e287d26
prefer build_doc -s to avoid heaps left behind in $ISABELLE_HOME_USER (especially relevant to isatest);
wenzelm
parents:
52740
diff
changeset
|
98 |
-o "document_output=$OUTPUT" -c "${BUILD_ARGS[@]}" |
52740 | 99 |
RC=$? |
49005
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
100 |
fi |
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
101 |
|
48972 | 102 |
if [ "$RC" = 0 ]; then |
52740 | 103 |
cp -f "$OUTPUT"/*.pdf "$ISABELLE_HOME/doc" |
48972 | 104 |
fi |
105 |
||
106 |
rm -rf "$OUTPUT" |
|
107 |
||
108 |
exit $RC |