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