# HG changeset patch # User wenzelm # Date 1369239054 -7200 # Node ID abf9fcfa65cf19d11157b67271d1f9244ecd5543 # Parent 3660205b96fa9d21f14982ed84e0c08d23c5e516 added isabelle_scala_script wrapper -- NB: portable hash-bang allows exactly one executable, without additional arguments; diff -r 3660205b96fa -r abf9fcfa65cf NEWS --- a/NEWS Wed May 22 16:47:48 2013 +0200 +++ b/NEWS Wed May 22 18:10:54 2013 +0200 @@ -250,6 +250,9 @@ * Isabelle settings variable ISABELLE_BUILD_JAVA_OPTIONS allows to specify global resources of the JVM process run by isabelle build. +* Toplevel executable $ISABELLE_HOME/bin/isabelle_scala_script allows +to run Isabelle/Scala source files as standalone programs. + New in Isabelle2013 (February 2013) diff -r 3660205b96fa -r abf9fcfa65cf bin/isabelle_scala_script --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/isabelle_scala_script Wed May 22 18:10:54 2013 +0200 @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# +# Author: Makarius +# +# Isabelle/Scala script wrapper. + +if [ -L "$0" ]; then + TARGET="$(LC_ALL=C ls -l "$0" | sed 's/.* -> //')" + exec "$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd "$(dirname "$TARGET")"; pwd)/$(basename "$TARGET")" "$@" +fi + + +## settings + +PRG="$(basename "$0")" + +ISABELLE_HOME="$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd ..; pwd)" +source "$ISABELLE_HOME/lib/scripts/getsettings" || exit 2 + + +## main + +exec "$ISABELLE_TOOL" scala -howtorun:script -nocompdaemon "$@" + diff -r 3660205b96fa -r abf9fcfa65cf lib/Tools/install --- a/lib/Tools/install Wed May 22 16:47:48 2013 +0200 +++ b/lib/Tools/install Wed May 22 18:10:54 2013 +0200 @@ -63,7 +63,7 @@ mkdir -p "$BINDIR" || fail "Bad directory: \"$BINDIR\"" -for NAME in isabelle isabelle-process +for NAME in isabelle isabelle-process isabelle_scala_script do BIN="$BINDIR/$NAME" DIST="$DISTDIR/bin/$NAME" diff -r 3660205b96fa -r abf9fcfa65cf src/Doc/System/Scala.thy --- a/src/Doc/System/Scala.thy Wed May 22 16:47:48 2013 +0200 +++ b/src/Doc/System/Scala.thy Wed May 22 18:10:54 2013 +0200 @@ -48,6 +48,7 @@ scala> isabelle.Isabelle_System.getenv("ISABELLE_HOME") scala> val options = isabelle.Options.init() scala> options.bool("browser_info") + scala> options.string("document") \end{alltt} *} @@ -69,4 +70,28 @@ adding plugin components, which needs special attention since it overrides the standard Java class loader. *} + +section {* Scala script wrapper *} + +text {* The executable @{executable + "$ISABELLE_HOME/bin/isabelle_scala_script"} allows to run + Isabelle/Scala source files stand-alone programs, by using a + suitable ``hash-bang'' line and executable file permissions. + + The subsequent example assumes that the main Isabelle binaries have + been installed in some directory that is included in @{setting PATH} + (see also @{tool "install"}): + +\begin{alltt} +#!/usr/bin/env isabelle_scala_script + +val options = isabelle.Options.init() +Console.println("browser_info = " + options.bool("browser_info")) +Console.println("document = " + options.string("document")) +\end{alltt} + + Alternatively the full @{"file" + "$ISABELLE_HOME/bin/isabelle_scala_script"} may be specified in + expanded form. *} + end