author | wenzelm |
Tue, 08 Sep 2015 11:44:15 +0200 | |
changeset 61131 | 83459eb76fe3 |
parent 60106 | e0d1d9203275 |
child 61135 | 8f7d802b7a71 |
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 |
|
61131 | 17 |
echo "${PREFIX}ISABELLE_BUILD_JAVA_OPTIONS=\"$ISABELLE_BUILD_JAVA_OPTIONS\"" |
18 |
echo |
|
48474 | 19 |
echo "${PREFIX}ML_PLATFORM=\"$ML_PLATFORM\"" |
20 |
echo "${PREFIX}ML_HOME=\"$ML_HOME\"" |
|
21 |
echo "${PREFIX}ML_SYSTEM=\"$ML_SYSTEM\"" |
|
22 |
echo "${PREFIX}ML_OPTIONS=\"$ML_OPTIONS\"" |
|
23 |
} |
|
24 |
||
48276 | 25 |
function usage() |
26 |
{ |
|
27 |
echo |
|
28 |
echo "Usage: isabelle $PRG [OPTIONS] [SESSIONS ...]" |
|
29 |
echo |
|
30 |
echo " Options are:" |
|
48737
f3bbb9ca57d6
added build option -D: include session directory and select its sessions;
wenzelm
parents:
48601
diff
changeset
|
31 |
echo " -D DIR include session directory and select its sessions" |
49131 | 32 |
echo " -R operate on requirements of selected sessions" |
60106 | 33 |
echo " -X NAME exclude sessions from group NAME and all descendants" |
48570 | 34 |
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
|
35 |
echo " -b build heap images" |
48595 | 36 |
echo " -c clean build" |
48737
f3bbb9ca57d6
added build option -D: include session directory and select its sessions;
wenzelm
parents:
48601
diff
changeset
|
37 |
echo " -d DIR include session directory" |
48570 | 38 |
echo " -g NAME select session group NAME" |
48578 | 39 |
echo " -j INT maximum number of parallel jobs (default 1)" |
59891
9ce697050455
added isabelle build option -k, for fast off-line checking of theory sources;
wenzelm
parents:
59565
diff
changeset
|
40 |
echo " -k KEYWORD check theory sources for conflicts with proposed keywords" |
48903 | 41 |
echo " -l list session source files" |
48469 | 42 |
echo " -n no build -- test dependencies only" |
52056 | 43 |
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
|
44 |
echo " -s system build mode: produce output in ISABELLE_HOME" |
48425 | 45 |
echo " -v verbose" |
60106 | 46 |
echo " -x NAME exclude session NAME and all descendants" |
48276 | 47 |
echo |
48 |
echo " Build and manage Isabelle sessions, depending on implicit" |
|
48474 | 49 |
show_settings " " |
48276 | 50 |
echo |
51 |
exit 1 |
|
52 |
} |
|
53 |
||
54 |
function fail() |
|
55 |
{ |
|
56 |
echo "$1" >&2 |
|
57 |
exit 2 |
|
58 |
} |
|
59 |
||
48425 | 60 |
function check_number() |
61 |
{ |
|
62 |
[ -n "$1" -a -z "$(echo "$1" | tr -d '[0-9]')" ] || fail "Bad number: \"$1\"" |
|
63 |
} |
|
64 |
||
48276 | 65 |
|
66 |
## process command line |
|
67 |
||
48737
f3bbb9ca57d6
added build option -D: include session directory and select its sessions;
wenzelm
parents:
48601
diff
changeset
|
68 |
declare -a SELECT_DIRS=() |
49131 | 69 |
REQUIREMENTS=false |
60106 | 70 |
declare -a EXCLUDE_SESSION_GROUPS=() |
48276 | 71 |
ALL_SESSIONS=false |
48511
37999ee01156
remove old output heaps, to ensure that result is valid wrt. check_stamps;
wenzelm
parents:
48509
diff
changeset
|
72 |
BUILD_HEAP=false |
48595 | 73 |
CLEAN_BUILD=false |
48737
f3bbb9ca57d6
added build option -D: include session directory and select its sessions;
wenzelm
parents:
48601
diff
changeset
|
74 |
declare -a INCLUDE_DIRS=() |
48509 | 75 |
declare -a SESSION_GROUPS=() |
48425 | 76 |
MAX_JOBS=1 |
59891
9ce697050455
added isabelle build option -k, for fast off-line checking of theory sources;
wenzelm
parents:
59565
diff
changeset
|
77 |
declare -a CHECK_KEYWORDS=() |
48903 | 78 |
LIST_FILES=false |
48469 | 79 |
NO_BUILD=false |
48509 | 80 |
eval "declare -a BUILD_OPTIONS=($ISABELLE_BUILD_OPTIONS)" |
48447
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48425
diff
changeset
|
81 |
SYSTEM_MODE=false |
48425 | 82 |
VERBOSE=false |
59892
2a616319c171
added isabelle build option -x, to exclude sessions;
wenzelm
parents:
59891
diff
changeset
|
83 |
declare -a EXCLUDE_SESSIONS=() |
48276 | 84 |
|
60106 | 85 |
while getopts "D:RX:abcd:g:j:k:lno:svx:" OPT |
48276 | 86 |
do |
87 |
case "$OPT" in |
|
48737
f3bbb9ca57d6
added build option -D: include session directory and select its sessions;
wenzelm
parents:
48601
diff
changeset
|
88 |
D) |
f3bbb9ca57d6
added build option -D: include session directory and select its sessions;
wenzelm
parents:
48601
diff
changeset
|
89 |
SELECT_DIRS["${#SELECT_DIRS[@]}"]="$OPTARG" |
f3bbb9ca57d6
added build option -D: include session directory and select its sessions;
wenzelm
parents:
48601
diff
changeset
|
90 |
;; |
49131 | 91 |
R) |
92 |
REQUIREMENTS="true" |
|
93 |
;; |
|
60106 | 94 |
X) |
95 |
EXCLUDE_SESSION_GROUPS["${#EXCLUDE_SESSION_GROUPS[@]}"]="$OPTARG" |
|
96 |
;; |
|
48276 | 97 |
a) |
98 |
ALL_SESSIONS="true" |
|
99 |
;; |
|
100 |
b) |
|
48511
37999ee01156
remove old output heaps, to ensure that result is valid wrt. check_stamps;
wenzelm
parents:
48509
diff
changeset
|
101 |
BUILD_HEAP="true" |
48276 | 102 |
;; |
48595 | 103 |
c) |
104 |
CLEAN_BUILD="true" |
|
105 |
;; |
|
48340
6f4fc030882a
allow explicit specification of additional session directories;
wenzelm
parents:
48276
diff
changeset
|
106 |
d) |
48737
f3bbb9ca57d6
added build option -D: include session directory and select its sessions;
wenzelm
parents:
48601
diff
changeset
|
107 |
INCLUDE_DIRS["${#INCLUDE_DIRS[@]}"]="$OPTARG" |
48340
6f4fc030882a
allow explicit specification of additional session directories;
wenzelm
parents:
48276
diff
changeset
|
108 |
;; |
48509 | 109 |
g) |
110 |
SESSION_GROUPS["${#SESSION_GROUPS[@]}"]="$OPTARG" |
|
111 |
;; |
|
48425 | 112 |
j) |
113 |
check_number "$OPTARG" |
|
114 |
MAX_JOBS="$OPTARG" |
|
115 |
;; |
|
59891
9ce697050455
added isabelle build option -k, for fast off-line checking of theory sources;
wenzelm
parents:
59565
diff
changeset
|
116 |
k) |
9ce697050455
added isabelle build option -k, for fast off-line checking of theory sources;
wenzelm
parents:
59565
diff
changeset
|
117 |
CHECK_KEYWORDS["${#CHECK_KEYWORDS[@]}"]="$OPTARG" |
9ce697050455
added isabelle build option -k, for fast off-line checking of theory sources;
wenzelm
parents:
59565
diff
changeset
|
118 |
;; |
48903 | 119 |
l) |
120 |
LIST_FILES="true" |
|
121 |
;; |
|
48469 | 122 |
n) |
123 |
NO_BUILD="true" |
|
48276 | 124 |
;; |
125 |
o) |
|
126 |
BUILD_OPTIONS["${#BUILD_OPTIONS[@]}"]="$OPTARG" |
|
127 |
;; |
|
48447
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48425
diff
changeset
|
128 |
s) |
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48425
diff
changeset
|
129 |
SYSTEM_MODE="true" |
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48425
diff
changeset
|
130 |
;; |
48425 | 131 |
v) |
132 |
VERBOSE="true" |
|
133 |
;; |
|
59892
2a616319c171
added isabelle build option -x, to exclude sessions;
wenzelm
parents:
59891
diff
changeset
|
134 |
x) |
2a616319c171
added isabelle build option -x, to exclude sessions;
wenzelm
parents:
59891
diff
changeset
|
135 |
EXCLUDE_SESSIONS["${#EXCLUDE_SESSIONS[@]}"]="$OPTARG" |
2a616319c171
added isabelle build option -x, to exclude sessions;
wenzelm
parents:
59891
diff
changeset
|
136 |
;; |
48276 | 137 |
\?) |
138 |
usage |
|
139 |
;; |
|
140 |
esac |
|
141 |
done |
|
142 |
||
143 |
shift $(($OPTIND - 1)) |
|
144 |
||
145 |
||
146 |
## main |
|
147 |
||
52443 | 148 |
isabelle_admin_build jars || exit $? |
48276 | 149 |
|
48601 | 150 |
if [ "$NO_BUILD" = false -a "$VERBOSE" = true ]; then |
48474 | 151 |
echo "Started at $(date) ($ML_IDENTIFIER on $(hostname))" |
152 |
||
48601 | 153 |
show_settings "" |
154 |
echo |
|
48474 | 155 |
fi |
156 |
||
59565
96e860a17b9a
more uniform headless mode for all derivatives of "build" (amending df5dc24ca712);
wenzelm
parents:
59464
diff
changeset
|
157 |
declare -a JAVA_ARGS; eval "JAVA_ARGS=($ISABELLE_BUILD_JAVA_OPTIONS)" |
51977
b55f90655328
more generous java resources via ISABELLE_BUILD_JAVA_OPTIONS;
wenzelm
parents:
50364
diff
changeset
|
158 |
|
48780
49a965020394
always show some timing information, to reduce the need for explicit -v;
wenzelm
parents:
48737
diff
changeset
|
159 |
. "$ISABELLE_HOME/lib/scripts/timestart.bash" |
49a965020394
always show some timing information, to reduce the need for explicit -v;
wenzelm
parents:
48737
diff
changeset
|
160 |
|
51977
b55f90655328
more generous java resources via ISABELLE_BUILD_JAVA_OPTIONS;
wenzelm
parents:
50364
diff
changeset
|
161 |
"$ISABELLE_TOOL" java "${JAVA_ARGS[@]}" isabelle.Build \ |
49131 | 162 |
"$REQUIREMENTS" "$ALL_SESSIONS" "$BUILD_HEAP" "$CLEAN_BUILD" "$MAX_JOBS" \ |
48903 | 163 |
"$LIST_FILES" "$NO_BUILD" "$SYSTEM_MODE" "$VERBOSE" \ |
56890 | 164 |
"${INCLUDE_DIRS[@]}" $'\n' "${SELECT_DIRS[@]}" $'\n' \ |
59891
9ce697050455
added isabelle build option -k, for fast off-line checking of theory sources;
wenzelm
parents:
59565
diff
changeset
|
165 |
"${SESSION_GROUPS[@]}" $'\n' "${CHECK_KEYWORDS[@]}" $'\n' \ |
60106 | 166 |
"${BUILD_OPTIONS[@]}" $'\n' "${EXCLUDE_SESSION_GROUPS[@]}" $'\n' \ |
167 |
"${EXCLUDE_SESSIONS[@]}" $'\n' "$@" |
|
48474 | 168 |
RC="$?" |
169 |
||
48601 | 170 |
if [ "$NO_BUILD" = false -a "$VERBOSE" = true ]; then |
48474 | 171 |
echo -n "Finished at "; date |
172 |
fi |
|
173 |
||
48780
49a965020394
always show some timing information, to reduce the need for explicit -v;
wenzelm
parents:
48737
diff
changeset
|
174 |
. "$ISABELLE_HOME/lib/scripts/timestop.bash" |
49a965020394
always show some timing information, to reduce the need for explicit -v;
wenzelm
parents:
48737
diff
changeset
|
175 |
echo "$TIMES_REPORT" |
49a965020394
always show some timing information, to reduce the need for explicit -v;
wenzelm
parents:
48737
diff
changeset
|
176 |
|
48474 | 177 |
exit "$RC" |