author | wenzelm |
Mon, 03 Sep 2012 11:30:29 +0200 | |
changeset 49073 | 88fe93ae61cf |
parent 49005 | 96d5e42e5e3a |
child 49131 | aa1e2ba3c697 |
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)" |
|
49005
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
20 |
echo " -p approximative build of 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 |
||
41 |
ALL_DOCS="false" |
|
42 |
JOBS="" |
|
49005
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
43 |
PDF_ONLY="" |
48972 | 44 |
|
49005
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
45 |
while getopts "aj:p" 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 |
;; |
|
49005
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
55 |
p) |
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
56 |
PDF_ONLY="true" |
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
57 |
;; |
48972 | 58 |
\?) |
59 |
usage |
|
60 |
;; |
|
61 |
esac |
|
62 |
done |
|
63 |
||
64 |
shift $(($OPTIND - 1)) |
|
65 |
||
66 |
if [ "$ALL_DOCS" = true ]; then |
|
67 |
declare -a BUILD_OPTIONS=(-g doc) |
|
68 |
else |
|
69 |
declare -a BUILD_OPTIONS=() |
|
49073 | 70 |
[ "$#" -eq 0 ] && usage |
48972 | 71 |
fi |
72 |
||
73 |
||
74 |
## main |
|
75 |
||
76 |
OUTPUT="$ISABELLE_TMP_PREFIX$$" |
|
77 |
mkdir -p "$OUTPUT" || fail "Bad directory: \"$OUTPUT\"" |
|
78 |
||
49005
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
79 |
if [ "$PDF_ONLY" = true ]; then |
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
80 |
FORMATS="pdf" |
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
81 |
else |
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
82 |
FORMATS="false dvi pdf" |
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
83 |
fi |
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
84 |
|
48972 | 85 |
RC=0 |
49005
96d5e42e5e3a
approximative build of pdf documents in 1 pass instead of 3;
wenzelm
parents:
49002
diff
changeset
|
86 |
for FORMAT in $FORMATS |
48972 | 87 |
do |
88 |
if [ "$RC" = 0 ]; then |
|
89 |
echo "Document format: $FORMAT" |
|
90 |
"$ISABELLE_TOOL" build -o browser_info=false -o "document=$FORMAT" \ |
|
91 |
-o "document_output=$OUTPUT" -c $JOBS "${BUILD_OPTIONS[@]}" -- "$@" |
|
92 |
RC=$? |
|
93 |
fi |
|
94 |
done |
|
95 |
||
96 |
if [ "$RC" = 0 ]; then |
|
97 |
for FILE in $(find "$OUTPUT" -name "*.eps" -o -name "*.ps") |
|
98 |
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
|
99 |
cp -f "$FILE" "$ISABELLE_HOME/doc" |
48972 | 100 |
done |
49073 | 101 |
if [ "$PDF_ONLY" = true ]; then |
102 |
cp -f "$OUTPUT"/*.pdf "$ISABELLE_HOME/doc" |
|
103 |
rm -f "$ISABELLE_HOME/doc/document.pdf" "$ISABELLE_HOME/doc/outline.pdf" |
|
104 |
else |
|
105 |
cp -f "$OUTPUT"/*.dvi "$OUTPUT"/*.pdf "$ISABELLE_HOME/doc" |
|
106 |
fi |
|
48972 | 107 |
fi |
108 |
||
109 |
rm -rf "$OUTPUT" |
|
110 |
||
111 |
exit $RC |