lib/Tools/usedir
author wenzelm
Sat, 30 May 2009 22:37:38 +0200
changeset 31307 7015fee8c3e8
parent 29435 a5f84ac14609
child 31317 1f5740424c69
permissions -rwxr-xr-x
ISABELLE_USEDIR_OPTIONS: proper word splitting of quoted options (via array variable and special expansion, cf. "$@");
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10555
2323ec838401 /usr/bin/env bash;
wenzelm
parents: 10511
diff changeset
     1
#!/usr/bin/env bash
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
     2
#
9788
wenzelm
parents: 9237
diff changeset
     3
# Author: Markus Wenzel, TU Muenchen
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
     4
#
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
     5
# DESCRIPTION: build object-logic or run examples
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
     6
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
     7
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
     8
## diagnostics
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
     9
10511
wenzelm
parents: 9788
diff changeset
    10
PRG="$(basename "$0")"
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    11
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    12
function usage()
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    13
{
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    14
  echo
28650
a7ba12e0d3b7 tuned usage line;
wenzelm
parents: 28502
diff changeset
    15
  echo "Usage: isabelle $PRG [OPTIONS] LOGIC NAME"
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    16
  echo
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    17
  echo "  Options are:"
17194
70d96933c210 added option -C: copy existing document directory;
wenzelm
parents: 17050
diff changeset
    18
  echo "    -C BOOL      copy existing document directory to -D PATH (default true)"
8197
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
    19
  echo "    -D PATH      dump generated document sources into PATH"
23972
9c418fa38f7e added usedir option -M: max threads;
wenzelm
parents: 18321
diff changeset
    20
  echo "    -M MAX       multithreading: maximum number of worker threads (default 1)"
6940
ee6640456cbb -B option;
wenzelm
parents: 6652
diff changeset
    21
  echo "    -P PATH      set path for remote theory browsing information"
29435
a5f84ac14609 added parallel_proofs flag (default true, cf. usedir option -Q), which can be disabled in low-memory situations;
wenzelm
parents: 29143
diff changeset
    22
  echo "    -Q BOOL      check proofs in parallel (default true)"
24118
464f260e5a20 multithreading trace: int;
wenzelm
parents: 24061
diff changeset
    23
  echo "    -T LEVEL     multithreading: trace level (default 0)"
17050
bfb571252817 added option -V VERSION;
wenzelm
parents: 15474
diff changeset
    24
  echo "    -V VERSION   declare alternative document VERSION"
6212
974310f9ca7d Session.init;
wenzelm
parents: 5034
diff changeset
    25
  echo "    -b           build mode (output heap image, using current dir)"
8359
124ad46105dd option -c: tell ML system to compress output image;
wenzelm
parents: 8241
diff changeset
    26
  echo "    -c BOOL      tell ML system to compress output image (default true)"
7737
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
    27
  echo "    -d FORMAT    build document as FORMAT (default false)"
15269
f856f4f3258f isatool usedir: ML root file can now be specified (previously hard-coded as ROOT.ML)
webertj
parents: 14981
diff changeset
    28
  echo "    -f NAME      use ML file NAME (default ROOT.ML)"
11847
82df5977101b option -g for document graph;
wenzelm
parents: 11577
diff changeset
    29
  echo "    -g BOOL      generate session graph image for document (default false)"
82df5977101b option -g for document graph;
wenzelm
parents: 11577
diff changeset
    30
  echo "    -i BOOL      generate HTML and graph browser information (default false)"
10562
fcd29e58c40c option -m;
wenzelm
parents: 10555
diff changeset
    31
  echo "    -m MODE      add print mode for output"
11535
7f4c5cdea239 Added new option for setting level of detail for proof objects.
berghofe
parents: 10585
diff changeset
    32
  echo "    -p LEVEL     set level of detail for proof objects"
6212
974310f9ca7d Session.init;
wenzelm
parents: 5034
diff changeset
    33
  echo "    -r           reset session path"
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    34
  echo "    -s NAME      override session NAME"
11577
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    35
  echo "    -v BOOL      be verbose (default false)"
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    36
  echo
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    37
  echo "  Build object-logic or run examples. Also creates browsing"
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    38
  echo "  information (HTML etc.) according to settings."
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    39
  echo
7461
94ae093f6706 usage: tell ISABELLE_USEDIR_OPTIONS;
wenzelm
parents: 7276
diff changeset
    40
  echo "  ISABELLE_USEDIR_OPTIONS=$ISABELLE_USEDIR_OPTIONS"
24957
50959112a4e1 usage: HOL_USEDIR_OPTIONS;
wenzelm
parents: 24118
diff changeset
    41
  echo "  HOL_USEDIR_OPTIONS=$HOL_USEDIR_OPTIONS"
7461
94ae093f6706 usage: tell ISABELLE_USEDIR_OPTIONS;
wenzelm
parents: 7276
diff changeset
    42
  echo
29089
8cffa980bd93 usage: echo ML settings as well;
wenzelm
parents: 28650
diff changeset
    43
  echo "  ML_PLATFORM=$ML_PLATFORM"
8cffa980bd93 usage: echo ML settings as well;
wenzelm
parents: 28650
diff changeset
    44
  echo "  ML_HOME=$ML_HOME"
8cffa980bd93 usage: echo ML settings as well;
wenzelm
parents: 28650
diff changeset
    45
  echo "  ML_SYSTEM=$ML_SYSTEM"
8cffa980bd93 usage: echo ML settings as well;
wenzelm
parents: 28650
diff changeset
    46
  echo "  ML_OPTIONS=$ML_OPTIONS"
8cffa980bd93 usage: echo ML settings as well;
wenzelm
parents: 28650
diff changeset
    47
  echo
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    48
  exit 1
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    49
}
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    50
11577
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    51
function fail()
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    52
{
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    53
  echo "$1" >&2
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    54
  exit 2
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    55
}
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    56
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    57
function check_bool()
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    58
{
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    59
  [ "$1" = true -o "$1" = false ] || fail "Bad boolean: \"$1\""
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    60
}
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    61
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    62
function check_number()
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    63
{
12912
0e144958cf27 tr: quote argument;
wenzelm
parents: 11949
diff changeset
    64
  [ -n "$1" -a -z "$(echo "$1" | tr -d '[0-9]')" ] || fail "Bad number: \"$1\""
11577
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    65
}
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    66
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    67
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    68
## process command line
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    69
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    70
# options
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    71
24061
68d2b6cf5194 added option -T (multithreading trace mode);
wenzelm
parents: 23972
diff changeset
    72
