author | wenzelm |
Thu, 12 Sep 2013 13:23:54 +0200 | |
changeset 53576 | 793a429c63e7 |
parent 53451 | fb74a9cb699c |
child 53577 | d033bc00b762 |
permissions | -rwxr-xr-x |
49558 | 1 |
#!/usr/bin/env bash |
2 |
# |
|
3 |
# Author: Markus Kaiser, TU Muenchen |
|
4 |
# Author: Makarius |
|
5 |
# |
|
6 |
# DESCRIPTION: graphview command-line tool wrapper |
|
7 |
||
8 |
## sources |
|
9 |
||
10 |
declare -a SOURCES=( |
|
11 |
"src/graph_panel.scala" |
|
49575 | 12 |
"src/graphview.scala" |
49558 | 13 |
"src/layout_pendulum.scala" |
14 |
"src/main_panel.scala" |
|
15 |
"src/model.scala" |
|
16 |
"src/mutator_dialog.scala" |
|
17 |
"src/mutator_event.scala" |
|
18 |
"src/mutator.scala" |
|
19 |
"src/popups.scala" |
|
20 |
"src/shapes.scala" |
|
21 |
"src/visualizer.scala" |
|
22 |
) |
|
23 |
||
24 |
||
25 |
## diagnostics |
|
26 |
||
27 |
PRG="$(basename "$0")" |
|
28 |
||
29 |
function usage() |
|
30 |
{ |
|
31 |
echo |
|
32 |
echo "Usage: isabelle $PRG [OPTIONS] GRAPH_FILE" |
|
33 |
echo |
|
34 |
echo " Options are:" |
|
35 |
echo " -b build only" |
|
49563 | 36 |
echo " -c cleanup -- remove GRAPH_FILE after use" |
49558 | 37 |
echo " -f fresh build" |
38 |
echo |
|
39 |
exit 1 |
|
40 |
} |
|
41 |
||
42 |
function fail() |
|
43 |
{ |
|
44 |
echo "$1" >&2 |
|
45 |
exit 2 |
|
46 |
} |
|
47 |
||
48 |
function failed() |
|
49 |
{ |
|
50 |
fail "Failed!" |
|
51 |
} |
|
52 |
||
53 |
||
54 |
## process command line |
|
55 |
||
56 |
# options |
|
57 |
||
49565
ea4308b7ef0f
ML support for generic graph display, with browser and graphview backends (via print modes);
wenzelm
parents:
49563
diff
changeset
|
58 |
BUILD_ONLY="false" |
ea4308b7ef0f
ML support for generic graph display, with browser and graphview backends (via print modes);
wenzelm
parents:
49563
diff
changeset
|
59 |
CLEAN="false" |
49558 | 60 |
BUILD_JARS="jars" |
61 |
||
49563 | 62 |
while getopts "bcf" OPT |
49558 | 63 |
do |
64 |
case "$OPT" in |
|
65 |
b) |
|
49565
ea4308b7ef0f
ML support for generic graph display, with browser and graphview backends (via print modes);
wenzelm
parents:
49563
diff
changeset
|
66 |
BUILD_ONLY="true" |
49558 | 67 |
;; |
49563 | 68 |
c) |
69 |
CLEAN="true" |
|
70 |
;; |
|
49558 | 71 |
f) |
72 |
BUILD_JARS="jars_fresh" |
|
73 |
;; |
|
74 |
\?) |
|
75 |
usage |
|
76 |
;; |
|
77 |
esac |
|
78 |
done |
|
79 |
||
49563 | 80 |
shift $(($OPTIND - 1)) |
81 |
||
49558 | 82 |
|
83 |
# args |
|
84 |
||
85 |
GRAPH_FILE="" |
|
49565
ea4308b7ef0f
ML support for generic graph display, with browser and graphview backends (via print modes);
wenzelm
parents:
49563
diff
changeset
|
86 |
[ "$#" -gt 0 ] && { GRAPH_FILE="$1"; shift; } |
ea4308b7ef0f
ML support for generic graph display, with browser and graphview backends (via print modes);
wenzelm
parents:
49563
diff
changeset
|
87 |
[ "$#" -ne 0 ] && usage |
ea4308b7ef0f
ML support for generic graph display, with browser and graphview backends (via print modes);
wenzelm
parents:
49563
diff
changeset
|
88 |
[ -z "$GRAPH_FILE" -a "$BUILD_ONLY" = false ] && usage |
49558 | 89 |
|
90 |
||
91 |
## build |
|
92 |
||
52443 | 93 |
isabelle_admin_build "$BUILD_JARS" || exit $? |
49558 | 94 |
|
95 |
pushd "$GRAPHVIEW_HOME" >/dev/null || failed |
|
96 |
||
97 |
PURE_JAR="$ISABELLE_HOME/lib/classes/ext/Pure.jar" |
|
98 |
||
99 |
TARGET_DIR="$ISABELLE_HOME/lib/classes" |
|
100 |
TARGET="$TARGET_DIR/ext/Graphview.jar" |
|
101 |
||
102 |
declare -a UPDATED=() |
|
103 |
||
104 |
if [ "$BUILD_JARS" = jars_fresh ]; then |
|
105 |
OUTDATED=true |
|
106 |
else |
|
107 |
OUTDATED=false |
|
108 |
if [ ! -e "$TARGET" ]; then |
|
109 |
OUTDATED=true |
|
110 |
else |
|
49569
7b6aaf446496
tuned pretty_locale/print_locale, with more basic pretty_locale_deps based on that;
wenzelm
parents:
49567
diff
changeset
|
111 |
if [ -e "$ISABELLE_HOME/Admin/build" ]; then |
49558 | 112 |
declare -a DEPS=("$PURE_JAR" "${SOURCES[@]}") |
113 |
else |
|
114 |
declare -a DEPS=() |
|
115 |
fi |
|
116 |
for DEP in "${DEPS[@]}" |
|
117 |
do |
|
118 |
[ ! -e "$DEP" ] && fail "Missing file: $DEP" |
|
119 |
[ "$DEP" -nt "$TARGET" ] && { |
|
120 |
OUTDATED=true |
|
121 |
UPDATED["${#UPDATED[@]}"]="$DEP" |
|
122 |
} |
|
123 |
done |
|
124 |
fi |
|
125 |
fi |
|
126 |
||
127 |
if [ "$OUTDATED" = true ] |
|
128 |
then |
|
129 |
echo "### Building Isabelle/Graphview ..." |
|
130 |
||
131 |
[ "${#UPDATED[@]}" -gt 0 ] && { |
|
132 |
echo "Changed files:" |
|
133 |
for FILE in "${UPDATED[@]}" |
|
134 |
do |
|
135 |
echo " $FILE" |
|
136 |
done |
|
137 |
} |
|
138 |
||
139 |
rm -rf classes && mkdir classes |
|
140 |
||
141 |
( |
|
53451 | 142 |
#workaround for scalac |
143 |
function stty() { :; } |
|
144 |
export -f stty |
|
145 |
||
53576
793a429c63e7
maintain classpath in more elementary manner: turn ISABELLE_CLASSPATH into -classpath option, so that all jars are covered by sun.misc.Launcher.AppClassLoader (e.g. relevant for loading add-on resources);
wenzelm
parents:
53451
diff
changeset
|
146 |
classpath "$PURE_JAR" |
793a429c63e7
maintain classpath in more elementary manner: turn ISABELLE_CLASSPATH into -classpath option, so that all jars are covered by sun.misc.Launcher.AppClassLoader (e.g. relevant for loading add-on resources);
wenzelm
parents:
53451
diff
changeset
|
147 |
export CLASSPATH="$(jvmpath "$ISABELLE_CLASSPATH")" |
49558 | 148 |
exec "$SCALA_HOME/bin/scalac" $ISABELLE_SCALA_BUILD_OPTIONS -d classes "${SOURCES[@]}" |
149 |
) || fail "Failed to compile sources" |
|
150 |
||
151 |
cd classes |
|
49567 | 152 |
isabelle_jdk jar cf "$(jvmpath "$TARGET")" * || failed |
49558 | 153 |
cd .. |
154 |
rm -rf classes |
|
155 |
fi |
|
156 |
||
157 |
popd >/dev/null |
|
158 |
||
159 |
||
160 |
## run |
|
161 |
||
49563 | 162 |
if [ "$BUILD_ONLY" = false ]; then |
163 |
PRIVATE_FILE="${ISABELLE_TMP:-/tmp}/$$""$(basename "$GRAPH_FILE")" |
|
49565
ea4308b7ef0f
ML support for generic graph display, with browser and graphview backends (via print modes);
wenzelm
parents:
49563
diff
changeset
|
164 |
if [ "$CLEAN" = "true" ]; then |
49563 | 165 |
mv -f "$GRAPH_FILE" "$PRIVATE_FILE" || fail "Cannot move file: $GRAPH_FILE" |
166 |
else |
|
167 |
cp -f "$GRAPH_FILE" "$PRIVATE_FILE" || fail "Cannot copy file: $GRAPH_FILE" |
|
168 |
fi |
|
169 |
||
49575 | 170 |
"$ISABELLE_TOOL" java $GRAPHVIEW_JAVA_OPTIONS isabelle.graphview.Graphview "$PRIVATE_FILE" |
49563 | 171 |
RC="$?" |
172 |
||
173 |
rm -f "$PRIVATE_FILE" |
|
174 |
echo "$RC" |
|
175 |
fi |