Admin/makebin
author wenzelm
Fri Dec 29 17:24:46 2006 +0100 (2006-12-29)
changeset 21935 4e20a5397b57
parent 17660 94bbe14c088e
child 23137 ae4110f7f88f
permissions -rwxr-xr-x
renamed project to subgraph, improved presentation, avoided unnecessary evaluation of predicate;
wenzelm@12721
     1
#!/usr/bin/env bash
wenzelm@10082
     2
#
wenzelm@10082
     3
# $Id$
wenzelm@10082
     4
#
wenzelm@10082
     5
# makebin -- make Isabelle logic images for current platform.
wenzelm@10082
     6
wenzelm@10082
     7
wenzelm@10082
     8
## global settings
wenzelm@10082
     9
wenzelm@12427
    10
TMP="/var/tmp/isabelle-makebin$$"
wenzelm@10082
    11
wenzelm@10082
    12
TAR=tar
wenzelm@10082
    13
type -path gtar >/dev/null && TAR=gtar
wenzelm@10082
    14
wenzelm@10097
    15
export THIS_IS_ISABELLE_BUILD=true
wenzelm@10097
    16
wenzelm@10082
    17
wenzelm@10082
    18
## diagnostics
wenzelm@10082
    19
wenzelm@10082
    20
PRG=$(basename "$0")
wenzelm@10082
    21
wenzelm@10082
    22
function usage()
wenzelm@10082
    23
{
wenzelm@10082
    24
  echo
wenzelm@12827
    25
  echo "Usage: $PRG [OPTIONS] ARCHIVE"
wenzelm@10082
    26
  echo
wenzelm@12827
    27
  echo "  Options are:"
wenzelm@13001
    28
  echo "    -l           produce library"
wenzelm@13001
    29
  echo "    -n           dry run"
wenzelm@12827
    30
  echo
wenzelm@12827
    31
  echo "  Precompile Isabelle for the current platform."
wenzelm@10082
    32
  echo
wenzelm@10082
    33
  exit 1
wenzelm@10082
    34
}
wenzelm@10082
    35
wenzelm@10082
    36
function fail()
wenzelm@10082
    37
{
wenzelm@10082
    38
  echo "$1" >&2
wenzelm@10082
    39
  exit 2
wenzelm@10082
    40
}
wenzelm@10082
    41
wenzelm@10082
    42
wenzelm@10082
    43
## process command line
wenzelm@10082
    44
wenzelm@12827
    45
# options
wenzelm@12827
    46
wenzelm@12827
    47
DO_LIBRARY=""
wenzelm@13001
    48
DRY_RUN=""
wenzelm@12827
    49
wenzelm@13001
    50
while getopts "ln" OPT
wenzelm@12827
    51
do
wenzelm@12827
    52
  case "$OPT" in
wenzelm@12827
    53
    l)
wenzelm@12827
    54
      DO_LIBRARY=true
wenzelm@12827
    55
      ;;
wenzelm@13001
    56
    n)
wenzelm@13001
    57
      DRY_RUN=true
wenzelm@12827
    58
      ;;
wenzelm@12827
    59
    \?)
wenzelm@12827
    60
      usage
wenzelm@12827
    61
      ;;
wenzelm@12827
    62
  esac
wenzelm@12827
    63
done
wenzelm@12827
    64
wenzelm@12827
    65
shift $(($OPTIND - 1))
wenzelm@12827
    66
wenzelm@12827
    67
wenzelm@12827
    68
# args
wenzelm@12827
    69
wenzelm@10082
    70
[ "$#" -gt 1 ] && usage
wenzelm@10082
    71
wenzelm@10082
    72
ARCHIVE="$1"; shift
wenzelm@10082
    73
wenzelm@10082
    74
wenzelm@10082
    75
## main
wenzelm@10082
    76
wenzelm@10082
    77
[ ! -f "$ARCHIVE" ] && fail "Bad archive file $ARCHIVE"
wenzelm@10082
    78
ARCHIVE_BASE=$(basename "$ARCHIVE")
wenzelm@10082
    79
ARCHIVE_DIR=$(cd $(dirname "$ARCHIVE"); echo "$PWD")
wenzelm@10082
    80
ARCHIVE_FULL="$ARCHIVE_DIR/$ARCHIVE_BASE"
wenzelm@10082
    81
wenzelm@10082
    82
ISABELLE_NAME=$(basename "$ARCHIVE_BASE" .tar.gz)
wenzelm@10082
    83
ISABELLE_HOME="$TMP/$ISABELLE_NAME"
wenzelm@10082
    84
wenzelm@10082
    85
wenzelm@10082
    86
# build logics
wenzelm@10082
    87
wenzelm@10082
    88
mkdir "$TMP" || fail "Cannot create directory $TMP"
wenzelm@10082
    89
wenzelm@10082
    90
cd "$TMP"
wenzelm@10087
    91
"$TAR" xzf "$ARCHIVE_FULL"
wenzelm@10082
    92
cd "$ISABELLE_NAME"
wenzelm@10082
    93
kleing@14633
    94
# FIXME: ugly hack to get proper HOL4 image
kleing@14633
    95
# needs HOL4 proof terms installed in ~/isabelle/proofs
kleing@14633
    96
# desperately needs fix for next release!
kleing@14633
    97
