| author | wenzelm | 
| Mon, 30 Jul 2012 13:48:56 +0200 | |
| changeset 48601 | 655b08c2cd89 | 
| parent 48595 | 231e6fa96dbb | 
| child 48737 | f3bbb9ca57d6 | 
| permissions | -rwxr-xr-x | 
| 48276 | 1  | 
#!/usr/bin/env bash  | 
2  | 
#  | 
|
3  | 
# Author: Makarius  | 
|
4  | 
#  | 
|
5  | 
# DESCRIPTION: build and manage Isabelle sessions  | 
|
6  | 
||
7  | 
||
8  | 
## diagnostics  | 
|
9  | 
||
10  | 
PRG="$(basename "$0")"  | 
|
11  | 
||
| 48474 | 12  | 
function show_settings()  | 
13  | 
{
 | 
|
14  | 
local PREFIX="$1"  | 
|
15  | 
  echo "${PREFIX}ISABELLE_BUILD_OPTIONS=\"$ISABELLE_BUILD_OPTIONS\""
 | 
|
16  | 
echo  | 
|
17  | 
  echo "${PREFIX}ML_PLATFORM=\"$ML_PLATFORM\""
 | 
|
18  | 
  echo "${PREFIX}ML_HOME=\"$ML_HOME\""
 | 
|
19  | 
  echo "${PREFIX}ML_SYSTEM=\"$ML_SYSTEM\""
 | 
|
20  | 
  echo "${PREFIX}ML_OPTIONS=\"$ML_OPTIONS\""
 | 
|
21  | 
}  | 
|
22  | 
||
| 48276 | 23  | 
function usage()  | 
24  | 
{
 | 
|
25  | 
echo  | 
|
26  | 
echo "Usage: isabelle $PRG [OPTIONS] [SESSIONS ...]"  | 
|
27  | 
echo  | 
|
28  | 
echo " Options are:"  | 
|
| 48570 | 29  | 
echo " -a select all sessions"  | 
| 
48511
 
37999ee01156
remove old output heaps, to ensure that result is valid wrt. check_stamps;
 
wenzelm 
parents: 
48509 
diff
changeset
 | 
30  | 
echo " -b build heap images"  | 
| 48595 | 31  | 
echo " -c clean build"  | 
| 48509 | 32  | 
echo " -d DIR include session directory with ROOT file"  | 
| 48570 | 33  | 
echo " -g NAME select session group NAME"  | 
| 48578 | 34  | 
echo " -j INT maximum number of parallel jobs (default 1)"  | 
| 48469 | 35  | 
echo " -n no build -- test dependencies only"  | 
| 48276 | 36  | 
echo " -o OPTION override session configuration OPTION (via NAME=VAL or NAME)"  | 
| 
48447
 
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
 
wenzelm 
parents: 
48425 
diff
changeset
 | 
37  | 
echo " -s system build mode: produce output in ISABELLE_HOME"  | 
| 48425 | 38  | 
echo " -v verbose"  | 
| 48276 | 39  | 
echo  | 
40  | 
echo " Build and manage Isabelle sessions, depending on implicit"  | 
|
| 48474 | 41  | 
show_settings " "  | 
| 48276 | 42  | 
echo  | 
43  | 
exit 1  | 
|
44  | 
}  | 
|
45  | 
||
46  | 
function fail()  | 
|
47  | 
{
 | 
|
48  | 
echo "$1" >&2  | 
|
49  | 
exit 2  | 
|
50  | 
}  | 
|
51  | 
||
| 48425 | 52  | 
function check_number()  | 
53  | 
{
 | 
|
54  | 
[ -n "$1" -a -z "$(echo "$1" | tr -d '[0-9]')" ] || fail "Bad number: \"$1\""  | 
|
55  | 
}  | 
|
56  | 
||
| 48276 | 57  | 
|
58  | 
## process command line  | 
|
59  | 
||
60  | 
ALL_SESSIONS=false  | 
|
| 
48511
 
37999ee01156
remove old output heaps, to ensure that result is valid wrt. check_stamps;
 
wenzelm 
parents: 
48509 
diff
changeset
 | 
61  | 
BUILD_HEAP=false  | 
| 48595 | 62  | 
CLEAN_BUILD=false  | 
| 48509 | 63  | 
declare -a MORE_DIRS=()  | 
64  | 
declare -a SESSION_GROUPS=()  | 
|
| 48425 | 65  | 
MAX_JOBS=1  | 
| 48469 | 66  | 
NO_BUILD=false  | 
| 48509 | 67  | 
eval "declare -a BUILD_OPTIONS=($ISABELLE_BUILD_OPTIONS)"  | 
| 
48447
 
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
 
wenzelm 
parents: 
48425 
diff
changeset
 | 
