src/Pure/mk
author wenzelm
Thu Oct 04 20:29:42 2007 +0200 (2007-10-04)
changeset 24850 0cfd722ab579
parent 22011 3d4ea1819cb7
child 28502 6b0e3e4e1891
permissions -rwxr-xr-x
Name.uu, Name.aT;
wenzelm@11391
     1
#!/usr/bin/env bash
wenzelm@2339
     2
#
wenzelm@2339
     3
# $Id$
wenzelm@9789
     4
# Author: Markus Wenzel, TU Muenchen
wenzelm@2339
     5
#
wenzelm@2339
     6
# mk - build Pure Isabelle.
wenzelm@2339
     7
#
wenzelm@10102
     8
# Requires proper Isabelle settings environment (cf. IsaMakefile).
wenzelm@2339
     9
wenzelm@2339
    10
wenzelm@2339
    11
## diagnostics
wenzelm@2339
    12
wenzelm@3774
    13
function usage()
wenzelm@3774
    14
{
wenzelm@3774
    15
  echo
wenzelm@3774
    16
  echo "Usage: $PRG [OPTIONS]"
wenzelm@3774
    17
  echo
wenzelm@3774
    18
  echo "  Make Pure Isabelle."
wenzelm@3774
    19
  echo
wenzelm@21996
    20
  echo "    -R DIR/FILE  run RAW session"
wenzelm@21996
    21
  echo "    -r           build RAW image"
wenzelm@3774
    22
  echo
wenzelm@3774
    23
  exit 1
wenzelm@3774
    24
}
wenzelm@3774
    25
wenzelm@2339
    26
function fail()
wenzelm@2339
    27
{
wenzelm@2339
    28
  echo "$1" >&2
wenzelm@2339
    29
  exit 2
wenzelm@2339
    30
}
wenzelm@2339
    31
wenzelm@2339
    32
wenzelm@3774
    33
## process command line
wenzelm@3774
    34
wenzelm@3774
    35
# options
wenzelm@3774
    36
wenzelm@21996
    37
RAW_SESSION=""
wenzelm@3774
    38
RAW=""
wenzelm@3774
    39
wenzelm@21996
    40
while getopts "R:r" OPT
wenzelm@3774
    41
do
wenzelm@3774
    42
  case "$OPT" in
wenzelm@21996
    43
    R)
wenzelm@21996
    44
      RAW_SESSION="$OPTARG"
wenzelm@10102
    45
      ;;
wenzelm@3774
    46
    r)
wenzelm@3774
    47
      RAW=true
wenzelm@3774
    48
      ;;
wenzelm@3774
    49
    \?)
wenzelm@3774
    50
      usage
wenzelm@3774
    51
      ;;
wenzelm@3774
    52
  esac
wenzelm@3774
    53
done
wenzelm@3774
    54
wenzelm@3774
    55
shift $(($OPTIND - 1))
wenzelm@3774
    56
wenzelm@3774
    57
wenzelm@3774
    58
# args
wenzelm@3774
    59
wenzelm@9789
    60
[ "$#" -ne 0 ] && usage
wenzelm@3774
    61
wenzelm@3774
    62
wenzelm@2339
    63
## main
wenzelm@2339
    64
wenzelm@4442
    65
# get compatibility file
wenzelm@4442
    66
wenzelm@9789
    67
ML_SYSTEM_BASE=$(echo "$ML_SYSTEM" | cut -f1 -d-)
wenzelm@16131
    68
[ -z "$ML_SYSTEM" ] && fail "Missing ML_SYSTEM settings!"
wenzelm@2339
    69
wenzelm@2339
    70
COMPAT=""
wenzelm@2339
    71
[ -f "ML-Systems/$ML_SYSTEM_BASE.ML" ] && COMPAT="ML-Systems/$ML_SYSTEM_BASE.ML"
wenzelm@2339
    72
[ -f "ML-Systems/$ML_SYSTEM.ML" ] && COMPAT="ML-Systems/$ML_SYSTEM.ML"
wenzelm@2339
    73
