lib/Tools/usedir
author wenzelm
Mon, 14 Feb 2000 12:23:08 +0100
changeset 8241 a55484a9b19f
parent 8218 6c4bec5cd2ac
child 8359 124ad46105dd
permissions -rwxr-xr-x
mkdir -p $ISABELLE_BROWSER_INFO;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3007
e5efa177ee0c removed -norc;
wenzelm
parents: 2917
diff changeset
     1
#!/bin/bash
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
     2
#
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
     3
# $Id$
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
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    10
PRG=$(basename $0)
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
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    15
  echo "Usage: $PRG LOGIC NAME"
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:"
8197
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
    18
  echo "    -D PATH      dump generated document sources into PATH"
6940
ee6640456cbb -B option;
wenzelm
parents: 6652
diff changeset
    19
  echo "    -P PATH      set path for remote theory browsing information"
6212
974310f9ca7d Session.init;
wenzelm
parents: 5034
diff changeset
    20
  echo "    -b           build mode (output heap image, using current dir)"
7737
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
    21
  echo "    -d FORMAT    build document as FORMAT (default false)"
3747
cd9b6c86926c There is now one single option -i for generating theory browsing
berghofe
parents: 3636
diff changeset
    22
  echo "    -i BOOL      generate theory browsing information,"
cd9b6c86926c There is now one single option -i for generating theory browsing
berghofe
parents: 3636
diff changeset
    23
  echo "                 i.e. HTML / graph data (default false)"
6212
974310f9ca7d Session.init;
wenzelm
parents: 5034
diff changeset
    24
  echo "    -r           reset session path"
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    25
  echo "    -s NAME      override session NAME"
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    26
  echo
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    27
  echo "  Build object-logic or run examples. Also creates browsing"
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    28
  echo "  information (HTML etc.) according to settings."
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    29
  echo
7461
94ae093f6706 usage: tell ISABELLE_USEDIR_OPTIONS;
wenzelm
parents: 7276
diff changeset
    30
  echo "  ISABELLE_USEDIR_OPTIONS=$ISABELLE_USEDIR_OPTIONS"
94ae093f6706 usage: tell ISABELLE_USEDIR_OPTIONS;
wenzelm
parents: 7276
diff changeset
    31
  echo
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    32
  exit 1
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    33
}
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    34
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    35
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    36
## process command line
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    37
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    38
# options
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    39
8197
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
    40
DUMP=""
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
    41
RPATH=""
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    42
BUILD=""
7737
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
    43
DOCUMENT=false
3747
cd9b6c86926c There is now one single option -i for generating theory browsing
berghofe
parents: 3636
diff changeset
    44
INFO=false
6212
974310f9ca7d Session.init;
wenzelm
parents: 5034
diff changeset
    45
RESET=false
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    46
SESSION=""
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    47
2917
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    48
function getoptions()
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    49
{
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    50
  OPTIND=1
8197
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
    51
  while getopts "D:P:bc:d:i:rs:" OPT
2917
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    52
  do
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    53
    case "$OPT" in
8197
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
    54
      D)
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
    55
        DUMP="$OPTARG"
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
    56
        ;;
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
    57
      P)
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
    58
        RPATH="$OPTARG"
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
    59
        ;;
2917
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    60
      b)
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    61
        BUILD=true
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    62
        ;;
7737
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
    63
      d)
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
    64
        DOCUMENT="$OPTARG"
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
    65
        ;;
3747
cd9b6c86926c There is now one single option -i for generating theory browsing
berghofe
parents: 3636
diff changeset
    66
      i)
cd9b6c86926c There is now one single option -i for generating theory browsing
berghofe
parents: 3636
diff changeset
    67
        INFO="$OPTARG"
2917
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    68
        ;;
6212
974310f9ca7d Session.init;
wenzelm
parents: 5034
diff changeset
    69
      r)
