lib/Tools/usedir
author hoelzl
Mon, 06 Dec 2010 19:54:48 +0100
changeset 41024 ba961a606c67
parent 34261 8e36b3ac6083
child 41703 d27950860514
permissions -rwxr-xr-x
move coercions to appropriate places
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"
24118
464f260e5a20 multithreading trace: int;
wenzelm
parents: 24061
diff changeset
    22
  echo "    -T LEVEL     multithreading: trace level (default 0)"
17050
bfb571252817 added option -V VERSION;
wenzelm
parents: 15474
diff changeset
    23
  echo "    -V VERSION   declare alternative document VERSION"
6212
974310f9ca7d Session.init;
wenzelm
parents: 5034
diff changeset
    24
  echo "    -b           build mode (output heap image, using current dir)"
7737
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
    25
  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
    26
  echo "    -f NAME      use ML file NAME (default ROOT.ML)"
11847
82df5977101b option -g for document graph;
wenzelm
parents: 11577
diff changeset
    27
  echo "    -g BOOL      generate session graph image for document (default false)"
82df5977101b option -g for document graph;
wenzelm
parents: 11577
diff changeset
    28
  echo "    -i BOOL      generate HTML and graph browser information (default false)"
10562
fcd29e58c40c option -m;
wenzelm
parents: 10555
diff changeset
    29
  echo "    -m MODE      add print mode for output"
32061
11f8ee55662d parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents: 31688
diff changeset
    30
  echo "    -p LEVEL     set level of detail for proof objects (default 0)"
11f8ee55662d parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents: 31688
diff changeset
    31
  echo "    -q LEVEL     set level of parallel proof checking (default 1)"
6212
974310f9ca7d Session.init;
wenzelm
parents: 5034
diff changeset
    32
  echo "    -r           reset session path"
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    33
  echo "    -s NAME      override session NAME"
31688
f27cc190083b usedir: internal timing option;
wenzelm
parents: 31317
diff changeset
    34
  echo "    -t BOOL      internal session timing (default false)"
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"
94ae093f6706 usage: tell ISABELLE_USEDIR_OPTIONS;
wenzelm
parents: 7276
diff changeset
    41
  echo
29089
8cffa980bd93 usage: echo ML settings as well;
wenzelm
parents: 28650
diff changeset
    42
  echo "  ML_PLATFORM=$ML_PLATFORM"
8cffa980bd93 usage: echo ML settings as well;
wenzelm
parents: 28650
diff changeset
    43
  echo "  ML_HOME=$ML_HOME"
8cffa980bd93 usage: echo ML settings as well;
wenzelm
parents: 28650
diff changeset
    44
  echo "  ML_SYSTEM=$ML_SYSTEM"
8cffa980bd93 usage: echo ML settings as well;
wenzelm
parents: 28650
diff changeset
    45
  echo "  ML_OPTIONS=$ML_OPTIONS"
8cffa980bd93 usage: echo ML settings as well;
wenzelm
parents: 28650
diff changeset
    46
  echo
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    47
  exit 1
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    48
}
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    49
11577
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    50
function fail()
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    51
{
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    52
  echo "$1" >&2
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    53
  exit 2
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    54
}
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    55
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    56
function check_bool()
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    57
{
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    58
  [ "$1" = true -o "$1" = false ] || fail "Bad boolean: \"$1\""
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    59
}
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    60
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    61
function check_number()
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    62
{
12912
0e144958cf27 tr: quote argument;
wenzelm
parents: 11949
diff changeset
    63
  [ -n "$1" -a -z "$(echo "$1" | tr -d '[0-9]')" ] || fail "Bad number: \"$1\""
11577
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    64
}
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    65
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    66
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    67
## process command line
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    68
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    69
# options
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    70
24061
68d2b6cf5194 added option -T (multithreading trace mode);
wenzelm
parents: 23972
diff changeset
    71
COPY_DUMP=true
8197
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
    72
DUMP=""
23972
9c418fa38f7e added usedir option -M: max threads;
wenzelm
parents: 18321
diff changeset
    73
MAXTHREADS="1"
8197
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
    74
RPATH=""
24118
464f260e5a20 multithreading trace: int;
wenzelm
parents: 24061
diff changeset
    75
