lib/scripts/getsettings
author wenzelm
Mon Jan 04 21:49:47 2010 +0100 (2010-01-04)
changeset 34254 14f6df4f473d
parent 34043 7129fab1fe4f
child 34255 2dd2547acb41
permissions -rw-r--r--
shell functions "isabelle-process" and "isabelle" refer to the proper executables statically -- for interactive use or sloppy bash scripts;
wenzelm@25434
     1
# -*- shell-script -*- :mode=shellscript:
wenzelm@29145
     2
#
wenzelm@9789
     3
# Author: Markus Wenzel, TU Muenchen
wenzelm@2299
     4
#
wenzelm@2348
     5
# getsettings - bash source script to augment current env.
wenzelm@2299
     6
wenzelm@7770
     7
if [ -z "$ISABELLE_SETTINGS_PRESENT" ]
wenzelm@7770
     8
then
wenzelm@7770
     9
wenzelm@3185
    10
set -o allexport
wenzelm@3185
    11
wenzelm@7770
    12
ISABELLE_SETTINGS_PRESENT=true
wenzelm@7770
    13
wenzelm@15972
    14
export ISABELLE_HOME
wenzelm@12598
    15
if { echo -n "$ISABELLE_HOME" | fgrep " " >/dev/null; }
wenzelm@12598
    16
then
wenzelm@12598
    17
  echo 1>&2 "### White space in ISABELLE_HOME may cause strange problems later on!"
wenzelm@12598
    18
  echo 1>&2 "### ISABELLE_HOME=\"$ISABELLE_HOME\""
wenzelm@12598
    19
fi
wenzelm@2736
    20
wenzelm@11553
    21
#key executables
wenzelm@28499
    22
ISABELLE_PROCESS="$ISABELLE_HOME/bin/isabelle-process"
wenzelm@28504
    23
ISABELLE_TOOL="$ISABELLE_HOME/bin/isabelle"
wenzelm@28499
    24
#legacy settings
wenzelm@28499
    25
ISABELLE="$ISABELLE_PROCESS"
wenzelm@28499
    26
ISATOOL="$ISABELLE_TOOL"
wenzelm@2299
    27
wenzelm@34254
    28
function isabelle-process ()
wenzelm@34254
    29
{
wenzelm@34254
    30
  "$ISABELLE_PROCESS" "$@"
wenzelm@34254
    31
}
wenzelm@34254
    32
wenzelm@34254
    33
function isabelle ()
wenzelm@34254
    34
{
wenzelm@34254
    35
  "$ISABELLE_TOOL" "$@"
wenzelm@34254
    36
}
wenzelm@34254
    37
wenzelm@25434
    38
#Isabelle distribution identifier -- filled in automatically!
wenzelm@25434
    39
ISABELLE_IDENTIFIER=""
wenzelm@21490
    40
wenzelm@2643
    41
#users tend to put strange things in here ...
wenzelm@2621
    42
unset ENV
wenzelm@2621
    43
unset BASH_ENV
wenzelm@2621
    44
wenzelm@9680
    45
#support easy settings
wenzelm@9680
    46
function choosefrom ()
wenzelm@9680
    47
{
wenzelm@9680
    48
  local RESULT=""
wenzelm@9680
    49
  local FILE=""
wenzelm@9680
    50
wenzelm@9680
    51
  for FILE in "$@"
wenzelm@9680
    52
  do
wenzelm@9680
    53
    [ -z "$RESULT" -a -e "$FILE" ] && RESULT="$FILE"
wenzelm@9680
    54
  done
wenzelm@9680
    55
wenzelm@9680
    56
  [ -z "$RESULT" ] && RESULT="$FILE"
wenzelm@9680
    57
  echo "$RESULT"
wenzelm@9680
    58
}
wenzelm@9680
    59
wenzelm@27914
    60
#JVM path wrapper
wenzelm@25650
    61
if [ "$OSTYPE" = cygwin ]; then
wenzelm@27908
    62
  CLASSPATH="$(cygpath -u -p "$CLASSPATH")"
wenzelm@27908
    63
  function jvmpath() { cygpath -w -p "$@"; }
wenzelm@34043
    64
  CYGWIN_ROOT="$(jvmpath "/")"
wenzelm@25650
    65
else
wenzelm@27908
    66
  function jvmpath() { echo "$@"; }
wenzelm@25650
    67
fi
wenzelm@28055
    68
HOME_JVM="$HOME"
wenzelm@25650
    69
