author | wenzelm |
Mon, 11 Nov 2013 17:34:44 +0100 | |
changeset 54383 | 9d3c7a04a65e |
parent 52083 | f852d08376f9 |
child 60962 | faa452d8e265 |
permissions | -rwxr-xr-x |
48360 | 1 |
#!/usr/bin/env bash |
2 |
# |
|
3 |
# Author: Makarius |
|
4 |
# |
|
5 |
# build - build Isabelle/ML |
|
6 |
# |
|
7 |
# Requires proper Isabelle settings environment. |
|
8 |
||
9 |
||
10 |
## diagnostics |
|
11 |
||
12 |
function usage() |
|
13 |
{ |
|
14 |
echo |
|
48511
37999ee01156
remove old output heaps, to ensure that result is valid wrt. check_stamps;
wenzelm
parents:
48447
diff
changeset
|
15 |
echo "Usage: $PRG TARGET [OUTPUT]" |
48360 | 16 |
echo |
17 |
exit 1 |
|
18 |
} |
|
19 |
||
20 |
function fail() |
|
21 |
{ |
|
22 |
echo "$1" >&2 |
|
23 |
exit 2 |
|
24 |
} |
|
25 |
||
26 |
[ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment" |
|
27 |
||
28 |
||
29 |
## process command line |
|
30 |
||
48373 | 31 |
# args |
32 |
||
48511
37999ee01156
remove old output heaps, to ensure that result is valid wrt. check_stamps;
wenzelm
parents:
48447
diff
changeset
|
33 |
if [ "$#" -eq 1 ]; then |
37999ee01156
remove old output heaps, to ensure that result is valid wrt. check_stamps;
wenzelm
parents:
48447
diff
changeset
|
34 |
TARGET="$1"; shift |
37999ee01156
remove old output heaps, to ensure that result is valid wrt. check_stamps;
wenzelm
parents:
48447
diff
changeset
|
35 |
OUTPUT=""; shift |
37999ee01156
remove old output heaps, to ensure that result is valid wrt. check_stamps;
wenzelm
parents:
48447
diff
changeset
|
36 |
elif [ "$#" -eq 2 ]; then |
48447
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48417
diff
changeset
|
37 |
TARGET="$1"; shift |
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48417
diff
changeset
|
38 |
OUTPUT="$1"; shift |
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48417
diff
changeset
|
39 |
else |
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48417
diff
changeset
|
40 |
usage |
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48417
diff
changeset
|
41 |
fi |
48360 | 42 |
|
43 |
||
44 |
## main |
|
45 |
||
46 |
# get compatibility file |
|
47 |
||
48 |
ML_SYSTEM_BASE=$(echo "$ML_SYSTEM" | cut -f1 -d-) |
|
49 |
[ -z "$ML_SYSTEM" ] && fail "Missing ML_SYSTEM settings!" |
|
50 |
||
51 |
COMPAT="" |
|
52 |
[ -f "ML-Systems/${ML_SYSTEM_BASE}.ML" ] && COMPAT="ML-Systems/${ML_SYSTEM_BASE}.ML" |
|
53 |
[ -f "ML-Systems/${ML_SYSTEM}.ML" ] && COMPAT="ML-Systems/${ML_SYSTEM}.ML" |
|
54 |
[ -z "$COMPAT" ] && fail "Missing compatibility file for ML system \"$ML_SYSTEM\"!" |
|
55 |
||
56 |
||
57 |
# run isabelle |
|
58 |
||
59 |
. "$ISABELLE_HOME/lib/scripts/timestart.bash" |
|
60 |
||
48373 | 61 |
if [ "$TARGET" = RAW ]; then |
48447
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48417
diff
changeset
|
62 |
if [ -z "$OUTPUT" ]; then |
48373 | 63 |
"$ISABELLE_PROCESS" \ |
48662 | 64 |
-e "use\"$COMPAT\" handle _ => Posix.Process.exit 0w1;" \ |
48373 | 65 |
-q RAW_ML_SYSTEM |
66 |
else |
|
67 |
"$ISABELLE_PROCESS" \ |
|
48662 | 68 |
-e "use\"$COMPAT\" handle _ => Posix.Process.exit 0w1;" \ |
48373 | 69 |
-e "structure Isar = struct fun main () = () end;" \ |
70 |
-e "ml_prompts \"ML> \" \"ML# \";" \ |
|
48447
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48417
diff
changeset
|
71 |
-q -w RAW_ML_SYSTEM "$OUTPUT" |
48373 | 72 |
fi |
73 |
else |
|
48447
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48417
diff
changeset
|
74 |
if [ -z "$OUTPUT" ]; then |
48373 | 75 |
"$ISABELLE_PROCESS" \ |
48662 | 76 |
-e "(use\"$COMPAT\"; use\"ROOT.ML\") handle _ => Posix.Process.exit 0w1;" \ |
48373 | 77 |
-q RAW_ML_SYSTEM |
78 |
else |
|
79 |
"$ISABELLE_PROCESS" \ |
|
48662 | 80 |
-e "(use\"$COMPAT\"; use\"ROOT.ML\") handle _ => Posix.Process.exit 0w1;" \ |
48373 | 81 |
-e "ml_prompts \"ML> \" \"ML# \";" \ |
52054
eaf17514aabd
discontinued obsolete isabelle-process options -f and -u;
wenzelm
parents:
48662
diff
changeset
|
82 |
-e "Command_Line.tool0 Session.finish;" \ |
52083
f852d08376f9
even later Options.reset_default -- still needed for printing errors of Session.finish (e.g. via Command_Line.tool0);
wenzelm
parents:
52054
diff
changeset
|
83 |
-e "Options.reset_default ();" \ |
52054
eaf17514aabd
discontinued obsolete isabelle-process options -f and -u;
wenzelm
parents:
48662
diff
changeset
|
84 |
-q -w RAW_ML_SYSTEM "$OUTPUT" |
48373 | 85 |
fi |
86 |
fi |
|
48360 | 87 |
|
48373 | 88 |
RC="$?" |
48360 | 89 |
|
90 |
. "$ISABELLE_HOME/lib/scripts/timestop.bash" |
|
91 |
||
92 |
if [ "$RC" -eq 0 ]; then |
|
93 |
echo "Finished $TARGET ($TIMES_REPORT)" >&2 |
|
94 |
fi |
|
95 |
||
96 |
exit "$RC" |