basic setup for Isabelle build tool;
authorwenzelm
Tue Jul 17 15:56:19 2012 +0200 (2012-07-17)
changeset 482764bd480886813
parent 48275 31daac3a85ea
child 48277 f14e564fca1a
basic setup for Isabelle build tool;
lib/Tools/build
src/Pure/System/build.scala
src/Pure/build-jars
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/lib/Tools/build	Tue Jul 17 15:56:19 2012 +0200
     1.3 @@ -0,0 +1,78 @@
     1.4 +#!/usr/bin/env bash
     1.5 +#
     1.6 +# Author: Makarius
     1.7 +#
     1.8 +# DESCRIPTION: build and manage Isabelle sessions
     1.9 +
    1.10 +
    1.11 +## diagnostics
    1.12 +
    1.13 +PRG="$(basename "$0")"
    1.14 +
    1.15 +function usage()
    1.16 +{
    1.17 +  echo
    1.18 +  echo "Usage: isabelle $PRG [OPTIONS] [SESSIONS ...]"
    1.19 +  echo
    1.20 +  echo "  Options are:"
    1.21 +  echo "    -a           all sessions"
    1.22 +  echo "    -b           build target images"
    1.23 +  echo "    -l           list sessions only"
    1.24 +  echo "    -o OPTION    override session configuration OPTION (via NAME=VAL or NAME)"
    1.25 +  echo
    1.26 +  echo "  Build and manage Isabelle sessions, depending on implicit"
    1.27 +  echo "  ISABELLE_BUILD_OPTIONS=\"$ISABELLE_BUILD_OPTIONS\""
    1.28 +  echo
    1.29 +  echo "  ML_PLATFORM=\"$ML_PLATFORM\""
    1.30 +  echo "  ML_HOME=\"$ML_HOME\""
    1.31 +  echo "  ML_SYSTEM=\"$ML_SYSTEM\""
    1.32 +  echo "  ML_OPTIONS=\"$ML_OPTIONS\""
    1.33 +  echo
    1.34 +  exit 1
    1.35 +}
    1.36 +
    1.37 +function fail()
    1.38 +{
    1.39 +  echo "$1" >&2
    1.40 +  exit 2
    1.41 +}
    1.42 +
    1.43 +
    1.44 +## process command line
    1.45 +
    1.46 +ALL_SESSIONS=false
    1.47 +BUILD_IMAGES=false
    1.48 +LIST_ONLY=false
    1.49 +
    1.50 +eval "declare -a BUILD_OPTIONS=($ISABELLE_BUILD_OPTIONS)"
    1.51 +
    1.52 +while getopts "ablo:" OPT
    1.53 +do
    1.54 +  case "$OPT" in
    1.55 +    a)
    1.56 +      ALL_SESSIONS="true"
    1.57 +      ;;
    1.58 +    b)
    1.59 +      BUILD_IMAGES="true"
    1.60 +      ;;
    1.61 +    l)
    1.62 +      LIST_ONLY="true"
    1.63 +      ;;
    1.64 +    o)
    1.65 +      BUILD_OPTIONS["${#BUILD_OPTIONS[@]}"]="$OPTARG"
    1.66 +      ;;
    1.67 +    \?)
    1.68 +      usage
    1.69 +      ;;
    1.70 +  esac
    1.71 +done
    1.72 +
    1.73 +shift $(($OPTIND - 1))
    1.74 +
    1.75 +
    1.76 +## main
    1.77 +
    1.78 +[ -e "$ISABELLE_HOME/Admin/build" ] && { "$ISABELLE_HOME/Admin/build" jars || exit $?; }
    1.79 +
    1.80 +exec "$ISABELLE_TOOL" java isabelle.Build \
    1.81 +  "$ALL_SESSIONS" "$BUILD_IMAGES" "$LIST_ONLY" "${BUILD_OPTIONS[@]}" $'\n' "$@"
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/Pure/System/build.scala	Tue Jul 17 15:56:19 2012 +0200
     2.3 @@ -0,0 +1,60 @@
     2.4 +/*  Title:      Pure/System/build.scala
     2.5 +    Author:     Makarius
     2.6 +
     2.7 +Build and manage Isabelle sessions.
     2.8 +*/
     2.9 +
    2.10 +package isabelle
    2.11 +
    2.12 +
    2.13 +object Build
    2.14 +{
    2.15 +  /* command line entry point */
    2.16 +
    2.17 +  private object Bool
    2.18 +  {
    2.19 +    def unapply(s: String): Option[Boolean] =
    2.20 +      s match {
    2.21 +        case "true" => Some(true)
    2.22 +        case "false" => Some(false)
    2.23 +        case _ => None
    2.24 +      }
    2.25 +  }
    2.26 +
    2.27 +  def main(args: Array[String])
    2.28 +  {
    2.29 +    def bad_args()
    2.30 +    {
    2.31 +      java.lang.System.err.println("Bad arguments: " + args.toString)
    2.32 +      sys.exit(2)
    2.33 +    }
    2.34 +
    2.35 +    args.toList match {
    2.36 +      case Bool(all_sessions) :: Bool(build_images) :: Bool(list_only) :: rest =>
    2.37 +        rest.indexWhere(_ == "\n") match {
    2.38 +          case -1 => bad_args()
    2.39 +          case i =>
    2.40 +            val (options, rest1) = rest.splitAt(i)
    2.41 +            val sessions = rest1.tail
    2.42 +            val rc = build(all_sessions, build_images, list_only, options, sessions)
    2.43 +            sys.exit(rc)
    2.44 +        }
    2.45 +      case _ => bad_args()
    2.46 +    }
    2.47 +  }
    2.48 +
    2.49 +
    2.50 +  /* build */
    2.51 +
    2.52 +  def build(all_sessions: Boolean, build_images: Boolean, list_only: Boolean,
    2.53 +    options: List[String], sessions: List[String]): Int =
    2.54 +  {
    2.55 +    val rc = 1
    2.56 +
    2.57 +    println("options = " + options.toString)
    2.58 +    println("sessions = " + sessions.toString)
    2.59 +
    2.60 +    rc
    2.61 +  }
    2.62 +}
    2.63 +
     3.1 --- a/src/Pure/build-jars	Tue Jul 17 14:33:23 2012 +0200
     3.2 +++ b/src/Pure/build-jars	Tue Jul 17 15:56:19 2012 +0200
     3.3 @@ -39,6 +39,7 @@
     3.4    PIDE/text.scala
     3.5    PIDE/xml.scala
     3.6    PIDE/yxml.scala
     3.7 +  System/build.scala
     3.8    System/event_bus.scala
     3.9    System/gui_setup.scala
    3.10    System/invoke_scala.scala