src/Pure/build
author wenzelm
Mon, 11 Nov 2013 17:34:44 +0100
changeset 54383 9d3c7a04a65e
parent 52083 f852d08376f9
child 60962 faa452d8e265
permissions -rwxr-xr-x
removed obsolete RC tags;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
48360
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
     1
#!/usr/bin/env bash
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
     2
#
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
     3
# Author: Makarius
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
     4
#
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
     5
# build - build Isabelle/ML
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
     6
#
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
     7
# Requires proper Isabelle settings environment.
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
     8
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
     9
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    10
## diagnostics
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    11
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    12
function usage()
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    13
{
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    14
  echo
48511
37999ee01156 remove old output heaps, to ensure that result is valid wrt. check_stamps;
wenzelm
parents: 48447
diff changeset
    15
  echo "Usage: $PRG TARGET [OUTPUT]"
48360
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    16
  echo
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    17
  exit 1
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    18
}
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    19
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    20
function fail()
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    21
{
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    22
  echo "$1" >&2
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    23
  exit 2
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    24
}
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    25
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    26
[ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    27
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    28
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    29
## process command line
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    30
48373
527e2bad7cca further imitation of "usedir" shell script;
wenzelm
parents: 48360
diff changeset
    31
# args
527e2bad7cca further imitation of "usedir" shell script;
wenzelm
parents: 48360
diff changeset
    32
48511
37999ee01156 remove old output heaps, to ensure that result is valid wrt. check_stamps;
wenzelm
parents: 48447
diff changeset
    33
if [ "$#" -eq 1 ]; then
37999ee01156 remove old output heaps, to ensure that result is valid wrt. check_stamps;
wenzelm
parents: 48447
diff changeset
    34
  TARGET="$1"; shift
37999ee01156 remove old output heaps, to ensure that result is valid wrt. check_stamps;
wenzelm
parents: 48447
diff changeset
    35
  OUTPUT=""; shift
37999ee01156 remove old output heaps, to ensure that result is valid wrt. check_stamps;
wenzelm
parents: 48447
diff changeset
    36
elif [ "$#" -eq 2 ]; then
48447
ef600ce4559c added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents: 48417
diff changeset
    37
  TARGET="$1"; shift
ef600ce4559c added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents: 48417
diff changeset
    38
  OUTPUT="$1"; shift
ef600ce4559c added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents: 48417
diff changeset
    39
else
ef600ce4559c added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents: 48417
diff changeset
    40
  usage
ef600ce4559c added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents: 48417
diff changeset
    41
fi
48360
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    42
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    43
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    44
## main
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    45
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    46
# get compatibility file
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    47
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    48
ML_SYSTEM_BASE=$(echo "$ML_SYSTEM" | cut -f1 -d-)
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    49
[ -z "$ML_SYSTEM" ] && fail "Missing ML_SYSTEM settings!"
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    50
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    51
COMPAT=""
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    52
[ -f "ML-Systems/${ML_SYSTEM_BASE}.ML" ] && COMPAT="ML-Systems/${ML_SYSTEM_BASE}.ML"
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    53
[ -f "ML-Systems/${ML_SYSTEM}.ML" ] && COMPAT="ML-Systems/${ML_SYSTEM}.ML"
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    54
[ -z "$COMPAT" ] && fail "Missing compatibility file for ML system \"$ML_SYSTEM\"!"
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    55
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    56
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    57
# run isabelle
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    58
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    59
. "$ISABELLE_HOME/lib/scripts/timestart.bash"
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    60
48373
527e2bad7cca further imitation of "usedir" shell script;
wenzelm
parents: 48360
diff changeset
    61
if [ "$TARGET" = RAW ]; then
48447
ef600ce4559c added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents: 48417
diff changeset
    62
  if [ -z "$OUTPUT" ]; then
48373
527e2bad7cca further imitation of "usedir" shell script;
wenzelm
parents: 48360
diff changeset
    63
    "$ISABELLE_PROCESS" \
48662
b171bcd5dd86 more informative process exit code;
wenzelm
parents: 48511
diff changeset
    64
      -e "use\"$COMPAT\" handle _ => Posix.Process.exit 0w1;" \
48373
527e2bad7cca further imitation of "usedir" shell script;
wenzelm
parents: 48360
diff changeset
    65
      -q RAW_ML_SYSTEM
527e2bad7cca further imitation of "usedir" shell script;
wenzelm
parents: 48360
diff changeset
    66
  else
527e2bad7cca further imitation of "usedir" shell script;
wenzelm
parents: 48360
diff changeset
    67
    "$ISABELLE_PROCESS" \
48662
b171bcd5dd86 more informative process exit code;
wenzelm
parents: 48511
diff changeset
    68
      -e "use\"$COMPAT\" handle _ => Posix.Process.exit 0w1;" \
48373
527e2bad7cca further imitation of "usedir" shell script;
wenzelm
parents: 48360
diff changeset
    69
      -e "structure Isar = struct fun main () = () end;" \
527e2bad7cca further imitation of "usedir" shell script;
wenzelm
parents: 48360
diff changeset
    70
      -e "ml_prompts \"ML> \" \"ML# \";" \
48447
ef600ce4559c added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents: 48417
diff changeset
    71
      -q -w RAW_ML_SYSTEM "$OUTPUT"
48373
527e2bad7cca further imitation of "usedir" shell script;
wenzelm
parents: 48360
diff changeset
    72
  fi
527e2bad7cca further imitation of "usedir" shell script;
wenzelm
parents: 48360
diff changeset
    73
else
48447
ef600ce4559c added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents: 48417
diff changeset
    74
  if [ -z "$OUTPUT" ]; then
48373
527e2bad7cca further imitation of "usedir" shell script;
wenzelm
parents: 48360
diff changeset
    75
    "$ISABELLE_PROCESS" \
48662
b171bcd5dd86 more informative process exit code;
wenzelm
parents: 48511
diff changeset
    76
      -e "(use\"$COMPAT\"; use\"ROOT.ML\") handle _ => Posix.Process.exit 0w1;" \
48373
527e2bad7cca further imitation of "usedir" shell script;
wenzelm
parents: 48360
diff changeset
    77
      -q RAW_ML_SYSTEM
527e2bad7cca further imitation of "usedir" shell script;
wenzelm
parents: 48360
diff changeset
    78
  else
527e2bad7cca further imitation of "usedir" shell script;
wenzelm
parents: 48360
diff changeset
    79
    "$ISABELLE_PROCESS" \
48662
b171bcd5dd86 more informative process exit code;
wenzelm
parents: 48511
diff changeset
    80
      -e "(use\"$COMPAT\"; use\"ROOT.ML\") handle _ => Posix.Process.exit 0w1;" \
48373
527e2bad7cca further imitation of "usedir" shell script;
wenzelm
parents: 48360
diff changeset
    81
      -e "ml_prompts \"ML> \" \"ML# \";" \
52054
eaf17514aabd discontinued obsolete isabelle-process options -f and -u;
wenzelm
parents: 48662
diff changeset
    82
      -e "Command_Line.tool0 Session.finish;" \
52083
f852d08376f9 even later Options.reset_default -- still needed for printing errors of Session.finish (e.g. via Command_Line.tool0);
wenzelm
parents: 52054
diff changeset
    83
      -e "Options.reset_default ();" \
52054
eaf17514aabd discontinued obsolete isabelle-process options -f and -u;
wenzelm
parents: 48662
diff changeset
    84
      -q -w RAW_ML_SYSTEM "$OUTPUT"
48373
527e2bad7cca further imitation of "usedir" shell script;
wenzelm
parents: 48360
diff changeset
    85
  fi
527e2bad7cca further imitation of "usedir" shell script;
wenzelm
parents: 48360
diff changeset
    86
fi
48360
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    87
48373
527e2bad7cca further imitation of "usedir" shell script;
wenzelm
parents: 48360
diff changeset
    88
RC="$?"
48360
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    89
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    90
. "$ISABELLE_HOME/lib/scripts/timestop.bash"
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    91
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    92
if [ "$RC" -eq 0 ]; then
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    93
  echo "Finished $TARGET ($TIMES_REPORT)" >&2
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    94
fi
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    95
631d286e97b0 simplified script to build Isabelle/ML;
wenzelm
parents:
diff changeset
    96
exit "$RC"