[ -z "$COMPAT" ] && fail "Missing compatibility file for ML system \"$ML_SYSTEM\"!"
wenzelm@2339
    74
wenzelm@4442
    75
wenzelm@4442
    76
# prepare log dir
wenzelm@4442
    77
wenzelm@4442
    78
LOGDIR="$ISABELLE_OUTPUT/log"
wenzelm@4442
    79
mkdir -p "$LOGDIR"
wenzelm@4442
    80
wenzelm@4442
    81
wenzelm@4442
    82
# run isabelle
wenzelm@4442
    83
wenzelm@18321
    84
. "$ISABELLE_HOME/lib/scripts/timestart.bash"
wenzelm@4442
    85
wenzelm@21996
    86
if [ -n "$RAW" ]; then
wenzelm@21996
    87
  ITEM="RAW"
wenzelm@21996
    88
  echo "Building $ITEM ..."
wenzelm@21996
    89
  LOG="$LOGDIR/$ITEM"
wenzelm@21996
    90
wenzelm@21996
    91
  "$ISABELLE" \
wenzelm@21996
    92
    -e "val ml_system = \"$ML_SYSTEM\";" \
wenzelm@21996
    93
    -e "val ml_platform = \"$ML_PLATFORM\";" \
wenzelm@21996
    94
    -e "use\"$COMPAT\" handle _ => exit 1;" \
wenzelm@21996
    95
    -q -w RAW_ML_SYSTEM RAW > "$LOG" 2>&1
wenzelm@21996
    96
  RC="$?"
wenzelm@21996
    97
elif [ -n "$RAW_SESSION" ]; then
wenzelm@21996
    98
  ITEM="RAW-$(basename $(dirname "$RAW_SESSION"))"
wenzelm@22011
    99
  echo "Running $ITEM ..."
wenzelm@21996
   100
  LOG="$LOGDIR/$ITEM"
wenzelm@21996
   101
wenzelm@21996
   102
  "$ISABELLE" \
wenzelm@21996
   103
    -e "use\"$RAW_SESSION\" handle _ => exit 1;" \
wenzelm@21996
   104
    -q RAW > "$LOG" 2>&1
wenzelm@21996
   105
  RC="$?"
wenzelm@21996
   106
else
wenzelm@4442
   107
  ITEM="Pure"
wenzelm@7277
   108
  echo "Building $ITEM ..."
wenzelm@4442
   109
  LOG="$LOGDIR/$ITEM"
wenzelm@4442
   110
wenzelm@21996
   111
  "$ISABELLE" \
wenzelm@3774
   112
    -e "val ml_system = \"$ML_SYSTEM\";" \
wenzelm@16376
   113
    -e "val ml_platform = \"$ML_PLATFORM\";" \
wenzelm@4495
   114
    -e "(use\"$COMPAT\"; use\"ROOT.ML\") handle _ => exit 1;" \
wenzelm@10900
   115
    -f -c -q -w RAW_ML_SYSTEM Pure > "$LOG" 2>&1
wenzelm@9789
   116
  RC="$?"
wenzelm@3774
   117
fi
wenzelm@4442
   118
wenzelm@18321
   119
. "$ISABELLE_HOME/lib/scripts/timestop.bash"
wenzelm@4442
   120
wenzelm@4442
   121
wenzelm@4442
   122
# exit status
wenzelm@4442
   123
wenzelm@9789
   124
if [ "$RC" -eq 0 ]; then
wenzelm@18321
   125
  echo "Finished $ITEM ($TIMES_REPORT)"
wenzelm@4442
   126
  gzip --force "$LOG"
wenzelm@4442
   127
else
wenzelm@7263
   128
  echo "$ITEM FAILED"
wenzelm@4442
   129
  echo "(see also $LOG)"
wenzelm@9789
   130
  echo; tail "$LOG"; echo
wenzelm@4442
   131
fi
wenzelm@4442
   132
wenzelm@9789
   133
exit "$RC"