src/Pure/build-jars
author wenzelm
Wed Jun 15 21:22:51 2011 +0200 (2011-06-15)
changeset 43405 723a8af9d3f0
parent 43320 657635e0445a
child 43517 87ec9a1c0f98
permissions -rwxr-xr-x
tuned messages;
wenzelm@34282
     1
#!/usr/bin/env bash
wenzelm@34282
     2
#
wenzelm@34282
     3
# Author: Makarius
wenzelm@34282
     4
#
wenzelm@42899
     5
# build-jars - build Isabelle/Scala
wenzelm@34282
     6
#
wenzelm@34282
     7
# Requires proper Isabelle settings environment.
wenzelm@34282
     8
wenzelm@43320
     9
## sources
wenzelm@43320
    10
wenzelm@43320
    11
declare -a SOURCES=(
wenzelm@43320
    12
  Concurrent/future.scala
wenzelm@43320
    13
  Concurrent/simple_thread.scala
wenzelm@43320
    14
  Concurrent/volatile.scala
wenzelm@43320
    15
  General/exn.scala
wenzelm@43320
    16
  General/timing.scala
wenzelm@43320
    17
  General/linear_set.scala
wenzelm@43320
    18
  General/markup.scala
wenzelm@43320
    19
  General/position.scala
wenzelm@43320
    20
  General/pretty.scala
wenzelm@43320
    21
  General/scan.scala
wenzelm@43320
    22
  General/sha1.scala
wenzelm@43320
    23
  General/symbol.scala
wenzelm@43320
    24
  General/xml.scala
wenzelm@43320
    25
  General/xml_data.scala
wenzelm@43320
    26
  General/yxml.scala
wenzelm@43320
    27
  Isar/keyword.scala
wenzelm@43320
    28
  Isar/outer_syntax.scala
wenzelm@43320
    29
  Isar/parse.scala
wenzelm@43320
    30
  Isar/token.scala
wenzelm@43320
    31
  PIDE/command.scala
wenzelm@43320
    32
  PIDE/document.scala
wenzelm@43320
    33
  PIDE/isar_document.scala
wenzelm@43320
    34
  PIDE/markup_tree.scala
wenzelm@43320
    35
  PIDE/text.scala
wenzelm@43320
    36
  System/cygwin.scala
wenzelm@43320
    37
  System/download.scala
wenzelm@43320
    38
  System/event_bus.scala
wenzelm@43320
    39
  System/gui_setup.scala
wenzelm@43320
    40
  System/isabelle_process.scala
wenzelm@43320
    41
  System/isabelle_syntax.scala
wenzelm@43320
    42
  System/isabelle_system.scala
wenzelm@43320
    43
  System/platform.scala
wenzelm@43320
    44
  System/session.scala
wenzelm@43320
    45
  System/session_manager.scala
wenzelm@43320
    46
  System/standard_system.scala
wenzelm@43320
    47
  System/swing_thread.scala
wenzelm@43320
    48
  Thy/completion.scala
wenzelm@43320
    49
  Thy/html.scala
wenzelm@43320
    50
  Thy/thy_header.scala
wenzelm@43320
    51
  Thy/thy_syntax.scala
wenzelm@43320
    52
  library.scala
wenzelm@43320
    53
  package.scala
wenzelm@43320
    54
)
wenzelm@43320
    55
wenzelm@34282
    56
wenzelm@34282
    57
## diagnostics
wenzelm@34282
    58
wenzelm@43280
    59
PRG="$(basename "$0")"
wenzelm@43280
    60
wenzelm@43280
    61
function usage()
wenzelm@43280
    62
{
wenzelm@43280
    63
  echo
wenzelm@43280
    64
  echo "Usage: isabelle $PRG [OPTIONS]"
wenzelm@43280
    65
  echo
wenzelm@43280
    66
  echo "  Options are:"
wenzelm@43280
    67
  echo "    -f           fresh build"
wenzelm@43280
    68
  echo
wenzelm@43280
    69
  exit 1
wenzelm@43280
    70
}
wenzelm@43280
    71
wenzelm@34282
    72
function fail()
wenzelm@34282
    73
{
wenzelm@34282
    74
  echo "$1" >&2
wenzelm@34282
    75
  exit 2
wenzelm@34282
    76
}
wenzelm@34282
    77
wenzelm@42899
    78
[ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
wenzelm@37174
    79
[ -z "$SCALA_HOME" ] && fail "Unknown SCALA_HOME -- Scala unavailable"
wenzelm@34282
    80
wenzelm@34282
    81
wenzelm@43280
    82
## process command line
wenzelm@43280
    83
wenzelm@43280
    84
# options
wenzelm@43280
    85
wenzelm@43280
    86
FRESH=""
wenzelm@43280
    87
wenzelm@43280
    88
while getopts "f" OPT
wenzelm@43280
    89
do
wenzelm@43280
    90
  case "$OPT" in
wenzelm@43280
    91
    f)
wenzelm@43280
    92
      FRESH=true
