| author | wenzelm | 
| Mon, 20 Aug 2012 15:43:10 +0200 | |
| changeset 48866 | 034df7b05759 | 
| parent 48780 | 49a965020394 | 
| child 48903 | 1621b3f26095 | 
| 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:"  | 
|
| 
48737
 
f3bbb9ca57d6
added build option -D: include session directory and select its sessions;
 
wenzelm 
parents: 
48601 
diff
changeset
 | 
29  | 
echo " -D DIR include session directory and select its sessions"  | 
| 48570 | 30  | 
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
 | 
31  | 
echo " -b build heap images"  | 
| 48595 | 32  | 
echo " -c clean build"  | 
| 
48737
 
f3bbb9ca57d6
added build option -D: include session directory and select its sessions;
 
wenzelm 
parents: 
48601 
diff
changeset
 | 
33  | 
echo " -d DIR include session directory"  | 
| 48570 | 34  | 
echo " -g NAME select session group NAME"  | 
| 48578 | 35  | 
echo " -j INT maximum number of parallel jobs (default 1)"  | 
| 48469 | 36  | 
echo " -n no build -- test dependencies only"  | 
| 48276 | 37  | 
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
 | 
38  | 
echo " -s system build mode: produce output in ISABELLE_HOME"  | 
| 48425 | 39  | 
echo " -v verbose"  | 
| 48276 | 40  | 
echo  | 
41  | 
echo " Build and manage Isabelle sessions, depending on implicit"  | 
|
| 48474 | 42  | 
show_settings " "  | 
| 48276 | 43  | 
echo  | 
44  | 
exit 1  | 
|
45  | 
}  | 
|
46  | 
||
47  | 
function fail()  | 
|
48  | 
{
 | 
|
49  | 
echo "$1" >&2  | 
|
50  | 
exit 2  | 
|
51  | 
}  | 
|
52  | 
||
| 48425 | 53  | 
function check_number()  | 
54  | 
{
 | 
|
55  | 
[ -n "$1" -a -z "$(echo "$1" | tr -d '[0-9]')" ] || fail "Bad number: \"$1\""  | 
|
56  | 
}  | 
|
57  | 
||
| 48276 | 58  | 
|
59  | 
## process command line  | 
|
60  | 
||
| 
48737
 
f3bbb9ca57d6
added build option -D: include session directory and select its sessions;
 
wenzelm 
parents: 
48601 
diff
changeset
 | 
61  | 
declare -a SELECT_DIRS=()  | 
| 48276 | 62  | 
ALL_SESSIONS=false  | 
| 
48511
 
37999ee01156
remove old output heaps, to ensure that result is valid wrt. check_stamps;
 
wenzelm 
parents: 
48509 
diff
changeset
 | 
63  | 
BUILD_HEAP=false  | 
| 48595 | 64  | 
CLEAN_BUILD=false  | 
| 
48737
 
f3bbb9ca57d6
added build option -D: include session directory and select its sessions;
 
wenzelm 
parents: 
48601 
diff
changeset
 | 
65  | 
declare -a INCLUDE_DIRS=()  | 
| 48509 | 66  | 
declare -a SESSION_GROUPS=()  | 
| 48425 | 67  | 
MAX_JOBS=1  | 
| 48469 | 68  | 
NO_BUILD=false  | 
| 48509 | 69  | 
eval "declare -a BUILD_OPTIONS=($ISABELLE_BUILD_OPTIONS)"  | 
| 
48447
 
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
 
wenzelm 
parents: 
48425 
diff
changeset
 | 
70  | 
SYSTEM_MODE=false  | 
| 48425 | 71  | 
VERBOSE=false  | 
| 48276 | 72  | 
|
| 
48737
 
f3bbb9ca57d6
added build option -D: include session directory and select its sessions;
 
wenzelm 
parents: 
48601 
diff
changeset
 | 
73  | 
while getopts "D:abcd:g:j:no:sv" OPT  | 
| 48276 | 74  | 
do  | 
75  | 
case "$OPT" in  | 
|
| 
48737
 
f3bbb9ca57d6
added build option -D: include session directory and select its sessions;
 
wenzelm 
parents: 
48601 
diff
changeset
 | 
76  | 
D)  | 
| 
 
f3bbb9ca57d6
added build option -D: include session directory and select its sessions;
 
wenzelm 
parents: 
48601 
diff
changeset
 | 
77  | 
      SELECT_DIRS["${#SELECT_DIRS[@]}"]="$OPTARG"
 | 
| 
 
f3bbb9ca57d6
added build option -D: include session directory and select its sessions;
 
wenzelm 
parents: 
48601 
diff
changeset
 | 
78  | 
;;  | 
| 48276 | 79  | 
a)  | 
80  | 
ALL_SESSIONS="true"  | 
|
81  | 
;;  | 
|
82  | 
b)  | 
|
| 
48511
 
37999ee01156
remove old output heaps, to ensure that result is valid wrt. check_stamps;
 
wenzelm 
parents: 
48509 
diff
changeset
 | 
83  | 
BUILD_HEAP="true"  | 
| 48276 | 84  | 
;;  | 
| 48595 | 85  | 
c)  | 
86  | 
CLEAN_BUILD="true"  | 
|
87  | 
;;  | 
|
| 
48340
 
