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