wenzelm@43280
    93
      ;;
wenzelm@43280
    94
    \?)
wenzelm@43280
    95
      usage
wenzelm@43280
    96
      ;;
wenzelm@43280
    97
  esac
wenzelm@43280
    98
done
wenzelm@43280
    99
wenzelm@43280
   100
shift $(($OPTIND - 1))
wenzelm@43280
   101
wenzelm@43280
   102
wenzelm@43280
   103
# args
wenzelm@43280
   104
wenzelm@43280
   105
[ "$#" -ne 0 ] && usage
wenzelm@43280
   106
wenzelm@43280
   107
wenzelm@43280
   108
wenzelm@34282
   109
## dependencies
wenzelm@34282
   110
wenzelm@34284
   111
TARGET_DIR="$ISABELLE_HOME/lib/classes"
wenzelm@34284
   112
PURE_JAR="$TARGET_DIR/Pure.jar"
wenzelm@34284
   113
FULL_JAR="$TARGET_DIR/isabelle-scala.jar"
wenzelm@34284
   114
wenzelm@34284
   115
declare -a TARGETS=("$PURE_JAR" "$FULL_JAR")
wenzelm@34282
   116
wenzelm@34282
   117
wenzelm@34282
   118
## main
wenzelm@34282
   119
wenzelm@43405
   120
declare -a UPDATED=()
wenzelm@43405
   121
wenzelm@43280
   122
if [ -n "$FRESH" ]; then
wenzelm@43280
   123
  OUTDATED=true
wenzelm@43280
   124
else
wenzelm@43280
   125
  OUTDATED=false
wenzelm@43405
   126
  for TARGET in "${TARGETS[@]}"
wenzelm@34282
   127
  do
wenzelm@43405
   128
    [ ! -e "$TARGET" ] && OUTDATED=true
wenzelm@43405
   129
  done
wenzelm@43405
   130
  if [ "$OUTDATED" = false ]; then
wenzelm@43405
   131
    for DEP in "${SOURCES[@]}"
wenzelm@43280
   132
    do
wenzelm@43405
   133
      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
wenzelm@43405
   134
      UPDATE=""
wenzelm@43405
   135
      for TARGET in "${TARGETS[@]}"
wenzelm@43405
   136
      do
wenzelm@43405
   137
        [ "$DEP" -nt "$TARGET" ] && {
wenzelm@43405
   138
          OUTDATED=true
wenzelm@43405
   139
          UPDATE=true
wenzelm@43405
   140
        }
wenzelm@43405
   141
      done
wenzelm@43405
   142
      [ -n "$UPDATE" ] && UPDATED["${#UPDATED[@]}"]="$DEP"
wenzelm@43280
   143
    done
wenzelm@43405
   144
  fi
wenzelm@43280
   145
fi
wenzelm@34282
   146
wenzelm@34284
   147
if [ "$OUTDATED" = true ]
wenzelm@34284
   148
then
wenzelm@34282
   149
  echo "###"
wenzelm@34876
   150
  echo "### Building Isabelle/Scala layer ..."
wenzelm@34282
   151
  echo "###"
wenzelm@34282
   152
wenzelm@43405
   153
  [ "${#UPDATED[@]}" -gt 0 ] && {
wenzelm@43405
   154
    echo "Changed files:"
wenzelm@43405
   155
    for FILE in "${UPDATED[@]}"
wenzelm@43405
   156
    do
wenzelm@43405
   157
      echo "  $FILE"
wenzelm@43405
   158
    done
wenzelm@43405
   159
  }
wenzelm@43405
   160
wenzelm@34282
   161
  rm -rf classes && mkdir classes
wenzelm@36011
   162
  "$SCALA_HOME/bin/scalac" -unchecked -deprecation -d classes -target:jvm-1.5 "${SOURCES[@]}" || \
wenzelm@34282
   163
    fail "Failed to compile sources"
wenzelm@34284
   164
  mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
wenzelm@43280
   165
wenzelm@43285
   166
  pushd classes >/dev/null
wenzelm@43280
   167
wenzelm@43280
   168
  jar cfe "$(jvmpath "$PURE_JAR")" isabelle.GUI_Setup isabelle || \
wenzelm@43280
   169
    fail "Failed to produce $PURE_JAR"
wenzelm@34282
   170
wenzelm@43280
   171
  cp "$SCALA_HOME/lib/scala-swing.jar" .
wenzelm@43280
   172
  jar xf scala-swing.jar
wenzelm@34282
   173
wenzelm@43280
   174
  cp "$SCALA_HOME/lib/scala-library.jar" "$FULL_JAR"
wenzelm@43280
   175
  jar ufe "$(jvmpath "$FULL_JAR")" isabelle.GUI_Setup isabelle scala || \
wenzelm@43280
   176
    fail "Failed to produce $FULL_JAR"
wenzelm@43280
   177
wenzelm@43280
   178
  popd >/dev/null
wenzelm@43280
   179
wenzelm@34282
   180
  rm -rf classes
wenzelm@34282
   181
fi