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