6f4fc030882a
allow explicit specification of additional session directories;
 
wenzelm 
parents: 
48276 
diff
changeset
 | 
88  | 
d)  | 
| 
48737
 
f3bbb9ca57d6
added build option -D: include session directory and select its sessions;
 
wenzelm 
parents: 
48601 
diff
changeset
 | 
89  | 
      INCLUDE_DIRS["${#INCLUDE_DIRS[@]}"]="$OPTARG"
 | 
| 
48340
 
6f4fc030882a
allow explicit specification of additional session directories;
 
wenzelm 
parents: 
48276 
diff
changeset
 | 
90  | 
;;  | 
| 48509 | 91  | 
g)  | 
92  | 
      SESSION_GROUPS["${#SESSION_GROUPS[@]}"]="$OPTARG"
 | 
|
93  | 
;;  | 
|
| 48425 | 94  | 
j)  | 
95  | 
check_number "$OPTARG"  | 
|
96  | 
MAX_JOBS="$OPTARG"  | 
|
97  | 
;;  | 
|
| 48469 | 98  | 
n)  | 
99  | 
NO_BUILD="true"  | 
|
| 48276 | 100  | 
;;  | 
101  | 
o)  | 
|
102  | 
      BUILD_OPTIONS["${#BUILD_OPTIONS[@]}"]="$OPTARG"
 | 
|
103  | 
;;  | 
|
| 
48447
 
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
 
wenzelm 
parents: 
48425 
diff
changeset
 | 
104  | 
s)  | 
| 
 
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
 
wenzelm 
parents: 
48425 
diff
changeset
 | 
105  | 
SYSTEM_MODE="true"  | 
| 
 
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
 
wenzelm 
parents: 
48425 
diff
changeset
 | 
106  | 
;;  | 
| 48425 | 107  | 
v)  | 
108  | 
VERBOSE="true"  | 
|
109  | 
;;  | 
|
| 48276 | 110  | 
\?)  | 
111  | 
usage  | 
|
112  | 
;;  | 
|
113  | 
esac  | 
|
114  | 
done  | 
|
115  | 
||
116  | 
shift $(($OPTIND - 1))  | 
|
117  | 
||
118  | 
||
119  | 
## main  | 
|
120  | 
||
121  | 
[ -e "$ISABELLE_HOME/Admin/build" ] && { "$ISABELLE_HOME/Admin/build" jars || exit $?; }
 | 
|
122  | 
||
| 48601 | 123  | 
if [ "$NO_BUILD" = false -a "$VERBOSE" = true ]; then  | 
| 48474 | 124  | 
echo "Started at $(date) ($ML_IDENTIFIER on $(hostname))"  | 
125  | 
||
| 48601 | 126  | 
show_settings ""  | 
127  | 
echo  | 
|
| 48474 | 128  | 
fi  | 
129  | 
||
| 
48780
 
49a965020394
always show some timing information, to reduce the need for explicit -v;
 
wenzelm 
parents: 
48737 
diff
changeset
 | 
130  | 
. "$ISABELLE_HOME/lib/scripts/timestart.bash"  | 
| 
 
49a965020394
always show some timing information, to reduce the need for explicit -v;
 
wenzelm 
parents: 
48737 
diff
changeset
 | 
131  | 
|
| 48474 | 132  | 
"$ISABELLE_TOOL" java isabelle.Build \  | 
| 48595 | 133  | 
"$ALL_SESSIONS" "$BUILD_HEAP" "$CLEAN_BUILD" "$MAX_JOBS" \  | 
134  | 
"$NO_BUILD" "$SYSTEM_MODE" "$VERBOSE" \  | 
|
| 
48737
 
f3bbb9ca57d6
added build option -D: include session directory and select its sessions;
 
wenzelm 
parents: 
48601 
diff
changeset
 | 
135  | 
  "${SELECT_DIRS[@]}" $'\n' "${INCLUDE_DIRS[@]}" $'\n' \
 | 
| 
 
f3bbb9ca57d6
added build option -D: include session directory and select its sessions;
 
wenzelm 
parents: 
48601 
diff
changeset
 | 
136  | 
  "${SESSION_GROUPS[@]}" $'\n' "${BUILD_OPTIONS[@]}" $'\n' "$@"
 | 
| 48474 | 137  | 
RC="$?"  | 
138  | 
||
| 48601 | 139  | 
if [ "$NO_BUILD" = false -a "$VERBOSE" = true ]; then  | 
| 48474 | 140  | 
echo -n "Finished at "; date  | 
141  | 
||
142  | 
fi  | 
|
143  | 
||
| 
48780
 
49a965020394
always show some timing information, to reduce the need for explicit -v;
 
wenzelm 
parents: 
48737 
diff
changeset
 | 
144  | 
. "$ISABELLE_HOME/lib/scripts/timestop.bash"  | 
| 
 
49a965020394
always show some timing information, to reduce the need for explicit -v;
 
wenzelm 
parents: 
48737 
diff
changeset
 | 
145  | 
echo "$TIMES_REPORT"  | 
| 
 
49a965020394
always show some timing information, to reduce the need for explicit -v;
 
wenzelm 
parents: 
48737 
diff
changeset
 | 
146  | 
|
| 48474 | 147  | 
exit "$RC"  |