COPY_DUMP=true
8197
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
    73
DUMP=""
23972
9c418fa38f7e added usedir option -M: max threads;
wenzelm
parents: 18321
diff changeset
    74
MAXTHREADS="1"
8197
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
    75
RPATH=""
29435
a5f84ac14609 added parallel_proofs flag (default true, cf. usedir option -Q), which can be disabled in low-memory situations;
wenzelm
parents: 29143
diff changeset
    76
PARALLEL_PROOFS="true"
24118
464f260e5a20 multithreading trace: int;
wenzelm
parents: 24061
diff changeset
    77
TRACETHREADS="0"
17050
bfb571252817 added option -V VERSION;
wenzelm
parents: 15474
diff changeset
    78
DOCUMENT_VERSIONS=""
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    79
BUILD=""
8747
22580c8bc62f fixed -c default value;
wenzelm
parents: 8568
diff changeset
    80
COMPRESS=true
7737
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
    81
DOCUMENT=false
17050
bfb571252817 added option -V VERSION;
wenzelm
parents: 15474
diff changeset
    82
ROOT_FILE="ROOT.ML"
11847
82df5977101b option -g for document graph;
wenzelm
parents: 11577
diff changeset
    83
DOCUMENT_GRAPH=false
3747
cd9b6c86926c There is now one single option -i for generating theory browsing
berghofe
parents: 3636
diff changeset
    84
INFO=false
10562
fcd29e58c40c option -m;
wenzelm
parents: 10555
diff changeset
    85
MODES=""
6212
974310f9ca7d Session.init;
wenzelm
parents: 5034
diff changeset
    86
RESET=false
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    87
SESSION=""
11543
d61b913431c5 renamed `keep_derivs' to `proofs', and made an integer;
wenzelm
parents: 11535
diff changeset
    88
