author | blanchet |
Tue, 07 May 2013 17:07:37 +0200 | |
changeset 51906 | 38dcb3a6dfcc |
parent 49131 | aa1e2ba3c697 |
child 52740 | bceec99254b0 |
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)" |
|
49131 | 20 |
echo " -p build only pdf documents" |
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 |
||
49131 | 41 |
# options |
42 |
||
48972 | 43 |
ALL_DOCS="false" |
44 |
JOBS="" |
|
49005
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
45 |
PDF_ONLY="" |
48972 | 46 |
|
49005
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
47 |
while getopts "aj:p" OPT |
48972 | 48 |
do |
49 |
case "$OPT" in |
|
50 |
a) |
|
51 |
ALL_DOCS="true" |
|
52 |
;; |
|
53 |
j) |
|
54 |
check_number "$OPTARG" |
|
55 |
JOBS="-j $OPTARG" |
|
56 |
;; |
|
49005
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
57 |
p) |
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
58 |
PDF_ONLY="true" |
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
59 |
;; |
48972 | 60 |
\?) |
61 |
usage |
|
62 |
;; |
|
63 |
esac |
|
64 |
done |
|
65 |
||
66 |
shift $(($OPTIND - 1)) |
|
67 |
||
49131 | 68 |
|
69 |
# arguments |
|
70 |
||
48972 | 71 |
if [ "$ALL_DOCS" = true ]; then |
49131 | 72 |
declare -a BUILD_ARGS=(-g doc) |
48972 | 73 |
else |
49131 | 74 |
declare -a BUILD_ARGS=() |
49073 | 75 |
[ "$#" -eq 0 ] && usage |
48972 | 76 |
fi |
77 |
||
49131 | 78 |
BUILD_ARGS["${#BUILD_ARGS[@]}"]="--" |
79 |
||
80 |
while [ "$#" -ne 0 ]; do |
|
81 |
BUILD_ARGS["${#BUILD_ARGS[@]}"]="$1" |
|
82 |
shift |
|
83 |
done |
|
84 |
||
48972 | 85 |
|
86 |
## main |
|
87 |
||
88 |
OUTPUT="$ISABELLE_TMP_PREFIX$$" |
|
89 |
mkdir -p "$OUTPUT" || fail "Bad directory: \"$OUTPUT\"" |
|
90 |
||
49131 | 91 |
"$ISABELLE_TOOL" build -R -b $JOBS "${BUILD_ARGS[@]}" |
92 |
RC=$? |
|
93 |
||
49005
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
94 |
if [ "$PDF_ONLY" = true ]; then |
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
95 |
FORMATS="pdf" |
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
96 |
else |
49131 | 97 |
FORMATS="dvi pdf" |
49005
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
98 |
fi |
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
99 |
|
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
100 |
for FORMAT in $FORMATS |
48972 | 101 |
do |
102 |
if [ "$RC" = 0 ]; then |
|
103 |
echo "Document format: $FORMAT" |
|
104 |
"$ISABELLE_TOOL" build -o browser_info=false -o "document=$FORMAT" \ |
|
49131 | 105 |
-o "document_output=$OUTPUT" -c $JOBS "${BUILD_ARGS[@]}" |
48972 | 106 |
RC=$? |
107 |
fi |
|
108 |
done |
|
109 |
||
110 |
if [ "$RC" = 0 ]; then |
|
111 |
for FILE in $(find "$OUTPUT" -name "*.eps" -o -name "*.ps") |
|
112 |
do |
|
48988
f4d4d6d6702b
prefer cp over mv, to reduce assumptions about file-system boundaries and GNU vs. non-GNU tools;
wenzelm
parents:
48972
diff
changeset
|
113 |
cp -f "$FILE" "$ISABELLE_HOME/doc" |
48972 | 114 |
done |
49073 | 115 |
if [ "$PDF_ONLY" = true ]; then |
116 |
cp -f "$OUTPUT"/*.pdf "$ISABELLE_HOME/doc" |
|
117 |
else |
|
118 |
cp -f "$OUTPUT"/*.dvi "$OUTPUT"/*.pdf "$ISABELLE_HOME/doc" |
|
119 |
fi |
|
48972 | 120 |
fi |
121 |
||
122 |
rm -rf "$OUTPUT" |
|
123 |
||
124 |
exit $RC |