author | wenzelm |
Sat, 09 Jan 2010 18:22:40 +0100 | |
changeset 34297 | 5c0a2583f997 |
parent 34283 | 7911e83d06c0 |
child 35587 | f037aa6699c3 |
permissions | -rwxr-xr-x |
10555 | 1 |
#!/usr/bin/env bash |
3640 | 2 |
# |
9788 | 3 |
# Author: Markus Wenzel, TU Muenchen |
3640 | 4 |
# |
7766 | 5 |
# DESCRIPTION: Isabelle graph browser |
3640 | 6 |
|
7 |
||
10511 | 8 |
PRG="$(basename "$0")" |
3640 | 9 |
|
10 |
function usage() |
|
11 |
{ |
|
12 |
echo |
|
28650 | 13 |
echo "Usage: isabelle $PRG [OPTIONS] [GRAPHFILE]" |
3640 | 14 |
echo |
7766 | 15 |
echo " Options are:" |
20569 | 16 |
echo " -c cleanup -- remove GRAPHFILE after use" |
11801 | 17 |
echo " -o FILE output to FILE (ps, eps, pdf)" |
7766 | 18 |
echo |
3640 | 19 |
exit 1 |
20 |
} |
|
21 |
||
11801 | 22 |
function fail() |
23 |
{ |
|
24 |
echo "$1" >&2 |
|
25 |
exit 2 |
|
26 |
} |
|
27 |
||
28 |
||
7766 | 29 |
## process command line |
30 |
||
31 |
# options |
|
32 |
||
20569 | 33 |
CLEAN="" |
11801 | 34 |
OUTFILE="" |
7766 | 35 |
|
20569 | 36 |
while getopts "co:" OPT |
7766 | 37 |
do |
38 |
case "$OPT" in |
|
20569 | 39 |
c) |
40 |
CLEAN=true |
|
7766 | 41 |
;; |
11801 | 42 |
o) |
43 |
OUTFILE="$OPTARG" |
|
44 |
;; |
|
7766 | 45 |
\?) |
46 |
usage |
|
47 |
;; |
|
48 |
esac |
|
49 |
done |
|
50 |
||
51 |
shift $(($OPTIND - 1)) |
|
52 |
||
53 |
||
54 |
# args |
|
55 |
||
56 |
GRAPHFILE="" |
|
9788 | 57 |
[ "$#" -gt 0 ] && { GRAPHFILE="$1"; shift; } |
58 |
[ "$#" -ne 0 ] && usage |
|
7766 | 59 |
|
3640 | 60 |
|
61 |
## main |
|
62 |
||
34297 | 63 |
[ -e "$ISABELLE_HOME/Admin/build" ] && { "$ISABELLE_HOME/Admin/build" browser || exit $?; } |
34283
7911e83d06c0
simplified build/bootstrap of graph browser -- avoid make;
wenzelm
parents:
29143
diff
changeset
|
64 |
|
27907 | 65 |
classpath "$ISABELLE_HOME/lib/browser/GraphBrowser.jar" |
25650 | 66 |
|
9794 | 67 |
if [ -z "$GRAPHFILE" ]; then |
26230 | 68 |
[ -d "$ISABELLE_BROWSER_INFO" ] && cd "$ISABELLE_BROWSER_INFO" |
28500 | 69 |
exec "$ISABELLE_TOOL" java GraphBrowser.GraphBrowser |
9794 | 70 |
else |
20569 | 71 |
PRIVATE_FILE="${ISABELLE_TMP:-/tmp}/$$"$(basename "$GRAPHFILE") |
72 |
if [ -n "$CLEAN" ]; then |
|
73 |
mv -f "$GRAPHFILE" "$PRIVATE_FILE" || fail "Cannot move file: $FILE" |
|
74 |
else |
|
75 |
cp -f "$GRAPHFILE" "$PRIVATE_FILE" || fail "Cannot copy file: $FILE" |
|
76 |
fi |
|
77 |
||
11843 | 78 |
PDF="" |
11801 | 79 |
case "$OUTFILE" in |
80 |
*.pdf) |
|
11843 | 81 |
OUTFILE="${OUTFILE%%.pdf}.eps" |
11801 | 82 |
PDF=true |
83 |
;; |
|
84 |
esac |
|
85 |
||
11843 | 86 |
if [ -z "$OUTFILE" ]; then |
28500 | 87 |
"$ISABELLE_TOOL" java GraphBrowser.GraphBrowser "$(jvmpath "$PRIVATE_FILE")" |
11813 | 88 |
else |
28500 | 89 |
"$ISABELLE_TOOL" java GraphBrowser.Console "$(jvmpath "$PRIVATE_FILE")" "$(jvmpath "$OUTFILE")" |
11813 | 90 |
fi |
11843 | 91 |
RC="$?" |
11801 | 92 |
|
93 |
if [ -n "$PDF" ]; then |
|
11843 | 94 |
"$ISABELLE_EPSTOPDF" "$OUTFILE" || fail "Failed to produce pdf output" |
11801 | 95 |
fi |
96 |
||
20569 | 97 |
rm -f "$PRIVATE_FILE" |
9794 | 98 |
fi |
11843 | 99 |
|
100 |
exit "$RC" |