wenzelm@27908
    70
#CLASSPATH convenience
wenzelm@27908
    71
function classpath () {
wenzelm@27908
    72
  for X in "$@"
wenzelm@27908
    73
  do
wenzelm@27908
    74
    if [ -z "$CLASSPATH" ]; then
wenzelm@27908
    75
      CLASSPATH="$X"
wenzelm@27908
    76
    else
wenzelm@27908
    77
      CLASSPATH="$CLASSPATH:$X"
wenzelm@27908
    78
    fi
wenzelm@27908
    79
  done
wenzelm@27908
    80
}
wenzelm@27908
    81
wenzelm@32390
    82
#arrays
wenzelm@32390
    83
function splitarray ()
wenzelm@32390
    84
{
wenzelm@32390
    85
  SPLITARRAY=()
wenzelm@32390
    86
  local IFS="$1"; shift
wenzelm@32390
    87
  for X in $*
wenzelm@32390
    88
  do
wenzelm@32390
    89
    SPLITARRAY["${#SPLITARRAY[@]}"]="$X"
wenzelm@32390
    90
  done
wenzelm@32390
    91
}
wenzelm@32390
    92
wenzelm@32305
    93
#nested components
wenzelm@32305
    94
ISABELLE_COMPONENTS=""
wenzelm@32305
    95
function init_component ()
wenzelm@32305
    96
{
wenzelm@32305
    97
  local COMPONENT="$1"
wenzelm@32305
    98
wenzelm@32305
    99
  if [ ! -d "$COMPONENT" ]; then
wenzelm@33295
   100
    echo >&2 "Bad Isabelle component: \"$COMPONENT\""
wenzelm@32305
   101
    exit 2
wenzelm@32305
   102
  elif [ -z "$ISABELLE_COMPONENTS" ]; then
wenzelm@32305
   103
    ISABELLE_COMPONENTS="$COMPONENT"
wenzelm@32305
   104
  else
wenzelm@32305
   105
    ISABELLE_COMPONENTS="$ISABELLE_COMPONENTS:$COMPONENT"
wenzelm@32305
   106
  fi
wenzelm@32305
   107
  if [ -f "$COMPONENT/etc/settings" ]; then
wenzelm@32305
   108
    source "$COMPONENT/etc/settings" || exit 2
wenzelm@32305
   109
  fi
wenzelm@32305
   110
  if [ -f "$COMPONENT/etc/components" ]; then
wenzelm@32305
   111
    {
wenzelm@33512
   112
      while { unset REPLY; read -r; test "$?" = 0 -o -n "$REPLY"; }
wenzelm@33512
   113
      do
wenzelm@32305
   114
        case "$REPLY" in
wenzelm@32305
   115
          \#* | "") ;;
wenzelm@32305
   116
          /*) init_component "$REPLY" ;;
wenzelm@32305
   117
          *) init_component "$COMPONENT/$REPLY" ;;
wenzelm@32305
   118
        esac
wenzelm@32305
   119
      done
wenzelm@33295
   120
    } < "$COMPONENT/etc/components"
wenzelm@32305
   121
  fi
wenzelm@32305
   122
}
wenzelm@32305
   123
wenzelm@32305
   124
#main components
wenzelm@32305
   125
init_component "$ISABELLE_HOME"
wenzelm@9789
   126
wenzelm@9789
   127
[ "$ISABELLE_HOME" -ef "$ISABELLE_HOME_USER" ] && \
wenzelm@32321
   128
  { echo >&2 "### ISABELLE_HOME and ISABELLE_HOME_USER must not be the same directory!"; }
wenzelm@32321
   129
[ -d "$ISABELLE_HOME_USER" ] && init_component "$ISABELLE_HOME_USER"
wenzelm@2299
   130
wenzelm@21490
   131
#ML system identifier
wenzelm@6413
   132
if [ -z "$ML_PLATFORM" ]; then
wenzelm@6413
   133
  ML_IDENTIFIER="$ML_SYSTEM"
wenzelm@6413
   134
else
wenzelm@6413
   135
  ML_IDENTIFIER="${ML_SYSTEM}_${ML_PLATFORM}"
wenzelm@6413
   136
fi
wenzelm@21468
   137
wenzelm@6413
   138
ISABELLE_OUTPUT="$ISABELLE_OUTPUT/$ML_IDENTIFIER"
wenzelm@3118
   139
wenzelm@2299
   140
set +o allexport
wenzelm@7770
   141
wenzelm@7770
   142
fi