src/Pure/build-jars
author wenzelm
Thu May 24 22:49:39 2012 +0200 (2012-05-24)
changeset 47995 72f52cd7c633
parent 47849 48b52cdc214a
child 47997 0a43fc778cd2
permissions -rwxr-xr-x
include scala-compiler.jar in basic Isabelle/Scala environment, to make Isabelle/jEdit console work with scala-2.10.0-M3;
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@43660
    12
  Concurrent/counter.scala
wenzelm@43320
    13
  Concurrent/future.scala
wenzelm@43320
    14
  Concurrent/simple_thread.scala
wenzelm@43320
    15
  Concurrent/volatile.scala
wenzelm@43320
    16
  General/exn.scala
wenzelm@46611
    17
  General/graph.scala
wenzelm@43320
    18
  General/linear_set.scala
wenzelm@43600
    19
  General/path.scala
wenzelm@43320
    20
  General/position.scala
wenzelm@43320
    21
  General/pretty.scala
wenzelm@43780
    22
  General/properties.scala
wenzelm@43320
    23
  General/scan.scala
wenzelm@43320
    24
  General/sha1.scala
wenzelm@43320
    25
  General/symbol.scala
wenzelm@45674
    26
  General/time.scala
wenzelm@45666
    27
  General/timing.scala
wenzelm@43320
    28
  Isar/keyword.scala
wenzelm@43320
    29
  Isar/outer_syntax.scala
wenzelm@43320
    30
  Isar/parse.scala
wenzelm@43320
    31
  Isar/token.scala
wenzelm@43715
    32
  PIDE/blob.scala
wenzelm@43320
    33
  PIDE/command.scala
wenzelm@43320
    34
  PIDE/document.scala
wenzelm@45670
    35
  PIDE/isabelle_markup.scala
wenzelm@45670
    36
  PIDE/markup.scala
wenzelm@43320
    37
  PIDE/markup_tree.scala
wenzelm@45709
    38
  PIDE/protocol.scala
wenzelm@43320
    39
  PIDE/text.scala
wenzelm@44698
    40
  PIDE/xml.scala
wenzelm@44698
    41
  PIDE/yxml.scala
wenzelm@43320
    42
  System/cygwin.scala
wenzelm@43320
    43
  System/download.scala
wenzelm@43320
    44
  System/event_bus.scala
wenzelm@43320
    45
  System/gui_setup.scala
wenzelm@43744
    46
  System/invoke_scala.scala
wenzelm@43517
    47
  System/isabelle_charset.scala
wenzelm@43320
    48
  System/isabelle_process.scala
wenzelm@43320
    49
  System/isabelle_system.scala
wenzelm@47663
    50
  System/main.scala
wenzelm@43320
    51
  System/platform.scala
wenzelm@43320
    52
  System/session.scala
wenzelm@43320
    53
  System/session_manager.scala
wenzelm@43320
    54
  System/standard_system.scala
wenzelm@43320
    55
  System/swing_thread.scala
wenzelm@45027
    56
  System/system_channel.scala
wenzelm@43320
    57
  Thy/completion.scala
wenzelm@43320
    58
  Thy/html.scala
wenzelm@43320
    59
  Thy/thy_header.scala
wenzelm@43651
    60
  Thy/thy_info.scala
wenzelm@43651
    61
  Thy/thy_load.scala
wenzelm@43320
    62
  Thy/thy_syntax.scala
wenzelm@43320
    63
  library.scala
wenzelm@43320
    64
  package.scala
wenzelm@43730
    65
  term.scala
wenzelm@43779
    66
  term_xml.scala
wenzelm@43320
    67
)
wenzelm@43320
    68
wenzelm@34282
    69
wenzelm@34282
    70
## diagnostics
wenzelm@34282
    71
wenzelm@43280
    72
PRG="$(basename "$0")"
wenzelm@43280
    73
wenzelm@43280
    74
function usage()
wenzelm@43280
    75
{
wenzelm@43280
    76
  echo
wenzelm@43280
    77
  echo "Usage: isabelle $PRG [OPTIONS]"
wenzelm@43280
    78
  echo
wenzelm@43280
    79
  echo "  Options are:"
wenzelm@43280
    80
  echo "    -f           fresh build"
wenzelm@47408
    81
  echo "    -t           test separate compilation of PIDE"
wenzelm@43280
    82
  echo
wenzelm@43280
    83
  exit 1
wenzelm@43280
    84
}
wenzelm@43280
    85
wenzelm@34282
    86
function fail()
wenzelm@34282
    87
{
wenzelm@34282
    88
  echo "$1" >&2
wenzelm@34282
    89
  exit 2
wenzelm@34282
    90
}
wenzelm@34282
    91
wenzelm@42899
    92
[ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
wenzelm@34282
    93
wenzelm@34282
    94
wenzelm@43280
    95
## process command line
wenzelm@43280
    96
wenzelm@43280
    97
# options
wenzelm@43280
    98
wenzelm@43280
    99
FRESH=""
wenzelm@47408
   100
TEST_PIDE=""
wenzelm@43280
   101
wenzelm@47408
   102
while getopts "ft" OPT
wenzelm@43280
   103
do
wenzelm@43280
   104
  case "$OPT" in
wenzelm@43280
   105
    f)
wenzelm@43280
   106
      FRESH=true
wenzelm@43280
   107
      ;;
wenzelm@47408
   108
    t)
wenzelm@47408
   109
      TEST_PIDE=true
wenzelm@47408
   110
      ;;
wenzelm@43280
   111
    \?)
wenzelm@43280
   112
      usage