PROOFS=0
11577
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    89
VERBOSE=false
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    90
2917
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    91
function getoptions()
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    92
{
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    93
  OPTIND=1
29435
a5f84ac14609 added parallel_proofs flag (default true, cf. usedir option -Q), which can be disabled in low-memory situations;
wenzelm
parents: 29143
diff changeset
    94
  while getopts "C:D:M:P:Q:T:V:bc:d:f:g:i:m:p:rs:v:" OPT
2917
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    95
  do
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    96
    case "$OPT" in
17194
70d96933c210 added option -C: copy existing document directory;
wenzelm
parents: 17050
diff changeset
    97
      C)
70d96933c210 added option -C: copy existing document directory;
wenzelm
parents: 17050
diff changeset
    98
        check_bool "$OPTARG"
70d96933c210 added option -C: copy existing document directory;
wenzelm
parents: 17050
diff changeset
    99
        COPY_DUMP="$OPTARG"
70d96933c210 added option -C: copy existing document directory;
wenzelm
parents: 17050
diff changeset
   100
        ;;
8197
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
   101
      D)
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
   102
        DUMP="$OPTARG"
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
   103
        ;;
23972
9c418fa38f7e added usedir option -M: max threads;
wenzelm
parents: 18321
diff changeset
   104
      M)
25774
28fac5c2af54 added usedir -M max (alias for -M 0);
wenzelm
parents: 25235
diff changeset
   105
        if [ "$OPTARG" = max ]; then
29435
a5f84ac14609 added parallel_proofs flag (default true, cf. usedir option -Q), which can be disabled in low-memory situations;
wenzelm
parents: 29143
diff changeset
   106
          MAXTHREADS=0
a5f84ac14609 added parallel_proofs flag (default true, cf. usedir option -Q), which can be disabled in low-memory situations;
wenzelm
parents: 29143
diff changeset
   107
        else
25774
28fac5c2af54 added usedir -M max (alias for -M 0);
wenzelm
parents: 25235
diff changeset
   108
          check_number "$OPTARG"
28fac5c2af54 added usedir -M max (alias for -M 0);
wenzelm
parents: 25235
diff changeset
   109
          MAXTHREADS="$OPTARG"
29435
a5f84ac14609 added parallel_proofs flag (default true, cf. usedir option -Q), which can be disabled in low-memory situations;
wenzelm
parents: 29143
diff changeset
   110
        fi
23972
9c418fa38f7e added usedir option -M: max threads;
wenzelm
parents: 18321
diff changeset
   111
        ;;
8197
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
   112
      P)
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
   113
        RPATH="$OPTARG"
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
   114
        ;;
29435
a5f84ac14609 added parallel_proofs flag (default true, cf. usedir option -Q), which can be disabled in low-memory situations;
wenzelm
parents: 29143
diff changeset
   115
      Q)
a5f84ac14609 added parallel_proofs flag (default true, cf. usedir option -Q), which can be disabled in low-memory situations;
wenzelm
parents: 29143
diff changeset
   116
        PARALLEL_PROOFS="$OPTARG"
a5f84ac14609 added parallel_proofs flag (default true, cf. usedir option -Q), which can be disabled in low-memory situations;
wenzelm
parents: 29143
diff changeset
   117
        ;;
24061
68d2b6cf5194 added option -T (multithreading trace mode);
wenzelm
parents: 23972
diff changeset
   118
      T)
24118
464f260e5a20 multithreading trace: int;
wenzelm
parents: 24061
diff changeset
   119
        check_number "$OPTARG"
24061
68d2b6cf5194 added option -T (multithreading trace mode);
wenzelm
parents: 23972
diff changeset
   120
        TRACETHREADS="$OPTARG"
68d2b6cf5194 added option -T (multithreading trace mode);
wenzelm
parents: 23972
diff changeset
   121
        ;;
17050
bfb571252817 added option -V VERSION;
wenzelm
parents: 15474
diff changeset
   122
      V)
bfb571252817 added option -V VERSION;
wenzelm
parents: 15474
diff changeset
   123
        if [ -z "$DOCUMENT_VERSIONS" ]; then
bfb571252817 added option -V VERSION;
wenzelm
parents: 15474
diff changeset
   124
          DOCUMENT_VERSIONS="\"$OPTARG\""
bfb571252817 added option -V VERSION;
wenzelm
parents: 15474
diff changeset
   125
        else
bfb571252817 added option -V VERSION;
wenzelm
parents: 15474
diff changeset
   126
          DOCUMENT_VERSIONS="$DOCUMENT_VERSIONS, \"$OPTARG\""
