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