TRACETHREADS="0"
17050
bfb571252817 added option -V VERSION;
wenzelm
parents: 15474
diff changeset
    76
DOCUMENT_VERSIONS=""
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    77
BUILD=""
7737
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
    78
DOCUMENT=false
17050
bfb571252817 added option -V VERSION;
wenzelm
parents: 15474
diff changeset
    79
ROOT_FILE="ROOT.ML"
11847
82df5977101b option -g for document graph;
wenzelm
parents: 11577
diff changeset
    80
DOCUMENT_GRAPH=false
3747
cd9b6c86926c There is now one single option -i for generating theory browsing
berghofe
parents: 3636
diff changeset
    81
INFO=false
10562
fcd29e58c40c option -m;
wenzelm
parents: 10555
diff changeset
    82
MODES=""
6212
974310f9ca7d Session.init;
wenzelm
parents: 5034
diff changeset
    83
RESET=false
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    84
SESSION=""
32061
11f8ee55662d parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents: 31688
diff changeset
    85
PROOFS="0"
11f8ee55662d parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents: 31688
diff changeset
    86
PARALLEL_PROOFS="1"
31688
f27cc190083b usedir: internal timing option;
wenzelm
parents: 31317
diff changeset
    87
TIMING=false
11577
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
    88
VERBOSE=false
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    89
2917
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    90
function getoptions()
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    91
{
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    92
  OPTIND=1
32061
11f8ee55662d parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents: 31688
diff changeset
    93
  while getopts "C:D:M:P:T:V:bd:f:g:i:m:p:q:rs:t:v:" OPT
2917
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    94
  do
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    95
    case "$OPT" in
17194
70d96933c210 added option -C: copy existing document directory;
wenzelm
parents: 17050
diff changeset
    96
      C)
70d96933c210 added option -C: copy existing document directory;
wenzelm
parents: 17050
diff changeset
    97
        check_bool "$OPTARG"
70d96933c210 added option -C: copy existing document directory;
wenzelm
parents: 17050
diff changeset
    98
        COPY_DUMP="$OPTARG"
70d96933c210 added option -C: copy existing document directory;
wenzelm
parents: 17050
diff changeset
    99
        ;;
8197
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
   100
      D)
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
   101
        DUMP="$OPTARG"
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
   102
        ;;
23972
9c418fa38f7e added usedir option -M: max threads;
wenzelm
parents: 18321
diff changeset
   103
      M)
25774
28fac5c2af54 added usedir -M max (alias for -M 0);
wenzelm
parents: 25235
diff changeset
   104
        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
   105
          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
   106
        else
25774
28fac5c2af54 added usedir -M max (alias for -M 0);
wenzelm
parents: 25235
diff changeset
   107
          check_number "$OPTARG"
28fac5c2af54 added usedir -M max (alias for -M 0);
wenzelm
parents: 25235
diff changeset
   108
          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
   109
        fi
23972
9c418fa38f7e added usedir option -M: max threads;
wenzelm
parents: 18321
diff changeset
   110
        ;;
8197
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
   111
      P)
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
   112
        RPATH="$OPTARG"
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
   113
        ;;
24061
68d2b6cf5194 added option -T (multithreading trace mode);
wenzelm
parents: 23972
diff changeset
   114
      T)
24118
464f260e5a20 multithreading trace: int;
wenzelm
parents: 24061
diff changeset
   115
        check_number "$OPTARG"
24061
68d2b6cf5194 added option -T (multithreading trace mode);
wenzelm
parents: 23972
diff changeset
   116
        TRACETHREADS="$OPTARG"
68d2b6cf5194 added option -T (multithreading trace mode);
wenzelm
parents: 23972
diff changeset
   117
        ;;
17050
bfb571252817 added option -V VERSION;
wenzelm
parents: 15474
diff changeset
   118
      V)
bfb571252817 added option -V VERSION;
wenzelm
parents: 15474
diff changeset
   119
        if [ -z "$DOCUMENT_VERSIONS" ]; then
bfb571252817 added option -V VERSION;
wenzelm
parents: 15474
diff changeset
   120
          DOCUMENT_VERSIONS="\"$OPTARG\""
