support fresh build of jars;
authorwenzelm
Wed Jun 08 17:11:00 2011 +0200 (2011-06-08)
changeset 43280e5dd0ae1b054
parent 43279 6af741899bf6
child 43281 8d8b6ed0588c
support fresh build of jars;
prefer pushd/popd, to avoid unclarity about fail/exit within sub-shell;
Admin/build
src/Pure/build-jars
     1.1 --- a/Admin/build	Wed Jun 08 16:19:22 2011 +0200
     1.2 +++ b/Admin/build	Wed Jun 08 17:11:00 2011 +0200
     1.3 @@ -27,6 +27,7 @@
     1.4      browser         graph browser (requires jdk)
     1.5      doc             documentation (requires latex and rail)
     1.6      jars            Isabelle/Scala layer (requires Scala in \$SCALA_HOME)
     1.7 +    jars_fresh      fresh build of jars
     1.8  
     1.9  EOF
    1.10    exit 1
    1.11 @@ -84,7 +85,7 @@
    1.12  function build_jars ()
    1.13  {
    1.14    pushd "$ISABELLE_HOME/src/Pure" >/dev/null
    1.15 -  "$ISABELLE_TOOL" env ./build-jars || exit $?
    1.16 +  "$ISABELLE_TOOL" env ./build-jars "$@" || exit $?
    1.17    popd >/dev/null
    1.18  }
    1.19  
    1.20 @@ -98,6 +99,7 @@
    1.21      browser) build_browser;;
    1.22      doc) build_doc;;
    1.23      jars) build_jars;;
    1.24 +    jars_fresh) build_jars -f;;
    1.25      *) fail "Bad module $MODULE"
    1.26    esac
    1.27  done
     2.1 --- a/src/Pure/build-jars	Wed Jun 08 16:19:22 2011 +0200
     2.2 +++ b/src/Pure/build-jars	Wed Jun 08 17:11:00 2011 +0200
     2.3 @@ -9,6 +9,19 @@
     2.4  
     2.5  ## diagnostics
     2.6  
     2.7 +PRG="$(basename "$0")"
     2.8 +
     2.9 +function usage()
    2.10 +{
    2.11 +  echo
    2.12 +  echo "Usage: isabelle $PRG [OPTIONS]"
    2.13 +  echo
    2.14 +  echo "  Options are:"
    2.15 +  echo "    -f           fresh build"
    2.16 +  echo
    2.17 +  exit 1
    2.18 +}
    2.19 +
    2.20  function fail()
    2.21  {
    2.22    echo "$1" >&2
    2.23 @@ -19,6 +32,33 @@
    2.24  [ -z "$SCALA_HOME" ] && fail "Unknown SCALA_HOME -- Scala unavailable"
    2.25  
    2.26  
    2.27 +## process command line
    2.28 +
    2.29 +# options
    2.30 +
    2.31 +FRESH=""
    2.32 +
    2.33 +while getopts "f" OPT
    2.34 +do
    2.35 +  case "$OPT" in
    2.36 +    f)
    2.37 +      FRESH=true
    2.38 +      ;;
    2.39 +    \?)
    2.40 +      usage
    2.41 +      ;;
    2.42 +  esac
    2.43 +done
    2.44 +
    2.45 +shift $(($OPTIND - 1))
    2.46 +
    2.47 +
    2.48 +# args
    2.49 +
    2.50 +[ "$#" -ne 0 ] && usage
    2.51 +
    2.52 +
    2.53 +
    2.54  ## dependencies
    2.55  
    2.56  declare -a SOURCES=(
    2.57 @@ -75,16 +115,19 @@
    2.58  
    2.59  ## main
    2.60  
    2.61 -OUTDATED=false
    2.62 -
    2.63 -for SOURCE in "${SOURCES[@]}"
    2.64 -do
    2.65 -  [ ! -e "$SOURCE" ] && fail "Missing source file: $SOURCE"
    2.66 -  for TARGET in "${TARGETS[@]}"
    2.67 +if [ -n "$FRESH" ]; then
    2.68 +  OUTDATED=true
    2.69 +else
    2.70 +  OUTDATED=false
    2.71 +  for SOURCE in "${SOURCES[@]}"
    2.72    do
    2.73 -    [ ! -e "$TARGET" -o "$SOURCE" -nt "$TARGET" ] && OUTDATED=true
    2.74 +    [ ! -e "$SOURCE" ] && fail "Missing source file: $SOURCE"
    2.75 +    for TARGET in "${TARGETS[@]}"
    2.76 +    do
    2.77 +      [ ! -e "$TARGET" -o "$SOURCE" -nt "$TARGET" ] && OUTDATED=true
    2.78 +    done
    2.79    done
    2.80 -done
    2.81 +fi
    2.82  
    2.83  if [ "$OUTDATED" = true ]
    2.84  then
    2.85 @@ -96,17 +139,20 @@
    2.86    "$SCALA_HOME/bin/scalac" -unchecked -deprecation -d classes -target:jvm-1.5 "${SOURCES[@]}" || \
    2.87      fail "Failed to compile sources"
    2.88    mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
    2.89 -  (
    2.90 -    cd classes
    2.91 -    jar cfe "$(jvmpath "$PURE_JAR")" isabelle.GUI_Setup isabelle || \
    2.92 -      fail "Failed to produce $PURE_JAR"
    2.93 +
    2.94 +  pushd classes
    2.95 +
    2.96 +  jar cfe "$(jvmpath "$PURE_JAR")" isabelle.GUI_Setup isabelle || \
    2.97 +    fail "Failed to produce $PURE_JAR"
    2.98  
    2.99 -    cp "$SCALA_HOME/lib/scala-swing.jar" .
   2.100 -    jar xf scala-swing.jar
   2.101 +  cp "$SCALA_HOME/lib/scala-swing.jar" .
   2.102 +  jar xf scala-swing.jar
   2.103  
   2.104 -    cp "$SCALA_HOME/lib/scala-library.jar" "$FULL_JAR"
   2.105 -    jar ufe "$(jvmpath "$FULL_JAR")" isabelle.GUI_Setup isabelle scala || \
   2.106 -      fail "Failed to produce $FULL_JAR"
   2.107 -  )
   2.108 +  cp "$SCALA_HOME/lib/scala-library.jar" "$FULL_JAR"
   2.109 +  jar ufe "$(jvmpath "$FULL_JAR")" isabelle.GUI_Setup isabelle scala || \
   2.110 +    fail "Failed to produce $FULL_JAR"
   2.111 +
   2.112 +  popd >/dev/null
   2.113 +
   2.114    rm -rf classes
   2.115  fi