974310f9ca7d Session.init;
wenzelm
parents: 5034
diff changeset
    70
        RESET=true
974310f9ca7d Session.init;
wenzelm
parents: 5034
diff changeset
    71
        ;;
2917
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    72
      s)
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    73
        SESSION="$OPTARG"
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    74
        ;;
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    75
      \?)
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    76
        usage
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    77
        ;;
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    78
    esac
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    79
  done
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    80
}
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    81
2917
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    82
getoptions $ISABELLE_USEDIR_OPTIONS
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    83
c7411fce37e4 added -g, -h options;
wenzelm
parents: 2849
diff changeset
    84
getoptions "$@"
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    85
shift $(($OPTIND - 1))
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    86
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    87
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    88
# args
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    89
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    90
[ $# -ne 2 ] && usage
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    91
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    92
LOGIC="$1"; shift
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    93
NAME="$1"; shift
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    94
4419
wenzelm
parents: 4075
diff changeset
    95
[ -z "$SESSION" ] && SESSION=$(basename $NAME)
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
    96
4419
wenzelm
parents: 4075
diff changeset
    97
wenzelm
parents: 4075
diff changeset
    98
wenzelm
parents: 4075
diff changeset
    99
## main
3636
3f2e55e5bacc Added some code for generating theory browsing data.
berghofe
parents: 3504
diff changeset
   100
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   101
# prepare browser info dir
4419
wenzelm
parents: 4075
diff changeset
   102
4586
wenzelm
parents: 4492
diff changeset
   103
if [ "$INFO" = "true" -a ! -f $ISABELLE_BROWSER_INFO/index.html ]; then
4419
wenzelm
parents: 4075
diff changeset
   104
8241
a55484a9b19f mkdir -p $ISABELLE_BROWSER_INFO;
wenzelm
parents: 8218
diff changeset
   105
  mkdir -p $ISABELLE_BROWSER_INFO
8218
6c4bec5cd2ac eliminated gif dir;
wenzelm
parents: 8197
diff changeset
   106
  cp $ISABELLE_HOME/lib/logo/isabelle.gif $ISABELLE_BROWSER_INFO/isabelle.gif
3747
cd9b6c86926c There is now one single option -i for generating theory browsing
berghofe
parents: 3636
diff changeset
   107
  cp $ISABELLE_HOME/lib/html/index1.html $ISABELLE_BROWSER_INFO/index.html
4419
wenzelm
parents: 4075
diff changeset
   108
3636
3f2e55e5bacc Added some code for generating theory browsing data.
berghofe
parents: 3504
diff changeset
   109
  mkdir -p $ISABELLE_BROWSER_INFO/graph
3f2e55e5bacc Added some code for generating theory browsing data.
berghofe
parents: 3504
diff changeset
   110
  cp $ISABELLE_HOME/lib/html/index2.html $ISABELLE_BROWSER_INFO/graph/index.html
3f2e55e5bacc Added some code for generating theory browsing data.
berghofe
parents: 3504
diff changeset
   111
  mkdir $ISABELLE_BROWSER_INFO/graph/GraphBrowser
3f2e55e5bacc Added some code for generating theory browsing data.
berghofe
parents: 3504
diff changeset
   112
  mkdir $ISABELLE_BROWSER_INFO/graph/awtUtilities
4419
wenzelm
parents: 4075
diff changeset
   113
  cp $ISABELLE_HOME/lib/browser/GraphBrowser/*.class $ISABELLE_BROWSER_INFO/graph/GraphBrowser
wenzelm
parents: 4075
diff changeset
   114
  cp $ISABELLE_HOME/lib/browser/awtUtilities/*.class $ISABELLE_BROWSER_INFO/graph/awtUtilities
wenzelm
parents: 4075
diff changeset
   115
3636
3f2e55e5bacc Added some code for generating theory browsing data.
berghofe
parents: 3504
diff changeset
   116
fi
3f2e55e5bacc Added some code for generating theory browsing data.
berghofe
parents: 3504
diff changeset
   117
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
   118
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   119
# prepare log dir
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   120
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   121
LOGDIR="$ISABELLE_OUTPUT/log"
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   122
mkdir -p "$LOGDIR"
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   123
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   124
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   125
# run isabelle
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   126
7737
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
   127
PARENT=$(basename "$LOGIC")
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
   128
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
   129
[ -z "$BUILD" ] && cd "$NAME"
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   130
7796
624f609e10d7 removed -c option;
wenzelm
parents: 7787
diff changeset
   131
DOC=""
624f609e10d7 removed -c option;
wenzelm
parents: 7787
diff changeset
   132
[ "$DOCUMENT" != false -a -d document ] && DOC="$DOCUMENT"
7737
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
   133
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
   134
acaf55bee03e document preparation options: -c -d;
wenzelm
parents: 7461
diff changeset
   135
SECONDS=0
6249
8bb90076cc7c Session.use_dir: check parent;
wenzelm
parents: 6212
diff changeset
   136
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
   137
if [ -n "$BUILD" ]; then
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   138
  ITEM="$SESSION"
7275
3a001f2148f7 removed -m option;
wenzelm
parents: 7259
diff changeset
   139
  echo "Building $ITEM ..."
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   140
  LOG="$LOGDIR/$ITEM"
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   141
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   142
  $ISABELLE \
8197
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
   143
    -e "Session.use_dir $RESET $INFO \"$DOC\" \"$PARENT\" \"$SESSION\" \"$DUMP\" \"$RPATH\";" \
4492
ab441d89a2cb stderr to $LOG;
wenzelm
parents: 4451
diff changeset
   144
    -q -w $LOGIC $NAME > $LOG 2>&1
6249
8bb90076cc7c Session.use_dir: check parent;
wenzelm
parents: 6212
diff changeset
   145
  RC=$?
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
   146
else
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   147
  ITEM=$(basename $LOGIC)-"$SESSION"
7275
3a001f2148f7 removed -m option;
wenzelm
parents: 7259
diff changeset
   148
  echo "Running $ITEM ..."
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   149
  LOG="$LOGDIR/$ITEM"
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   150
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   151
  $ISABELLE \
8197
baab8e487fad -D PATH: dump generated document sources into PATH;
wenzelm
parents: 7888
diff changeset
   152
    -e "Session.use_dir $RESET $INFO \"$DOC\" \"$PARENT\" \"$SESSION\" \"$DUMP\" \"$RPATH\"; quit();" \
4492
ab441d89a2cb stderr to $LOG;
wenzelm
parents: 4451
diff changeset
   153
    -r -q $LOGIC > $LOG 2>&1
6249
8bb90076cc7c Session.use_dir: check parent;
wenzelm
parents: 6212
diff changeset
   154
  RC=$?
6212
974310f9ca7d Session.init;
wenzelm
parents: 5034
diff changeset
   155
  cd ..
2808
e8a224e41b9f usedir -- build object-logic or run examples;
wenzelm
parents:
diff changeset
   156
fi
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   157
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   158
ELAPSED=$($ISABELLE_HOME/lib/scripts/showtime $SECONDS)
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   159
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   160
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   161
# exit status
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   162
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   163
if [ $RC -eq 0 ]; then
7275
3a001f2148f7 removed -m option;
wenzelm
parents: 7259
diff changeset
   164
  echo "Finished $ITEM ($ELAPSED elapsed time)"
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   165
  gzip --force "$LOG"
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   166
else
7259
e75aa311788c tuned messages;
wenzelm
parents: 7226
diff changeset
   167
  echo "$ITEM FAILED"
4451
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   168
  echo "(see also $LOG)"
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   169
  echo; tail $LOG; echo
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   170
fi
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   171
f9e3e9f1af61 log file;
wenzelm
parents: 4419
diff changeset
   172
exit $RC