author | chaieb |
Mon, 09 Feb 2009 15:38:26 +0000 | |
changeset 29837 | eb7e62c0f53c |
parent 28502 | 6b0e3e4e1891 |
child 30204 | 8ede2f7104cf |
permissions | -rwxr-xr-x |
11391 | 1 |
#!/usr/bin/env bash |
2339 | 2 |
# |
3 |
# $Id$ |
|
9789 | 4 |
# Author: Markus Wenzel, TU Muenchen |
2339 | 5 |
# |
6 |
# mk - build Pure Isabelle. |
|
7 |
# |
|
10102 | 8 |
# Requires proper Isabelle settings environment (cf. IsaMakefile). |
2339 | 9 |
|
10 |
||
11 |
## diagnostics |
|
12 |
||
3774 | 13 |
function usage() |
14 |
{ |
|
15 |
echo |
|
16 |
echo "Usage: $PRG [OPTIONS]" |
|
17 |
echo |
|
18 |
echo " Make Pure Isabelle." |
|
19 |
echo |
|
21996 | 20 |
echo " -R DIR/FILE run RAW session" |
21 |
echo " -r build RAW image" |
|
3774 | 22 |
echo |
23 |
exit 1 |
|
24 |
} |
|
25 |
||
2339 | 26 |
function fail() |
27 |
{ |
|
28 |
echo "$1" >&2 |
|
29 |
exit 2 |
|
30 |
} |
|
31 |
||
32 |
||
3774 | 33 |
## process command line |
34 |
||
35 |
# options |
|
36 |
||
21996 | 37 |
RAW_SESSION="" |
3774 | 38 |
RAW="" |
39 |
||
21996 | 40 |
while getopts "R:r" OPT |
3774 | 41 |
do |
42 |
case "$OPT" in |
|
21996 | 43 |
R) |
44 |
RAW_SESSION="$OPTARG" |
|
10102 | 45 |
;; |
3774 | 46 |
r) |
47 |
RAW=true |
|
48 |
;; |
|
49 |
\?) |
|
50 |
usage |
|
51 |
;; |
|
52 |
esac |
|
53 |
done |
|
54 |
||
55 |
shift $(($OPTIND - 1)) |
|
56 |
||
57 |
||
58 |
# args |
|
59 |
||
9789 | 60 |
[ "$#" -ne 0 ] && usage |
3774 | 61 |
|
62 |
||
2339 | 63 |
## main |
64 |
||
4442 | 65 |
# get compatibility file |
66 |
||
9789 | 67 |
ML_SYSTEM_BASE=$(echo "$ML_SYSTEM" | cut -f1 -d-) |
16131 | 68 |
[ -z "$ML_SYSTEM" ] && fail "Missing ML_SYSTEM settings!" |
2339 | 69 |
|
70 |
COMPAT="" |
|
71 |
[ -f "ML-Systems/$ML_SYSTEM_BASE.ML" ] && COMPAT="ML-Systems/$ML_SYSTEM_BASE.ML" |
|
72 |
[ -f "ML-Systems/$ML_SYSTEM.ML" ] && COMPAT="ML-Systems/$ML_SYSTEM.ML" |
|
73 |
[ -z "$COMPAT" ] && fail "Missing compatibility file for ML system \"$ML_SYSTEM\"!" |
|
74 |
||
4442 | 75 |
|
76 |
# prepare log dir |
|
77 |
||
78 |
LOGDIR="$ISABELLE_OUTPUT/log" |
|
79 |
mkdir -p "$LOGDIR" |
|
80 |
||
81 |
||
82 |
# run isabelle |
|
83 |
||
18321
3414557c2dda
replaced lib/scripts/showtime by more advanced lib/scripts/timestart|stop.bash;
wenzelm
parents:
16376
diff
changeset
|
84 |
. "$ISABELLE_HOME/lib/scripts/timestart.bash" |
4442 | 85 |
|
21996 | 86 |
if [ -n "$RAW" ]; then |
87 |
ITEM="RAW" |
|
88 |
echo "Building $ITEM ..." |
|
89 |
LOG="$LOGDIR/$ITEM" |
|
90 |
||
28502 | 91 |
"$ISABELLE_PROCESS" \ |
21996 | 92 |
-e "val ml_system = \"$ML_SYSTEM\";" \ |
93 |
-e "val ml_platform = \"$ML_PLATFORM\";" \ |
|
94 |
-e "use\"$COMPAT\" handle _ => exit 1;" \ |
|
95 |
-q -w RAW_ML_SYSTEM RAW > "$LOG" 2>&1 |
|
96 |
RC="$?" |
|
97 |
elif [ -n "$RAW_SESSION" ]; then |
|
98 |
ITEM="RAW-$(basename $(dirname "$RAW_SESSION"))" |
|
22011 | 99 |
echo "Running $ITEM ..." |
21996 | 100 |
LOG="$LOGDIR/$ITEM" |
101 |
||
28502 | 102 |
"$ISABELLE_PROCESS" \ |
21996 | 103 |
-e "use\"$RAW_SESSION\" handle _ => exit 1;" \ |
104 |
-q RAW > "$LOG" 2>&1 |
|
105 |
RC="$?" |
|
106 |
else |
|
4442 | 107 |
ITEM="Pure" |
7277 | 108 |
echo "Building $ITEM ..." |
4442 | 109 |
LOG="$LOGDIR/$ITEM" |
110 |
||
28502 | 111 |
"$ISABELLE_PROCESS" \ |
3774 | 112 |
-e "val ml_system = \"$ML_SYSTEM\";" \ |
16376 | 113 |
-e "val ml_platform = \"$ML_PLATFORM\";" \ |
4495 | 114 |
-e "(use\"$COMPAT\"; use\"ROOT.ML\") handle _ => exit 1;" \ |
10900 | 115 |
-f -c -q -w RAW_ML_SYSTEM Pure > "$LOG" 2>&1 |
9789 | 116 |
RC="$?" |
3774 | 117 |
fi |
4442 | 118 |
|
18321
3414557c2dda
replaced lib/scripts/showtime by more advanced lib/scripts/timestart|stop.bash;
wenzelm
parents:
16376
diff
changeset
|
119 |
. "$ISABELLE_HOME/lib/scripts/timestop.bash" |
4442 | 120 |
|
121 |
||
122 |
# exit status |
|
123 |
||
9789 | 124 |
if [ "$RC" -eq 0 ]; then |
18321
3414557c2dda
replaced lib/scripts/showtime by more advanced lib/scripts/timestart|stop.bash;
wenzelm
parents:
16376
diff
changeset
|
125 |
echo "Finished $ITEM ($TIMES_REPORT)" |
4442 | 126 |
gzip --force "$LOG" |
127 |
else |
|
7263 | 128 |
echo "$ITEM FAILED" |
4442 | 129 |
echo "(see also $LOG)" |
9789 | 130 |
echo; tail "$LOG"; echo |
4442 | 131 |
fi |
132 |
||
9789 | 133 |
exit "$RC" |