src/Pure/build-jars
changeset 43280 e5dd0ae1b054
parent 42899 108e815fdc8e
child 43285 966f359dc724
     1.1 --- a/src/Pure/build-jars	Wed Jun 08 16:19:22 2011 +0200
     1.2 +++ b/src/Pure/build-jars	Wed Jun 08 17:11:00 2011 +0200
     1.3 @@ -9,6 +9,19 @@
     1.4  
     1.5  ## diagnostics
     1.6  
     1.7 +PRG="$(basename "$0")"
     1.8 +
     1.9 +function usage()
    1.10 +{
    1.11 +  echo
    1.12 +  echo "Usage: isabelle $PRG [OPTIONS]"
    1.13 +  echo
    1.14 +  echo "  Options are:"
    1.15 +  echo "    -f           fresh build"
    1.16 +  echo
    1.17 +  exit 1
    1.18 +}
    1.19 +
    1.20  function fail()
    1.21  {
    1.22    echo "$1" >&2
    1.23 @@ -19,6 +32,33 @@
    1.24  [ -z "$SCALA_HOME" ] && fail "Unknown SCALA_HOME -- Scala unavailable"
    1.25  
    1.26  
    1.27 +## process command line
    1.28 +
    1.29 +# options
    1.30 +
    1.31 +FRESH=""
    1.32 +
    1.33 +while getopts "f" OPT
    1.34 +do
    1.35 +  case "$OPT" in
    1.36 +    f)
    1.37 +      FRESH=true
    1.38 +      ;;
    1.39 +    \?)
    1.40 +      usage
    1.41 +      ;;
    1.42 +  esac
    1.43 +done
    1.44 +
    1.45 +shift $(($OPTIND - 1))
    1.46 +
    1.47 +
    1.48 +# args
    1.49 +
    1.50 +[ "$#" -ne 0 ] && usage
    1.51 +
    1.52 +
    1.53 +
    1.54  ## dependencies
    1.55  
    1.56  declare -a SOURCES=(
    1.57 @@ -75,16 +115,19 @@
    1.58  
    1.59  ## main
    1.60  
    1.61 -OUTDATED=false
    1.62 -
    1.63 -for SOURCE in "${SOURCES[@]}"
    1.64 -do
    1.65 -  [ ! -e "$SOURCE" ] && fail "Missing source file: $SOURCE"
    1.66 -  for TARGET in "${TARGETS[@]}"
    1.67 +if [ -n "$FRESH" ]; then
    1.68 +  OUTDATED=true
    1.69 +else
    1.70 +  OUTDATED=false
    1.71 +  for SOURCE in "${SOURCES[@]}"
    1.72    do
    1.73 -    [ ! -e "$TARGET" -o "$SOURCE" -nt "$TARGET" ] && OUTDATED=true
    1.74 +    [ ! -e "$SOURCE" ] && fail "Missing source file: $SOURCE"
    1.75 +    for TARGET in "${TARGETS[@]}"
    1.76 +    do
    1.77 +      [ ! -e "$TARGET" -o "$SOURCE" -nt "$TARGET" ] && OUTDATED=true
    1.78 +    done
    1.79    done
    1.80 -done
    1.81 +fi
    1.82  
    1.83  if [ "$OUTDATED" = true ]
    1.84  then
    1.85 @@ -96,17 +139,20 @@
    1.86    "$SCALA_HOME/bin/scalac" -unchecked -deprecation -d classes -target:jvm-1.5 "${SOURCES[@]}" || \
    1.87      fail "Failed to compile sources"
    1.88    mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
    1.89 -  (
    1.90 -    cd classes
    1.91 -    jar cfe "$(jvmpath "$PURE_JAR")" isabelle.GUI_Setup isabelle || \
    1.92 -      fail "Failed to produce $PURE_JAR"
    1.93 +
    1.94 +  pushd classes
    1.95 +
    1.96 +  jar cfe "$(jvmpath "$PURE_JAR")" isabelle.GUI_Setup isabelle || \
    1.97 +    fail "Failed to produce $PURE_JAR"
    1.98  
    1.99 -    cp "$SCALA_HOME/lib/scala-swing.jar" .
   1.100 -    jar xf scala-swing.jar
   1.101 +  cp "$SCALA_HOME/lib/scala-swing.jar" .
   1.102 +  jar xf scala-swing.jar
   1.103  
   1.104 -    cp "$SCALA_HOME/lib/scala-library.jar" "$FULL_JAR"
   1.105 -    jar ufe "$(jvmpath "$FULL_JAR")" isabelle.GUI_Setup isabelle scala || \
   1.106 -      fail "Failed to produce $FULL_JAR"
   1.107 -  )
   1.108 +  cp "$SCALA_HOME/lib/scala-library.jar" "$FULL_JAR"
   1.109 +  jar ufe "$(jvmpath "$FULL_JAR")" isabelle.GUI_Setup isabelle scala || \
   1.110 +    fail "Failed to produce $FULL_JAR"
   1.111 +
   1.112 +  popd >/dev/null
   1.113 +
   1.114    rm -rf classes
   1.115  fi