lib/scripts/getsettings
author wenzelm
Mon Apr 07 13:11:31 2014 +0200 (2014-04-07)
changeset 56448 344800503974
parent 56440 aab984137bcd
child 57411 9444489766a1
permissions -rwxr-xr-x
provide old-style ISABELLE_SCALA_SCRIPT for uniformity;
     1 # -*- shell-script -*- :mode=shellscript:
     2 #
     3 # Author: Markus Wenzel, TU Muenchen
     4 #
     5 # getsettings - bash source script to augment current env.
     6 
     7 if [ -z "$ISABELLE_SETTINGS_PRESENT" ]
     8 then
     9 
    10 set -o allexport
    11 
    12 ISABELLE_SETTINGS_PRESENT=true
    13 
    14 #GNU tar (notably on Mac OS X)
    15 if [ -x /usr/bin/gnutar ]; then
    16   function tar() { /usr/bin/gnutar "$@"; }
    17 fi
    18 
    19 #Cygwin vs. POSIX
    20 if [ "$OSTYPE" = cygwin ]
    21 then
    22   unset INI_DIR
    23 
    24   if [ -z "$USER_HOME" ]; then
    25     USER_HOME="$(cygpath -u "$HOMEDRIVE\\$HOMEPATH")"
    26   fi
    27 
    28   function jvmpath() { cygpath -i -C UTF8 -w -p "$@"; }
    29   CYGWIN_ROOT="$(jvmpath "/")"
    30 
    31   ISABELLE_CLASSPATH="$(cygpath -i -u -p "$CLASSPATH")"
    32   unset CLASSPATH
    33 else
    34   if [ -z "$USER_HOME" ]; then
    35     USER_HOME="$HOME"
    36   fi
    37 
    38   function jvmpath() { echo "$@"; }
    39 
    40   ISABELLE_CLASSPATH="$CLASSPATH"
    41   unset CLASSPATH
    42 fi
    43 
    44 export ISABELLE_HOME
    45 
    46 #key executables
    47 ISABELLE_TOOL="$ISABELLE_HOME/bin/isabelle"
    48 ISABELLE_PROCESS="$ISABELLE_HOME/bin/isabelle_process"
    49 ISABELLE_SCALA_SCRIPT="$ISABELLE_HOME/bin/isabelle_scala_script"
    50 
    51 function isabelle ()
    52 {
    53   "$ISABELLE_TOOL" "$@"
    54 }
    55 
    56 function isabelle_process ()
    57 {
    58   "$ISABELLE_PROCESS" "$@"
    59 }
    60 
    61 function isabelle_scala_script ()
    62 {
    63   "$ISABELLE_SCALA_SCRIPT" "$@"
    64 }
    65 
    66 #platform
    67 source "$ISABELLE_HOME/lib/scripts/isabelle-platform"
    68 if [ -z "$ISABELLE_PLATFORM" ]; then
    69   echo 1>&2 "Failed to determine hardware and operating system type!"
    70   exit 2
    71 fi
    72 
    73 #Isabelle distribution identifier -- filled in automatically!
    74 ISABELLE_ID=""
    75 [ -z "$ISABELLE_IDENTIFIER" ] && ISABELLE_IDENTIFIER=""
    76 
    77 #sometimes users put strange things in here ...
    78 unset ENV
    79 unset BASH_ENV
    80 
    81 #shared library convenience
    82 function librarypath ()
    83 {
    84   for X in "$@"
    85   do
    86     case "$ISABELLE_PLATFORM" in
    87       *-darwin)
    88         if [ -z "$DYLD_LIBRARY_PATH" ]; then
    89           DYLD_LIBRARY_PATH="$X"
    90         else
    91           DYLD_LIBRARY_PATH="$X:$DYLD_LIBRARY_PATH"
    92         fi
    93         export DYLD_LIBRARY_PATH
    94         ;;
    95       *)
    96         if [ -z "$LD_LIBRARY_PATH" ]; then
    97           LD_LIBRARY_PATH="$X"
    98         else
    99           LD_LIBRARY_PATH="$X:$LD_LIBRARY_PATH"
   100         fi
   101         export LD_LIBRARY_PATH
   102         ;;
   103     esac
   104   done
   105 }
   106 
   107 #robust invocation via ISABELLE_JDK_HOME
   108 function isabelle_jdk ()
   109 {
   110   if [ -z "$ISABELLE_JDK_HOME" ]; then
   111     echo "Unknown ISABELLE_JDK_HOME -- Java tools unavailable" >&2
   112     return 127
   113   else
   114     local PRG="$1"; shift
   115     "$ISABELLE_JDK_HOME/bin/$PRG" "$@"
   116   fi
   117 }
   118 
   119 #robust invocation via SCALA_HOME
   120 function isabelle_scala ()
   121 {
   122   if [ -z "$ISABELLE_JDK_HOME" ]; then
   123     echo "Unknown ISABELLE_JDK_HOME -- Java tools unavailable" >&2
   124     return 127
   125   elif [ -z "$SCALA_HOME" ]; then
   126     echo "Unknown SCALA_HOME -- Scala unavailable" >&2
   127     return 127
   128   else
   129     local PRG="$1"; shift
   130     "$SCALA_HOME/bin/$PRG" "$@"
   131   fi
   132 }
   133 
   134 #administrative build
   135 if [ -e "$ISABELLE_HOME/Admin/build" ]; then
   136   function isabelle_admin_build ()
   137   {
   138     "$ISABELLE_HOME/Admin/build" "$@"
   139   }
   140 else
   141   function isabelle_admin_build () { return 0; }
   142 fi
   143 
   144 #classpath
   145 function classpath ()
   146 {
   147   for X in "$@"
   148   do
   149     if [ -z "$ISABELLE_CLASSPATH" ]; then
   150       ISABELLE_CLASSPATH="$X"
   151     else
   152       ISABELLE_CLASSPATH="$ISABELLE_CLASSPATH:$X"
   153     fi
   154   done
   155   export ISABELLE_CLASSPATH
   156 }
   157 
   158 #arrays
   159 function splitarray ()
   160 {
   161   SPLITARRAY=()
   162   local IFS="$1"; shift
   163   for X in $*
   164   do
   165     SPLITARRAY["${#SPLITARRAY[@]}"]="$X"
   166   done
   167 }
   168 
   169 
   170 # components
   171 
   172 ISABELLE_COMPONENTS=""
   173 ISABELLE_COMPONENTS_MISSING=""
   174 
   175 #init component tree
   176 function init_component ()
   177 {
   178   local COMPONENT="$1"
   179   case "$COMPONENT" in
   180     /*) ;;
   181     *)
   182       echo >&2 "Absolute component path required: \"$COMPONENT\""
   183       exit 2
   184       ;;
   185   esac
   186 
   187   if [ -d "$COMPONENT" ]; then
   188     if [ -z "$ISABELLE_COMPONENTS" ]; then
   189       ISABELLE_COMPONENTS="$COMPONENT"
   190     else
   191       ISABELLE_COMPONENTS="$ISABELLE_COMPONENTS:$COMPONENT"
   192     fi
   193   else
   194     echo >&2 "### Missing Isabelle component: \"$COMPONENT\""
   195     if [ -z "$ISABELLE_COMPONENTS_MISSING" ]; then
   196       ISABELLE_COMPONENTS_MISSING="$COMPONENT"
   197     else
   198       ISABELLE_COMPONENTS_MISSING="$ISABELLE_COMPONENTS_MISSING:$COMPONENT"
   199     fi
   200   fi
   201 
   202   if [ -f "$COMPONENT/etc/settings" ]; then
   203     source "$COMPONENT/etc/settings"
   204     local RC="$?"
   205     if [ "$RC" -ne 0 ]; then
   206       echo >&2 "Return code $RC from bash script: \"$COMPONENT/etc/settings\""
   207       exit 2
   208     fi
   209   fi
   210   if [ -f "$COMPONENT/etc/components" ]; then
   211     init_components "$COMPONENT" "$COMPONENT/etc/components"
   212   fi
   213 }
   214 
   215 #init component forest
   216 function init_components ()
   217 {
   218   local BASE="$1"
   219   local CATALOG="$2"
   220 
   221   if [ ! -f "$CATALOG" ]; then
   222     echo >&2 "Bad component catalog file: \"$CATALOG\""
   223     exit 2
   224   fi
   225   {
   226     while { unset REPLY; read -r; test "$?" = 0 -o -n "$REPLY"; }
   227     do
   228       case "$REPLY" in
   229         \#* | "") ;;
   230         /*) init_component "$REPLY" ;;
   231         *) init_component "$BASE/$REPLY" ;;
   232       esac
   233     done
   234   } < "$CATALOG"
   235 }
   236 
   237 #main components
   238 init_component "$ISABELLE_HOME"
   239 [ -d "$ISABELLE_HOME/Admin" ] && init_component "$ISABELLE_HOME/Admin"
   240 [ -d "$ISABELLE_HOME_USER" ] && init_component "$ISABELLE_HOME_USER"
   241 
   242 
   243 #ML system identifier
   244 if [ -z "$ML_PLATFORM" ]; then
   245   ML_IDENTIFIER="$ML_SYSTEM"
   246 else
   247   ML_IDENTIFIER="${ML_SYSTEM}_${ML_PLATFORM}"
   248 fi
   249 
   250 ISABELLE_OUTPUT="$ISABELLE_OUTPUT/$ML_IDENTIFIER"
   251 
   252 #enforce JAVA_HOME
   253 export JAVA_HOME="$ISABELLE_JDK_HOME"
   254 
   255 #build condition etc.
   256 case "$ML_SYSTEM" in
   257   polyml*)
   258     ISABELLE_POLYML="true"
   259     ;;
   260   *)
   261     ISABELLE_POLYML=""
   262     ;;
   263 esac
   264 
   265 set +o allexport
   266 
   267 fi