bfb571252817 added option -V VERSION;
wenzelm
parents: 15474
diff changeset
   127
        fi
bfb571252817 added option -V VERSION;
wenzelm
parents: 15474
diff changeset
   128
        ;;
2917
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
   129
      b)
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
   130
        BUILD=true
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
   131
        ;;
8359
124ad46105dd option -c: tell ML system to compress output image;
wenzelm
parents: 8241
diff changeset
   132
      c)
11577
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
   133
        check_bool "$OPTARG"
8359
124ad46105dd option -c: tell ML system to compress output image;
wenzelm
parents: 8241
diff changeset
   134
        COMPRESS="$OPTARG"
124ad46105dd option -c: tell ML system to compress output image;
wenzelm
parents: 8241
diff changeset
   135
        ;;
7737
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
   136
      d)
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
   137
        DOCUMENT="$OPTARG"
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
   138
        ;;
15269
f856f4f3258f isatool usedir: ML root file can now be specified (previously hard-coded as ROOT.ML)
webertj
parents: 14981
diff changeset
   139
      f)
f856f4f3258f isatool usedir: ML root file can now be specified (previously hard-coded as ROOT.ML)
webertj
parents: 14981
diff changeset
   140
        ROOT_FILE="$OPTARG"
f856f4f3258f isatool usedir: ML root file can now be specified (previously hard-coded as ROOT.ML)
webertj
parents: 14981
diff changeset
   141
        ;;
11847
82df5977101b option -g for document graph;
wenzelm
parents: 11577
diff changeset
   142
      g)
82df5977101b option -g for document graph;
wenzelm
parents: 11577
diff changeset
   143
        check_bool "$OPTARG"
82df5977101b option -g for document graph;
wenzelm
parents: 11577
diff changeset
   144
        DOCUMENT_GRAPH="$OPTARG"
82df5977101b option -g for document graph;
wenzelm
parents: 11577
diff changeset
   145
        ;;
3747
cd9b6c86926c There is now one single option -i for generating theory browsing
berghofe
parents: 3636
diff changeset
   146
      i)
11577
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
   147
        check_bool "$OPTARG"
3747
cd9b6c86926c There is now one single option -i for generating theory browsing
berghofe
parents: 3636
diff changeset
   148
        INFO="$OPTARG"
2917
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
   149
        ;;
10562
fcd29e58c40c option -m;
wenzelm
parents: 10555
diff changeset
   150
      m)
fcd29e58c40c option -m;
wenzelm
parents: 10555
diff changeset
   151
        if [ -z "$MODES" ]; then
fcd29e58c40c option -m;
wenzelm
parents: 10555
diff changeset
   152
          MODES="\"$OPTARG\""
fcd29e58c40c option -m;
wenzelm
parents: 10555
diff changeset
   153
        else
10585
58a1ed1edb65 proper order of modes;
wenzelm
parents: 10562
diff changeset
   154
          MODES="\"$OPTARG\", $MODES"
10562
fcd29e58c40c option -m;
wenzelm
parents: 10555
diff changeset
   155
        fi
fcd29e58c40c option -m;
wenzelm
parents: 10555
diff changeset
   156
        ;;
11535
7f4c5cdea239 Added new option for setting level of detail for proof objects.
berghofe
parents: 10585
diff changeset
   157
      p)
11577
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
   158
        check_number "$OPTARG"
11543
d61b913431c5 renamed `keep_derivs' to `proofs', and made an integer;
wenzelm
parents: 11535
diff changeset
   159
        PROOFS="$OPTARG"
11535
7f4c5cdea239 Added new option for setting level of detail for proof objects.
berghofe
parents: 10585
diff changeset
   160
        ;;
6212
974310f9ca7d Session.init;
wenzelm
parents: 5034
diff changeset
   161
      r)
974310f9ca7d Session.init;
wenzelm
parents: 5034
diff changeset
   162
        RESET=true
974310f9ca7d Session.init;
wenzelm
parents: 5034
diff changeset
   163
        ;;
2917
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
   164
      s)
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
   165
        SESSION="$OPTARG"
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
   166
        ;;
11577
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
   167
      v)
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
   168
        check_bool "$OPTARG"
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
   169
        VERBOSE="$OPTARG"
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
   170
        ;;