wenzelm@43280
   113
      ;;
wenzelm@43280
   114
  esac
wenzelm@43280
   115
done
wenzelm@43280
   116
wenzelm@43280
   117
shift $(($OPTIND - 1))
wenzelm@43280
   118
wenzelm@43280
   119
wenzelm@43280
   120
# args
wenzelm@43280
   121
wenzelm@43280
   122
[ "$#" -ne 0 ] && usage
wenzelm@43280
   123
wenzelm@43280
   124
wenzelm@43280
   125
wenzelm@43523
   126
# build
wenzelm@34282
   127
wenzelm@34284
   128
TARGET_DIR="$ISABELLE_HOME/lib/classes"
wenzelm@43523
   129
TARGET="$TARGET_DIR/ext/Pure.jar"
wenzelm@34282
   130
wenzelm@45673
   131
declare -a PIDE_SOURCES=()
wenzelm@45673
   132
declare -a PURE_SOURCES=()
wenzelm@45673
   133
wenzelm@45673
   134
for DEP in "${SOURCES[@]}"
wenzelm@45673
   135
do
wenzelm@45673
   136
  if grep "Module:.*PIDE" "$DEP" >/dev/null
wenzelm@45673
   137
  then
wenzelm@45673
   138
    PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   139
  else
wenzelm@45673
   140
    PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   141
  fi
wenzelm@45673
   142
done
wenzelm@45673
   143
wenzelm@43405
   144
declare -a UPDATED=()
wenzelm@43405
   145
wenzelm@43280
   146
if [ -n "$FRESH" ]; then
wenzelm@43280
   147
  OUTDATED=true
wenzelm@43280
   148
else
wenzelm@43280
   149
  OUTDATED=false
wenzelm@43523
   150
  if [ ! -e "$TARGET" ]; then
wenzelm@43523
   151
    OUTDATED=true
wenzelm@43523
   152
  else
wenzelm@43405
   153
    for DEP in "${SOURCES[@]}"
wenzelm@43280
   154
    do
wenzelm@43405
   155
      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
wenzelm@43523
   156
      [ "$DEP" -nt "$TARGET" ] && {
wenzelm@43523
   157
        OUTDATED=true
wenzelm@43523
   158
        UPDATED["${#UPDATED[@]}"]="$DEP"
wenzelm@43523
   159
      }
wenzelm@43280
   160
    done
wenzelm@43405
   161
  fi
wenzelm@43280
   162
fi
wenzelm@34282
   163
wenzelm@34284
   164
if [ "$OUTDATED" = true ]
wenzelm@34284
   165
then
wenzelm@34876
   166
  echo "### Building Isabelle/Scala layer ..."
wenzelm@34282
   167
wenzelm@43405
   168
  [ "${#UPDATED[@]}" -gt 0 ] && {
wenzelm@43405
   169
    echo "Changed files:"
wenzelm@43405
   170
    for FILE in "${UPDATED[@]}"
wenzelm@43405
   171
    do
wenzelm@43405
   172
      echo "  $FILE"
wenzelm@43405
   173
    done
wenzelm@43405
   174
  }
wenzelm@43405
   175
wenzelm@34282
   176
  rm -rf classes && mkdir classes
wenzelm@45673
   177
wenzelm@47009
   178
  SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
wenzelm@45673
   179
wenzelm@47408
   180
  if [ "$TEST_PIDE" = true ]; then
wenzelm@47408
   181
    isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
wenzelm@47408
   182
      fail "Failed to compile PIDE sources"
wenzelm@47408
   183
    isabelle_scala scalac $SCALAC_OPTIONS -classpath classes "${PURE_SOURCES[@]}" || \
wenzelm@47408
   184
      fail "Failed to compile Pure sources"
wenzelm@47408
   185
  else
wenzelm@47408
   186
    isabelle_scala scalac $SCALAC_OPTIONS -classpath classes \
wenzelm@47408
   187
      "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
wenzelm@47408
   188
      fail "Failed to compile sources"
wenzelm@47408
   189
  fi
wenzelm@45673
   190
wenzelm@43523
   191
  mkdir -p "$TARGET_DIR/ext" || fail "Failed to create directory $TARGET_DIR/ext"
wenzelm@43280
   192
wenzelm@43285
   193
  pushd classes >/dev/null
wenzelm@43280
   194
wenzelm@43517
   195
  CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
wenzelm@43517
   196
  mkdir -p "$(dirname "$CHARSET_SERVICE")"
wenzelm@43517
   197
  echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
wenzelm@43517
   198
wenzelm@47115
   199
  isabelle_jdk jar cfe "$(jvmpath "$TARGET")" isabelle.GUI_Setup META-INF isabelle || \
wenzelm@43523
   200
    fail "Failed to produce $TARGET"
wenzelm@34282
   201
wenzelm@47995
   202
  cp "$SCALA_HOME/lib/scala-compiler.jar" \
wenzelm@47995
   203
    "$SCALA_HOME/lib/scala-library.jar" \
wenzelm@47995
   204
    "$SCALA_HOME/lib/scala-swing.jar" "$TARGET_DIR/ext"
wenzelm@47995
   205
wenzelm@47849
   206
  [ -e "$SCALA_HOME/lib/scala-actors.jar" ] && \
wenzelm@47849
   207
    cp "$SCALA_HOME/lib/scala-actors.jar" "$TARGET_DIR/ext"
wenzelm@43521
   208
wenzelm@43280
   209
  popd >/dev/null
wenzelm@43280
   210
wenzelm@34282
   211
  rm -rf classes
wenzelm@34282
   212
fi