lib/scripts/getsettings
author wenzelm
Tue Nov 16 21:54:52 2010 +0100 (2010-11-16)
changeset 40570 bf8f92bdf630
parent 40568 3003be923908
child 41511 2fe62d602681
permissions -rw-r--r--
init_component: require absolute path (when invoked by user 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@2299
    24
wenzelm@34254
    25
function isabelle ()
wenzelm@34254
    26
{
wenzelm@34254
    27
  "$ISABELLE_TOOL" "$@"
wenzelm@34254
    28
}
wenzelm@34254
    29
wenzelm@36196
    30
#platform
wenzelm@36196
    31
. "$ISABELLE_HOME/lib/scripts/isabelle-platform"
wenzelm@36196
    32
wenzelm@25434
    33
#Isabelle distribution identifier -- filled in automatically!
wenzelm@25434
    34
ISABELLE_IDENTIFIER=""
wenzelm@21490
    35
wenzelm@2643
    36
#users tend to put strange things in here ...
wenzelm@2621
    37
unset ENV
wenzelm@2621
    38
unset BASH_ENV
wenzelm@2621
    39
wenzelm@9680
    40
#support easy settings
wenzelm@9680
    41
function choosefrom ()
wenzelm@9680
    42
{
wenzelm@9680
    43
  local RESULT=""
wenzelm@9680
    44
  local FILE=""
wenzelm@9680
    45
wenzelm@9680
    46
  for FILE in "$@"
wenzelm@9680
    47
  do
wenzelm@9680
    48
    [ -z "$RESULT" -a -e "$FILE" ] && RESULT="$FILE"
wenzelm@9680
    49
  done
wenzelm@9680
    50
wenzelm@9680
    51
  [ -z "$RESULT" ] && RESULT="$FILE"
wenzelm@9680
    52
  echo "$RESULT"
wenzelm@9680
    53
}
wenzelm@9680
    54
wenzelm@27914
    55
#JVM path wrapper
wenzelm@25650
    56
if [ "$OSTYPE" = cygwin ]; then
wenzelm@27908
    57
  CLASSPATH="$(cygpath -u -p "$CLASSPATH")"
wenzelm@27908
    58
  function jvmpath() { cygpath -w -p "$@"; }
wenzelm@36194
    59
  THIS_CYGWIN="$(jvmpath "/")"
wenzelm@25650
    60
else
wenzelm@27908
    61
  function jvmpath() { echo "$@"; }
wenzelm@25650
    62
fi
wenzelm@28055
    63
HOME_JVM="$HOME"
wenzelm@25650
    64
wenzelm@27908
    65
#CLASSPATH convenience
wenzelm@27908
    66
function classpath () {
wenzelm@27908
    67
  for X in "$@"
wenzelm@27908
    68
  do
wenzelm@27908
    69
    if [ -z "$CLASSPATH" ]; then
wenzelm@27908
    70
      CLASSPATH="$X"
wenzelm@27908
    71
    else
wenzelm@27908
    72
      CLASSPATH="$CLASSPATH:$X"
wenzelm@27908
    73
    fi
wenzelm@27908
    74
  done
wenzelm@40568
    75
  export CLASSPATH
wenzelm@27908
    76
}
wenzelm@27908
    77
wenzelm@32390
    78
#arrays
wenzelm@32390
    79
function splitarray ()
wenzelm@32390
    80
{
wenzelm@32390
    81
  SPLITARRAY=()
wenzelm@32390
    82
  local IFS="$1"; shift
wenzelm@32390
    83
  for X in $*
wenzelm@32390
    84
  do
wenzelm@32390
    85
    SPLITARRAY["${#SPLITARRAY[@]}"]="$X"
wenzelm@32390
    86
  done
wenzelm@32390
    87
}
wenzelm@32390
    88
wenzelm@32305
    89
#nested components
wenzelm@32305
    90
ISABELLE_COMPONENTS=""
wenzelm@32305
    91
function init_component ()
wenzelm@32305
    92
{
wenzelm@32305
    93
  local COMPONENT="$1"
wenzelm@40570
    94
  case "$COMPONENT" in
wenzelm@40570
    95
    /*) ;;
wenzelm@40570
    96
    *)
wenzelm@40570
    97
      echo >&2 "Absolute component path required: \"$COMPONENT\""
wenzelm@40570
    98
      exit 2
wenzelm@40570
    99
      ;;
wenzelm@40570
   100
  esac
wenzelm@32305
   101
wenzelm@32305
   102
  if [ ! -d "$COMPONENT" ]; then
wenzelm@33295
   103
    echo >&2 "Bad Isabelle component: \"$COMPONENT\""
wenzelm@32305
   104
    exit 2
wenzelm@32305
   105
  elif [ -z "$ISABELLE_COMPONENTS" ]; then
wenzelm@32305
   106
    ISABELLE_COMPONENTS="$COMPONENT"
wenzelm@32305
   107
  else
wenzelm@32305
   108
    ISABELLE_COMPONENTS="$ISABELLE_COMPONENTS:$COMPONENT"
wenzelm@32305
   109
  fi
wenzelm@32305
   110
  if [ -f "$COMPONENT/etc/settings" ]; then
wenzelm@32305
   111
    source "$COMPONENT/etc/settings" || exit 2
wenzelm@32305
   112
  fi
wenzelm@32305
   113
  if [ -f "$COMPONENT/etc/components" ]; then
wenzelm@32305
   114
    {
wenzelm@33512
   115
      while { unset REPLY; read -r; test "$?" = 0 -o -n "$REPLY"; }
wenzelm@33512
   116
      do
wenzelm@32305
   117
        case "$REPLY" in
wenzelm@32305
   118
          \#* | "") ;;
wenzelm@32305
   119
          /*) init_component "$REPLY" ;;
wenzelm@32305
   120
          *) init_component "$COMPONENT/$REPLY" ;;
wenzelm@32305
   121
        esac
wenzelm@32305
   122
      done
wenzelm@33295
   123
    } < "$COMPONENT/etc/components"
wenzelm@32305
   124
  fi
wenzelm@32305
   125
}
wenzelm@32305
   126
wenzelm@32305
   127
#main components
wenzelm@32305
   128
init_component "$ISABELLE_HOME"
wenzelm@9789
   129
wenzelm@9789
   130
[ "$ISABELLE_HOME" -ef "$ISABELLE_HOME_USER" ] && \
wenzelm@32321
   131
  { echo >&2 "### ISABELLE_HOME and ISABELLE_HOME_USER must not be the same directory!"; }
wenzelm@32321
   132
[ -d "$ISABELLE_HOME_USER" ] && init_component "$ISABELLE_HOME_USER"
wenzelm@2299
   133
wenzelm@21490
   134
#ML system identifier
wenzelm@6413
   135
if [ -z "$ML_PLATFORM" ]; then
wenzelm@6413
   136
  ML_IDENTIFIER="$ML_SYSTEM"
wenzelm@6413
   137
else
wenzelm@6413
   138
  ML_IDENTIFIER="${ML_SYSTEM}_${ML_PLATFORM}"
wenzelm@6413
   139
fi
wenzelm@21468
   140
wenzelm@6413
   141
ISABELLE_OUTPUT="$ISABELLE_OUTPUT/$ML_IDENTIFIER"
wenzelm@3118
   142
wenzelm@2299
   143
set +o allexport
wenzelm@7770
   144
wenzelm@7770
   145
fi