cat > src/HOL/Import/HOL/ROOT.ML <<EOF
kleing@14633
    98
with_path ".." use_thy "HOL4Compat";
kleing@14633
    99
with_path ".." use_thy "HOL4Syntax";
kleing@14633
   100
use_thy "HOL4Prob";
kleing@14633
   101
use_thy "HOL4";
kleing@14633
   102
EOF
kleing@14633
   103
wenzelm@17575
   104
perl -pi \
wenzelm@17575
   105
  -e 's:^ISABELLE_USEDIR_OPTIONS=.*$:ISABELLE_USEDIR_OPTIONS="-p 1":;' \
wenzelm@17575
   106
  -e 's:^HOL_USEDIR_OPTIONS=.*$:HOL_USEDIR_OPTIONS="-p 2":;' \
wenzelm@17575
   107
  etc/settings
wenzelm@17575
   108
wenzelm@13001
   109
if [ -n "$DO_LIBRARY" ]; then
wenzelm@17575
   110
  perl -pi -e 's:^ISABELLE_USEDIR_OPTIONS=.*$:ISABELLE_USEDIR_OPTIONS="-p 1 -i true -d pdf -V outline=/proof,/ML":;' \
wenzelm@13001
   111
    etc/settings
wenzelm@13001
   112
fi
wenzelm@11576
   113
wenzelm@10082
   114
ISABELLE_HOME_USER=$(./bin/isatool getenv -b ISABELLE_HOME_USER)
wenzelm@10082
   115
[ -f "$ISABELLE_HOME_USER/etc/settings" ] && \
wenzelm@10082
   116
  echo "### WARNING!  Personal Isabelle settings present. " >&2
wenzelm@10082
   117
wenzelm@10082
   118
COMPILER=$(./bin/isatool getenv -b ML_IDENTIFIER)
wenzelm@10082
   119
PLATFORM=$(./bin/isatool getenv -b ML_PLATFORM)
wenzelm@10082
   120
wenzelm@13001
   121
if [ -n "$DRY_RUN" ]; then
wenzelm@12827
   122
  mkdir -p "heaps/$COMPILER/log"
wenzelm@10082
   123
  touch "heaps/$COMPILER/HOL"
wenzelm@12827
   124
  touch "heaps/$COMPILER/log/HOL.gz"
kleing@14024
   125
  touch "heaps/$COMPILER/HOL-Complex"
kleing@14024
   126
  touch "heaps/$COMPILER/log/HOL-Complex.gz"
kleing@14633
   127
  touch "heaps/$COMPILER/HOL4"
kleing@14633
   128
  touch "heaps/$COMPILER/log/HOL4.gz"
wenzelm@10082
   129
  touch "heaps/$COMPILER/ZF"
wenzelm@12827
   130
  touch "heaps/$COMPILER/log/ZF.gz"
wenzelm@12827
   131
  mkdir browser_info
wenzelm@13001
   132
elif [ -n "$DO_LIBRARY" ]; then
wenzelm@13001
   133
  ./build -bait
wenzelm@10082
   134
else
kleing@14024
   135
  ./build -b -m HOL-Complex HOL
wenzelm@17575
   136
  ./build -b -m HOL4 HOL
wenzelm@10082
   137
  ./build -b ZF
wenzelm@10082
   138
  rm -f "heaps/$COMPILER/Pure" "heaps/$COMPILER/FOL"
wenzelm@10082
   139
fi
wenzelm@10082
   140
wenzelm@10082
   141
wenzelm@10082
   142
# prepare result
wenzelm@10082
   143
wenzelm@10082
   144
cd "$TMP"
wenzelm@10082
   145
wenzelm@10082
   146
chmod -R g=o "$TMP"
wenzelm@10082
   147
chgrp -R isabelle "$TMP"
wenzelm@10082
   148
wenzelm@13001
   149
if [ -n "$DO_LIBRARY" ]; then
wenzelm@13001
   150
  "$TAR" cf "${ISABELLE_NAME}_library.tar" $ISABELLE_NAME/browser_info && \
wenzelm@13001
   151
    gzip -f "${ISABELLE_NAME}_library.tar"
wenzelm@13001
   152
    cp -f "${ISABELLE_NAME}_library.tar.gz" "$ARCHIVE_DIR"
wenzelm@13001
   153
else
kleing@14633
   154
  for IMG in HOL HOL-Complex HOL4 ZF
wenzelm@13001
   155
  do
wenzelm@13001
   156
    "$TAR" cf "${IMG}_$PLATFORM.tar" \
wenzelm@13001
   157
      "$ISABELLE_NAME/heaps/$COMPILER/$IMG" \
wenzelm@13001
   158
      "$ISABELLE_NAME/heaps/$COMPILER/log/$IMG.gz"
wenzelm@13001
   159
    gzip -f "${IMG}_$PLATFORM.tar"
wenzelm@13001
   160
    cp -f "${IMG}_$PLATFORM.tar.gz" "$ARCHIVE_DIR"
wenzelm@13001
   161
  done
wenzelm@13001
   162
fi
wenzelm@10082
   163
wenzelm@10082
   164
wenzelm@10082
   165
# clean up
wenzelm@10082
   166
cd /tmp
wenzelm@10082
   167
rm -rf "$TMP"