added isabelle_scala_script wrapper -- NB: portable hash-bang allows exactly one executable, without additional arguments;
authorwenzelm
Wed May 22 18:10:54 2013 +0200 (2013-05-22)
changeset 52116abf9fcfa65cf
parent 52115 3660205b96fa
child 52117 352ea4b159ff
added isabelle_scala_script wrapper -- NB: portable hash-bang allows exactly one executable, without additional arguments;
NEWS
bin/isabelle_scala_script
lib/Tools/install
src/Doc/System/Scala.thy
     1.1 --- a/NEWS	Wed May 22 16:47:48 2013 +0200
     1.2 +++ b/NEWS	Wed May 22 18:10:54 2013 +0200
     1.3 @@ -250,6 +250,9 @@
     1.4  * Isabelle settings variable ISABELLE_BUILD_JAVA_OPTIONS allows to
     1.5  specify global resources of the JVM process run by isabelle build.
     1.6  
     1.7 +* Toplevel executable $ISABELLE_HOME/bin/isabelle_scala_script allows
     1.8 +to run Isabelle/Scala source files as standalone programs.
     1.9 +
    1.10  
    1.11  
    1.12  New in Isabelle2013 (February 2013)
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/bin/isabelle_scala_script	Wed May 22 18:10:54 2013 +0200
     2.3 @@ -0,0 +1,24 @@
     2.4 +#!/usr/bin/env bash
     2.5 +#
     2.6 +# Author: Makarius
     2.7 +#
     2.8 +# Isabelle/Scala script wrapper.
     2.9 +
    2.10 +if [ -L "$0" ]; then
    2.11 +  TARGET="$(LC_ALL=C ls -l "$0" | sed 's/.* -> //')"
    2.12 +  exec "$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd "$(dirname "$TARGET")"; pwd)/$(basename "$TARGET")" "$@"
    2.13 +fi
    2.14 +
    2.15 +
    2.16 +## settings
    2.17 +
    2.18 +PRG="$(basename "$0")"
    2.19 +
    2.20 +ISABELLE_HOME="$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd ..; pwd)"
    2.21 +source "$ISABELLE_HOME/lib/scripts/getsettings" || exit 2
    2.22 +
    2.23 +
    2.24 +## main
    2.25 +
    2.26 +exec "$ISABELLE_TOOL" scala -howtorun:script -nocompdaemon "$@"
    2.27 +
     3.1 --- a/lib/Tools/install	Wed May 22 16:47:48 2013 +0200
     3.2 +++ b/lib/Tools/install	Wed May 22 18:10:54 2013 +0200
     3.3 @@ -63,7 +63,7 @@
     3.4  
     3.5  mkdir -p "$BINDIR" || fail "Bad directory: \"$BINDIR\""
     3.6  
     3.7 -for NAME in isabelle isabelle-process
     3.8 +for NAME in isabelle isabelle-process isabelle_scala_script
     3.9  do
    3.10    BIN="$BINDIR/$NAME"
    3.11    DIST="$DISTDIR/bin/$NAME"
     4.1 --- a/src/Doc/System/Scala.thy	Wed May 22 16:47:48 2013 +0200
     4.2 +++ b/src/Doc/System/Scala.thy	Wed May 22 18:10:54 2013 +0200
     4.3 @@ -48,6 +48,7 @@
     4.4    scala> isabelle.Isabelle_System.getenv("ISABELLE_HOME")
     4.5    scala> val options = isabelle.Options.init()
     4.6    scala> options.bool("browser_info")
     4.7 +  scala> options.string("document")
     4.8  \end{alltt}
     4.9  *}
    4.10  
    4.11 @@ -69,4 +70,28 @@
    4.12    adding plugin components, which needs special attention since
    4.13    it overrides the standard Java class loader.  *}
    4.14  
    4.15 +
    4.16 +section {* Scala script wrapper *}
    4.17 +
    4.18 +text {* The executable @{executable
    4.19 +  "$ISABELLE_HOME/bin/isabelle_scala_script"} allows to run
    4.20 +  Isabelle/Scala source files stand-alone programs, by using a
    4.21 +  suitable ``hash-bang'' line and executable file permissions.
    4.22 +
    4.23 +  The subsequent example assumes that the main Isabelle binaries have
    4.24 +  been installed in some directory that is included in @{setting PATH}
    4.25 +  (see also @{tool "install"}):
    4.26 +
    4.27 +\begin{alltt}
    4.28 +#!/usr/bin/env isabelle_scala_script
    4.29 +
    4.30 +val options = isabelle.Options.init()
    4.31 +Console.println("browser_info = " + options.bool("browser_info"))
    4.32 +Console.println("document = " + options.string("document"))
    4.33 +\end{alltt}
    4.34 +
    4.35 +  Alternatively the full @{"file"
    4.36 +  "$ISABELLE_HOME/bin/isabelle_scala_script"} may be specified in
    4.37 +  expanded form.  *}
    4.38 +
    4.39  end