2917
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
   171
      \?)
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
   172
        usage
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
   173
        ;;
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
   174
    esac
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
   175
  done
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
   176
}
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
   177
31307
7015fee8c3e8 ISABELLE_USEDIR_OPTIONS: proper word splitting of quoted options (via array variable and special expansion, cf. "$@");
wenzelm
parents: 29435
diff changeset
   178
eval "OPTIONS=($ISABELLE_USEDIR_OPTIONS)"
7015fee8c3e8 ISABELLE_USEDIR_OPTIONS: proper word splitting of quoted options (via array variable and special expansion, cf. "$@");
wenzelm
parents: 29435
diff changeset
   179
getoptions "${OPTIONS[@]}"
2917
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
   180
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
   181
getoptions "$@"
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
   182
shift $(($OPTIND - 1))
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
   183
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
   184
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
   185
# args
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
   186
9788
wenzelm
parents: 9237
diff changeset
   187
[ "$#" -ne 2 ] && usage
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
   188
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
   189
LOGIC="$1"; shift
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
   190
NAME="$1"; shift
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
   191
9788
wenzelm
parents: 9237
diff changeset
   192
[ -z "$SESSION" ] && SESSION=$(basename "$NAME")
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
   193
4419
wenzelm
parents: 4075
diff changeset
   194
wenzelm
parents: 4075
diff changeset
   195
wenzelm
parents: 4075
diff changeset
   196
## main
3636
3f2e55e5bacc Added some code for generating theory browsing data.
berghofe
parents: 3504
diff changeset
   197
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   198
# prepare browser info dir
4419
wenzelm
parents: 4075
diff changeset
   199
25235
04cb7e02ca38 split library index into templates
haftmann
parents: 25234
diff changeset
   200
if [ "$INFO" = "true" -a ! -f "$ISABELLE_BROWSER_INFO/index.html" ]; then
9788
wenzelm
parents: 9237
diff changeset
   201
  mkdir -p "$ISABELLE_BROWSER_INFO"
wenzelm
parents: 9237
diff changeset
   202
  cp "$ISABELLE_HOME/lib/logo/isabelle.gif" "$ISABELLE_BROWSER_INFO/isabelle.gif"
25234
2e91cc4ddf29 split library index into templates
haftmann
parents: 24957
diff changeset
   203
  cat "$ISABELLE_HOME/lib/html/library_index_header.template" \
2e91cc4ddf29 split library index into templates
haftmann
parents: 24957
diff changeset
   204
    "$ISABELLE_HOME/lib/html/library_index_content.template" \
2e91cc4ddf29 split library index into templates
haftmann
parents: 24957
diff changeset
   205
    "$ISABELLE_HOME/lib/html/library_index_footer.template"> "$ISABELLE_BROWSER_INFO/index.html"
3636
3f2e55e5bacc Added some code for generating theory browsing data.
berghofe
parents: 3504
diff changeset
   206
fi
3f2e55e5bacc Added some code for generating theory browsing data.
berghofe
parents: 3504
diff changeset
   207
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
   208
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   209
# prepare log dir
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   210
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   211
LOGDIR="$ISABELLE_OUTPUT/log"
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   212
mkdir -p "$LOGDIR"
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   213
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   214
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   215
# run isabelle
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   216
7737
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
   217
PARENT=$(basename "$LOGIC")
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
   218
11949
wenzelm
parents: 11907
diff changeset
   219
if [ -z "$BUILD" ]; then
wenzelm
parents: 11907
diff changeset
   220
  cd "$NAME" || fail "Bad session directory '$NAME'"
wenzelm
parents: 11907
diff changeset
   221
fi
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   222
11847
82df5977101b option -g for document graph;
wenzelm
parents: 11577
diff changeset
   223
if [ "$DOCUMENT" != false ]; then
8568
wenzelm
parents: 8565
diff changeset
   224
  DOC="$DOCUMENT"
wenzelm
parents: 8565
diff changeset
   225
else
wenzelm
parents: 8565
diff changeset
   226
  DOC=""
wenzelm
parents: 8565
diff changeset
   227
fi
7737
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
   228
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
   229
18321
3414557c2dda replaced lib/scripts/showtime by more advanced lib/scripts/timestart|stop.bash;
wenzelm
parents: 17194
diff changeset
   230