bfb571252817 added option -V VERSION;
wenzelm
parents: 15474
diff changeset
   121
        else
bfb571252817 added option -V VERSION;
wenzelm
parents: 15474
diff changeset
   122
          DOCUMENT_VERSIONS="$DOCUMENT_VERSIONS, \"$OPTARG\""
bfb571252817 added option -V VERSION;
wenzelm
parents: 15474
diff changeset
   123
        fi
bfb571252817 added option -V VERSION;
wenzelm
parents: 15474
diff changeset
   124
        ;;
2917
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
   125
      b)
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
   126
        BUILD=true
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
   127
        ;;
7737
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
   128
      d)
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
   129
        DOCUMENT="$OPTARG"
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
   130
        ;;
15269
f856f4f3258f isatool usedir: ML root file can now be specified (previously hard-coded as ROOT.ML)
webertj
parents: 14981
diff changeset
   131
      f)
f856f4f3258f isatool usedir: ML root file can now be specified (previously hard-coded as ROOT.ML)
webertj
parents: 14981
diff changeset
   132
        ROOT_FILE="$OPTARG"
f856f4f3258f isatool usedir: ML root file can now be specified (previously hard-coded as ROOT.ML)
webertj
parents: 14981
diff changeset
   133
        ;;
11847
82df5977101b option -g for document graph;
wenzelm
parents: 11577
diff changeset
   134
      g)
82df5977101b option -g for document graph;
wenzelm
parents: 11577
diff changeset
   135
        check_bool "$OPTARG"
82df5977101b option -g for document graph;
wenzelm
parents: 11577
diff changeset
   136
        DOCUMENT_GRAPH="$OPTARG"
82df5977101b option -g for document graph;
wenzelm
parents: 11577
diff changeset
   137
        ;;
3747
cd9b6c86926c There is now one single option -i for generating theory browsing
berghofe
parents: 3636
diff changeset
   138
      i)
11577
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
   139
        check_bool "$OPTARG"
3747
cd9b6c86926c There is now one single option -i for generating theory browsing
berghofe
parents: 3636
diff changeset
   140
        INFO="$OPTARG"
2917
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
   141
        ;;
10562
fcd29e58c40c option -m;
wenzelm
parents: 10555
diff changeset
   142
      m)
fcd29e58c40c option -m;
wenzelm
parents: 10555
diff changeset
   143
        if [ -z "$MODES" ]; then
fcd29e58c40c option -m;
wenzelm
parents: 10555
diff changeset
   144
          MODES="\"$OPTARG\""
fcd29e58c40c option -m;
wenzelm
parents: 10555
diff changeset
   145
        else
10585
58a1ed1edb65 proper order of modes;
wenzelm
parents: 10562
diff changeset
   146
          MODES="\"$OPTARG\", $MODES"
10562
fcd29e58c40c option -m;
wenzelm
parents: 10555
diff changeset
   147
        fi
fcd29e58c40c option -m;
wenzelm
parents: 10555
diff changeset
   148
        ;;
11535
7f4c5cdea239 Added new option for setting level of detail for proof objects.
berghofe
parents: 10585
diff changeset
   149
      p)
11577
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
   150
        check_number "$OPTARG"
11543
d61b913431c5 renamed `keep_derivs' to `proofs', and made an integer;
wenzelm
parents: 11535
diff changeset
   151
        PROOFS="$OPTARG"
11535
7f4c5cdea239 Added new option for setting level of detail for proof objects.
berghofe
parents: 10585
diff changeset
   152
        ;;
32061
11f8ee55662d parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents: 31688
diff changeset
   153
      q)
11f8ee55662d parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents: 31688
diff changeset
   154
        check_number "$OPTARG"
11f8ee55662d parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents: 31688
diff changeset
   155
        PARALLEL_PROOFS="$OPTARG"
11f8ee55662d parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents: 31688
diff changeset
   156
        ;;
6212
974310f9ca7d Session.init;
wenzelm
parents: 5034
diff changeset
   157
      r)
974310f9ca7d Session.init;
wenzelm
parents: 5034
diff changeset
   158
        RESET=true
974310f9ca7d Session.init;
wenzelm
parents: 5034
diff changeset
   159
        ;;
