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