. "$ISABELLE_HOME/lib/scripts/timestart.bash"
6249
8bb90076cc7c Session.use_dir: check parent;
wenzelm
parents: 6212
diff changeset
   231
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
   232
if [ -n "$BUILD" ]; then
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   233
  ITEM="$SESSION"
11577
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
   234
  echo "Building $ITEM ..." >&2
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   235
  LOG="$LOGDIR/$ITEM"
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   236
8359
124ad46105dd option -c: tell ML system to compress output image;
wenzelm
parents: 8241
diff changeset
   237
  OPT_C=""
124ad46105dd option -c: tell ML system to compress output image;
wenzelm
parents: 8241
diff changeset
   238
  [ "$COMPRESS" = true ] && OPT_C="-c"
124ad46105dd option -c: tell ML system to compress output image;
wenzelm
parents: 8241
diff changeset
   239
28502
6b0e3e4e1891 replaced ISABELLE by ISABELLE_PROCESS;
wenzelm
parents: 25774
diff changeset
   240
  "$ISABELLE_PROCESS" \
29435
a5f84ac14609 added parallel_proofs flag (default true, cf. usedir option -Q), which can be disabled in low-memory situations;
wenzelm
parents: 29143
diff changeset
   241
    -e "Session.use_dir \"$ROOT_FILE\" true [$MODES] $RESET $INFO \"$DOC\" $DOCUMENT_GRAPH [$DOCUMENT_VERSIONS] \"$PARENT\" \"$SESSION\" ($COPY_DUMP, \"$DUMP\") \"$RPATH\" $PROOFS $VERBOSE $MAXTHREADS $TRACETHREADS $PARALLEL_PROOFS;" \
11577
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
   242
    $OPT_C -q -w $LOGIC $NAME > "$LOG"
9788
wenzelm
parents: 9237
diff changeset
   243
  RC="$?"
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
   244
else
9788
wenzelm
parents: 9237
diff changeset
   245
  ITEM=$(basename "$LOGIC")-"$SESSION"
11577
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
   246
  echo "Running $ITEM ..." >&2
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   247
  LOG="$LOGDIR/$ITEM"
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   248
28502
6b0e3e4e1891 replaced ISABELLE by ISABELLE_PROCESS;
wenzelm
parents: 25774
diff changeset
   249
  "$ISABELLE_PROCESS" \
29435
a5f84ac14609 added parallel_proofs flag (default true, cf. usedir option -Q), which can be disabled in low-memory situations;
wenzelm
parents: 29143
diff changeset
   250
    -e "Session.use_dir \"$ROOT_FILE\" false [$MODES] $RESET $INFO \"$DOC\" $DOCUMENT_GRAPH [$DOCUMENT_VERSIONS] \"$PARENT\" \"$SESSION\" ($COPY_DUMP, \"$DUMP\") \"$RPATH\" $PROOFS $VERBOSE $MAXTHREADS $TRACETHREADS $PARALLEL_PROOFS; quit();" \
11577
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
   251
    -r -q "$LOGIC" > "$LOG"
9788
wenzelm
parents: 9237
diff changeset
   252
  RC="$?"
6212
974310f9ca7d Session.init;
wenzelm
parents: 5034
diff changeset
   253
  cd ..
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
   254
fi
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   255
18321
3414557c2dda replaced lib/scripts/showtime by more advanced lib/scripts/timestart|stop.bash;
wenzelm
parents: 17194
diff changeset
   256
. "$ISABELLE_HOME/lib/scripts/timestop.bash"
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   257
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   258
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   259
# exit status
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   260
9788
wenzelm
parents: 9237
diff changeset
   261
if [ "$RC" -eq 0 ]; then
18321
3414557c2dda replaced lib/scripts/showtime by more advanced lib/scripts/timestart|stop.bash;
wenzelm
parents: 17194
diff changeset
   262
  echo "Finished $ITEM ($TIMES_REPORT)" >&2
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   263
  gzip --force "$LOG"
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   264
else
11577
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
   265
  { echo "$ITEM FAILED";
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
   266
    echo "(see also $LOG)";
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
   267
    echo; tail "$LOG"; echo; } >&2
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   268
fi
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   269
9788
wenzelm
parents: 9237
diff changeset
   270
exit "$RC"