author | wenzelm |
Mon, 23 Jul 2012 15:59:14 +0200 | |
changeset 48447 | ef600ce4559c |
parent 48425 | 0d95980e9aae |
child 48459 | 375e45df6fdf |
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 |
||
12 |
function usage() |
|
13 |
{ |
|
14 |
echo |
|
15 |
echo "Usage: isabelle $PRG [OPTIONS] [SESSIONS ...]" |
|
16 |
echo |
|
17 |
echo " Options are:" |
|
18 |
echo " -a all sessions" |
|
19 |
echo " -b build target images" |
|
48340
6f4fc030882a
allow explicit specification of additional session directories;
wenzelm
parents:
48276
diff
changeset
|
20 |
echo " -d DIR additional session directory with ROOT file" |
48425 | 21 |
echo " -j INT maximum number of jobs (default 1)" |
48276 | 22 |
echo " -l list sessions only" |
23 |
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
|
24 |
echo " -s system build mode: produce output in ISABELLE_HOME" |
48425 | 25 |
echo " -v verbose" |
48276 | 26 |
echo |
27 |
echo " Build and manage Isabelle sessions, depending on implicit" |
|
28 |
echo " ISABELLE_BUILD_OPTIONS=\"$ISABELLE_BUILD_OPTIONS\"" |
|
29 |
echo |
|
30 |
echo " ML_PLATFORM=\"$ML_PLATFORM\"" |
|
31 |
echo " ML_HOME=\"$ML_HOME\"" |
|
32 |
echo " ML_SYSTEM=\"$ML_SYSTEM\"" |
|
33 |
echo " ML_OPTIONS=\"$ML_OPTIONS\"" |
|
34 |
echo |
|
35 |
exit 1 |
|
36 |
} |
|
37 |
||
38 |
function fail() |
|
39 |
{ |
|
40 |
echo "$1" >&2 |
|
41 |
exit 2 |
|
42 |
} |
|
43 |
||
48425 | 44 |
function check_number() |
45 |
{ |
|
46 |
[ -n "$1" -a -z "$(echo "$1" | tr -d '[0-9]')" ] || fail "Bad number: \"$1\"" |
|
47 |
} |
|
48 |
||
48276 | 49 |
|
50 |
## process command line |
|
51 |
||
52 |
ALL_SESSIONS=false |
|
53 |
BUILD_IMAGES=false |
|
48425 | 54 |
MAX_JOBS=1 |
48276 | 55 |
LIST_ONLY=false |
48447
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48425
diff
changeset
|
56 |
SYSTEM_MODE=false |
48425 | 57 |
VERBOSE=false |
48276 | 58 |
|
48340
6f4fc030882a
allow explicit specification of additional session directories;
wenzelm
parents:
48276
diff
changeset
|
59 |
declare -a MORE_DIRS=() |
48276 | 60 |
eval "declare -a BUILD_OPTIONS=($ISABELLE_BUILD_OPTIONS)" |
61 |
||
48447
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48425
diff
changeset
|
62 |
while getopts "abd:j:lo:sv" OPT |
48276 | 63 |
do |
64 |
case "$OPT" in |
|
65 |
a) |
|
66 |
ALL_SESSIONS="true" |
|
67 |
;; |
|
68 |
b) |
|
69 |
BUILD_IMAGES="true" |
|
70 |
;; |
|
48340
6f4fc030882a
allow explicit specification of additional session directories;
wenzelm
parents:
48276
diff
changeset
|
71 |
d) |
6f4fc030882a
allow explicit specification of additional session directories;
wenzelm
parents:
48276
diff
changeset
|
72 |
MORE_DIRS["${#MORE_DIRS[@]}"]="$OPTARG" |
6f4fc030882a
allow explicit specification of additional session directories;
wenzelm
parents:
48276
diff
changeset
|
73 |
;; |
48425 | 74 |
j) |
75 |
check_number "$OPTARG" |
|
76 |
MAX_JOBS="$OPTARG" |
|
77 |
;; |
|
48276 | 78 |
l) |
79 |
LIST_ONLY="true" |
|
80 |
;; |
|
81 |
o) |
|
82 |
BUILD_OPTIONS["${#BUILD_OPTIONS[@]}"]="$OPTARG" |
|
83 |
;; |
|
48447
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48425
diff
changeset
|
84 |
s) |
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48425
diff
changeset
|
85 |
SYSTEM_MODE="true" |
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48425
diff
changeset
|
86 |
;; |
48425 | 87 |
v) |
88 |
VERBOSE="true" |
|
89 |
;; |
|
48276 | 90 |
\?) |
91 |
usage |
|
92 |
;; |
|
93 |
esac |
|
94 |
done |
|
95 |
||
96 |
shift $(($OPTIND - 1)) |
|
97 |
||
98 |
||
99 |
## main |
|
100 |
||
101 |
[ -e "$ISABELLE_HOME/Admin/build" ] && { "$ISABELLE_HOME/Admin/build" jars || exit $?; } |
|
102 |
||
103 |
exec "$ISABELLE_TOOL" java isabelle.Build \ |
|
48447
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48425
diff
changeset
|
104 |
"$ALL_SESSIONS" "$BUILD_IMAGES" "$MAX_JOBS" "$LIST_ONLY" "$SYSTEM_MODE" "$VERBOSE" \ |
48340
6f4fc030882a
allow explicit specification of additional session directories;
wenzelm
parents:
48276
diff
changeset
|
105 |
"${MORE_DIRS[@]}" $'\n' "${BUILD_OPTIONS[@]}" $'\n' "$@" |