68  | 
SYSTEM_MODE=false  | 
| 48425 | 69  | 
VERBOSE=false  | 
| 48276 | 70  | 
|
| 48595 | 71  | 
while getopts "abcd:g:j:no:sv" OPT  | 
| 48276 | 72  | 
do  | 
73  | 
case "$OPT" in  | 
|
74  | 
a)  | 
|
75  | 
ALL_SESSIONS="true"  | 
|
76  | 
;;  | 
|
77  | 
b)  | 
|
| 
48511
 
37999ee01156
remove old output heaps, to ensure that result is valid wrt. check_stamps;
 
wenzelm 
parents: 
48509 
diff
changeset
 | 
78  | 
BUILD_HEAP="true"  | 
| 48276 | 79  | 
;;  | 
| 48595 | 80  | 
c)  | 
81  | 
CLEAN_BUILD="true"  | 
|
82  | 
;;  | 
|
| 
48340
 
6f4fc030882a
allow explicit specification of additional session directories;
 
wenzelm 
parents: 
48276 
diff
changeset
 | 
83  | 
d)  | 
| 
 
6f4fc030882a
allow explicit specification of additional session directories;
 
wenzelm 
parents: 
48276 
diff
changeset
 | 
84  | 
      MORE_DIRS["${#MORE_DIRS[@]}"]="$OPTARG"
 | 
| 
 
6f4fc030882a
allow explicit specification of additional session directories;
 
wenzelm 
parents: 
48276 
diff
changeset
 | 
85  | 
;;  | 
| 48509 | 86  | 
g)  | 
87  | 
      SESSION_GROUPS["${#SESSION_GROUPS[@]}"]="$OPTARG"
 | 
|
88  | 
;;  | 
|
| 48425 | 89  | 
j)  | 
90  | 
check_number "$OPTARG"  | 
|
91  | 
MAX_JOBS="$OPTARG"  | 
|
92  | 
;;  | 
|
| 48469 | 93  | 
n)  | 
94  | 
NO_BUILD="true"  | 
|
| 48276 | 95  | 
;;  | 
96  | 
o)  | 
|
97  | 
      BUILD_OPTIONS["${#BUILD_OPTIONS[@]}"]="$OPTARG"
 | 
|
98  | 
;;  | 
|
| 
48447
 
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
 
wenzelm 
parents: 
48425 
diff
changeset
 | 
99  | 
s)  | 
| 
 
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
 
wenzelm 
parents: 
48425 
diff
changeset
 | 
100  | 
SYSTEM_MODE="true"  | 
| 
 
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
 
wenzelm 
parents: 
48425 
diff
changeset
 | 
101  | 
;;  | 
| 48425 | 102  | 
v)  | 
103  | 
VERBOSE="true"  | 
|
104  | 
;;  | 
|
| 48276 | 105  | 
\?)  | 
106  | 
usage  | 
|
107  | 
;;  | 
|
108  | 
esac  | 
|
109  | 
done  | 
|
110  | 
||
111  | 
shift $(($OPTIND - 1))  | 
|
112  | 
||
113  | 
||
114  | 
## main  | 
|
115  | 
||
116  | 
[ -e "$ISABELLE_HOME/Admin/build" ] && { "$ISABELLE_HOME/Admin/build" jars || exit $?; }
 | 
|
117  | 
||
| 48601 | 118  | 
if [ "$NO_BUILD" = false -a "$VERBOSE" = true ]; then  | 
| 48474 | 119  | 
echo "Started at $(date) ($ML_IDENTIFIER on $(hostname))"  | 
120  | 
||
| 48601 | 121  | 
show_settings ""  | 
122  | 
echo  | 
|
| 48474 | 123  | 
. "$ISABELLE_HOME/lib/scripts/timestart.bash"  | 
124  | 
fi  | 
|
125  | 
||
126  | 
"$ISABELLE_TOOL" java isabelle.Build \  | 
|
| 48595 | 127  | 
"$ALL_SESSIONS" "$BUILD_HEAP" "$CLEAN_BUILD" "$MAX_JOBS" \  | 
128  | 
"$NO_BUILD" "$SYSTEM_MODE" "$VERBOSE" \  | 
|
| 48509 | 129  | 
  "${MORE_DIRS[@]}" $'\n' "${SESSION_GROUPS[@]}" $'\n' "${BUILD_OPTIONS[@]}" $'\n' "$@"
 | 
| 48474 | 130  | 
RC="$?"  | 
131  | 
||
| 48601 | 132  | 
if [ "$NO_BUILD" = false -a "$VERBOSE" = true ]; then  | 
| 48474 | 133  | 
echo -n "Finished at "; date  | 
134  | 
||
135  | 
. "$ISABELLE_HOME/lib/scripts/timestop.bash"  | 
|
136  | 
echo "$TIMES_REPORT"  | 
|
137  | 
fi  | 
|
138  | 
||
139  | 
exit "$RC"  |