2917
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
   160
      s)
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
   161
        SESSION="$OPTARG"
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
   162
        ;;
31688
f27cc190083b usedir: internal timing option;
wenzelm
parents: 31317
diff changeset
   163
      t)
f27cc190083b usedir: internal timing option;
wenzelm
parents: 31317
diff changeset
   164
        check_bool "$OPTARG"
f27cc190083b usedir: internal timing option;
wenzelm
parents: 31317
diff changeset
   165
        TIMING="$OPTARG"
f27cc190083b usedir: internal timing option;
wenzelm
parents: 31317
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
28502
6b0e3e4e1891 replaced ISABELLE by ISABELLE_PROCESS;
wenzelm
parents: 25774
diff changeset
   237
  "$ISABELLE_PROCESS" \
31688
f27cc190083b usedir: internal timing option;
wenzelm
parents: 31317
diff changeset
   238
    -e "Session.use_dir \"$ITEM\" \"$ROOT_FILE\" true [$MODES] $RESET $INFO \"$DOC\" $DOCUMENT_GRAPH [$DOCUMENT_VERSIONS] \"$PARENT\" \"$SESSION\" ($COPY_DUMP, \"$DUMP\") \"$RPATH\" $PROOFS $TIMING $VERBOSE $MAXTHREADS $TRACETHREADS $PARALLEL_PROOFS;" \
31317
1f5740424c69 removed "compress" option from isabelle-process and isabelle usedir -- this is always enabled;
wenzelm
parents: 31307
diff changeset
   239
    -q -w $LOGIC $NAME > "$LOG"
9788
wenzelm
parents: 9237
diff changeset
   240
  RC="$?"
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
   241
else
9788
wenzelm
parents: 9237
diff changeset
   242
  ITEM=$(basename "$LOGIC")-"$SESSION"
11577
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
   243
  echo "Running $ITEM ..." >&2
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   244
  LOG="$LOGDIR/$ITEM"
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   245
28502
6b0e3e4e1891 replaced ISABELLE by ISABELLE_PROCESS;
wenzelm
parents: 25774
diff changeset
   246
  "$ISABELLE_PROCESS" \
31688
f27cc190083b usedir: internal timing option;
wenzelm
parents: 31317
diff changeset
   247
    -e "Session.use_dir \"$ITEM\" \"$ROOT_FILE\" false [$MODES] $RESET $INFO \"$DOC\" $DOCUMENT_GRAPH [$DOCUMENT_VERSIONS] \"$PARENT\" \"$SESSION\" ($COPY_DUMP, \"$DUMP\") \"$RPATH\" $PROOFS $TIMING $VERBOSE $MAXTHREADS $TRACETHREADS $PARALLEL_PROOFS; quit();" \
11577
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
   248
    -r -q "$LOGIC" > "$LOG"
9788
wenzelm
parents: 9237
diff changeset
   249
  RC="$?"
6212
974310f9ca7d Session.init;
wenzelm
parents: 5034
diff changeset
   250
  cd ..
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
   251
fi
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   252
18321
3414557c2dda replaced lib/scripts/showtime by more advanced lib/scripts/timestart|stop.bash;
wenzelm
parents: 17194
diff changeset
   253
. "$ISABELLE_HOME/lib/scripts/timestop.bash"
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   254
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   255
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   256
# exit status
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   257
9788
wenzelm
parents: 9237
diff changeset
   258
if [ "$RC" -eq 0 ]; then
18321
3414557c2dda replaced lib/scripts/showtime by more advanced lib/scripts/timestart|stop.bash;
wenzelm
parents: 17194
diff changeset
   259
  echo "Finished $ITEM ($TIMES_REPORT)" >&2
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   260
  gzip --force "$LOG"
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   261
else
11577
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
   262
  { echo "$ITEM FAILED";
68323aa9575d option -v;
wenzelm
parents: 11543
diff changeset
   263
    echo "(see also $LOG)";
34261
8e36b3ac6083 slightly shorter tail (again) -- theory loader produces less warning spam (cf. 2524c1bbd087);
wenzelm
parents: 34238
diff changeset
   264
    echo; tail -20 "$LOG"; echo; } >&2
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   265
fi
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   266
9788
wenzelm
parents: 9237
diff changeset
   267
exit "$RC"