src/Pure/build-jars
author wenzelm
Sat Feb 23 11:27:45 2013 +0100 (2013-02-23)
changeset 51250 ca13a14cc52e
parent 51098 22d5c010ef5c
child 51504 18095684c5a6
permissions -rwxr-xr-x
support for POSIX interrupts (bypassed on Windows);
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@51098
    19
  General/graphics_file.scala
wenzelm@43320
    20
  General/linear_set.scala
wenzelm@43600
    21
  General/path.scala
wenzelm@43320
    22
  General/position.scala
wenzelm@43320
    23
  General/pretty.scala
wenzelm@43780
    24
  General/properties.scala
wenzelm@43320
    25
  General/scan.scala
wenzelm@43320
    26
  General/sha1.scala
wenzelm@43320
    27
  General/symbol.scala
wenzelm@45674
    28
  General/time.scala
wenzelm@45666
    29
  General/timing.scala
wenzelm@43320
    30
  Isar/keyword.scala
wenzelm@43320
    31
  Isar/outer_syntax.scala
wenzelm@43320
    32
  Isar/parse.scala
wenzelm@43320
    33
  Isar/token.scala
wenzelm@43320
    34
  PIDE/command.scala
wenzelm@43320
    35
  PIDE/document.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@49294
    42
  System/color_value.scala
wenzelm@48346
    43
  System/command_line.scala
wenzelm@43320
    44
  System/event_bus.scala
wenzelm@43320
    45
  System/gui_setup.scala
wenzelm@49066
    46
  System/html5_panel.scala
wenzelm@51250
    47
  System/interrupt.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@48365
    53
  System/options.scala
wenzelm@43320
    54
  System/platform.scala
wenzelm@43320
    55
  System/session.scala
wenzelm@43320
    56
  System/swing_thread.scala
wenzelm@45027
    57
  System/system_channel.scala
wenzelm@50203
    58
  System/utf8.scala
wenzelm@43320
    59
  Thy/completion.scala
wenzelm@43320
    60
  Thy/html.scala
wenzelm@50707
    61
  Thy/present.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@50686
    66
  Tools/build.scala
wenzelm@50686
    67
  Tools/build_dialog.scala
wenzelm@50687
    68
  Tools/main.scala
wenzelm@50981
    69
  Tools/ml_statistics.scala
wenzelm@50980
    70
  Tools/task_statistics.scala
wenzelm@43320
    71
  library.scala
wenzelm@43320
    72
  package.scala
wenzelm@43730
    73
  term.scala
wenzelm@43779
    74
  term_xml.scala
wenzelm@43320
    75
)
wenzelm@43320
    76
wenzelm@34282
    77
wenzelm@34282
    78
## diagnostics
wenzelm@34282
    79
wenzelm@43280
    80
PRG="$(basename "$0")"
wenzelm@43280
    81
wenzelm@43280
    82
function usage()
wenzelm@43280
    83
{
wenzelm@43280
    84
  echo
wenzelm@43280
    85
  echo "Usage: isabelle $PRG [OPTIONS]"
wenzelm@43280
    86
  echo
wenzelm@43280
    87
  echo "  Options are:"
wenzelm@43280
    88
  echo "    -f           fresh build"
wenzelm@47408
    89
  echo "    -t           test separate compilation of PIDE"
wenzelm@43280
    90
  echo
wenzelm@43280
    91
  exit 1
wenzelm@43280
    92
}
wenzelm@43280
    93
wenzelm@34282
    94
function fail()
wenzelm@34282
    95
{
wenzelm@34282
    96
  echo "$1" >&2
wenzelm@34282
    97
  exit 2
wenzelm@34282
    98
}
wenzelm@34282
    99
wenzelm@42899
   100
[ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
wenzelm@34282
   101
wenzelm@34282
   102
wenzelm@43280
   103
## process command line
wenzelm@43280
   104
wenzelm@43280
   105
# options
wenzelm@43280
   106
wenzelm@43280
   107
FRESH=""
wenzelm@47408
   108
TEST_PIDE=""
wenzelm@43280
   109
wenzelm@47408
   110
while getopts "ft" OPT
wenzelm@43280
   111
do
wenzelm@43280
   112
  case "$OPT" in
wenzelm@43280
   113
    f)
wenzelm@43280
   114
      FRESH=true
wenzelm@43280
   115
      ;;
wenzelm@47408
   116
    t)
wenzelm@47408
   117
      TEST_PIDE=true
wenzelm@47408
   118
      ;;
wenzelm@43280
   119
    \?)
wenzelm@43280
   120
      usage
wenzelm@43280
   121
      ;;
wenzelm@43280
   122
  esac
wenzelm@43280
   123
done
wenzelm@43280
   124
wenzelm@43280
   125
shift $(($OPTIND - 1))
wenzelm@43280
   126
wenzelm@43280
   127
wenzelm@43280
   128
# args
wenzelm@43280
   129
wenzelm@43280
   130
[ "$#" -ne 0 ] && usage
wenzelm@43280
   131
wenzelm@43280
   132
wenzelm@50689
   133
## dependencies
wenzelm@50689
   134
wenzelm@50689
   135
declare -a JFREECHART_JARS=()
wenzelm@50689
   136
for NAME in $JFREECHART_JAR_NAMES
wenzelm@50689
   137
do
wenzelm@50689
   138
  JFREECHART_JARS["${#JFREECHART_JARS[@]}"]="$JFREECHART_HOME/lib/$NAME"
wenzelm@50689
   139
done
wenzelm@50689
   140
wenzelm@50689
   141
wenzelm@49558
   142
## build
wenzelm@34282
   143
wenzelm@34284
   144
TARGET_DIR="$ISABELLE_HOME/lib/classes"
wenzelm@43523
   145
TARGET="$TARGET_DIR/ext/Pure.jar"
wenzelm@34282
   146
wenzelm@45673
   147
declare -a PIDE_SOURCES=()
wenzelm@45673
   148
declare -a PURE_SOURCES=()
wenzelm@45673
   149
wenzelm@45673
   150
for DEP in "${SOURCES[@]}"
wenzelm@45673
   151
do
wenzelm@45673
   152
  if grep "Module:.*PIDE" "$DEP" >/dev/null
wenzelm@45673
   153
  then
wenzelm@45673
   154
    PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   155
  else
wenzelm@45673
   156
    PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   157
  fi
wenzelm@45673
   158
done
wenzelm@45673
   159
wenzelm@43405
   160
declare -a UPDATED=()
wenzelm@43405
   161
wenzelm@43280
   162
if [ -n "$FRESH" ]; then
wenzelm@43280
   163
  OUTDATED=true
wenzelm@43280
   164
else
wenzelm@43280
   165
  OUTDATED=false
wenzelm@43523
   166
  if [ ! -e "$TARGET" ]; then
wenzelm@43523
   167
    OUTDATED=true
wenzelm@43523
   168
  else
wenzelm@43405
   169
    for DEP in "${SOURCES[@]}"
wenzelm@43280
   170
    do
wenzelm@43405
   171
      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
wenzelm@43523
   172
      [ "$DEP" -nt "$TARGET" ] && {
wenzelm@43523
   173
        OUTDATED=true
wenzelm@43523
   174
        UPDATED["${#UPDATED[@]}"]="$DEP"
wenzelm@43523
   175
      }
wenzelm@43280
   176
    done
wenzelm@43405
   177
  fi
wenzelm@43280
   178
fi
wenzelm@34282
   179
wenzelm@34284
   180
if [ "$OUTDATED" = true ]
wenzelm@34284
   181
then
wenzelm@49173
   182
  echo "### Building Isabelle/Scala ..."
wenzelm@34282
   183
wenzelm@43405
   184
  [ "${#UPDATED[@]}" -gt 0 ] && {
wenzelm@43405
   185
    echo "Changed files:"
wenzelm@43405
   186
    for FILE in "${UPDATED[@]}"
wenzelm@43405
   187
    do
wenzelm@43405
   188
      echo "  $FILE"
wenzelm@43405
   189
    done
wenzelm@43405
   190
  }
wenzelm@43405
   191
wenzelm@34282
   192
  rm -rf classes && mkdir classes
wenzelm@45673
   193
wenzelm@47009
   194
  SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
wenzelm@45673
   195
wenzelm@49067
   196
  JFXRT="$ISABELLE_JDK_HOME/jre/lib/jfxrt.jar"
wenzelm@49067
   197
wenzelm@50689
   198
  (
wenzelm@50689
   199
    for X in "$JFXRT" "${JFREECHART_JARS[@]}" classes
wenzelm@50689
   200
    do
wenzelm@50689
   201
      CLASSPATH="$CLASSPATH:$X"
wenzelm@50689
   202
    done
wenzelm@50689
   203
    CLASSPATH="$(jvmpath "$CLASSPATH")"
wenzelm@50689
   204
wenzelm@50689
   205
    if [ "$TEST_PIDE" = true ]; then
wenzelm@50689
   206
      isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
wenzelm@50689
   207
        fail "Failed to compile PIDE sources"
wenzelm@50689
   208
      isabelle_scala scalac $SCALAC_OPTIONS "${PURE_SOURCES[@]}" || \
wenzelm@50689
   209
        fail "Failed to compile Pure sources"
wenzelm@50689
   210
    else
wenzelm@50689
   211
      isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
wenzelm@50689
   212
        fail "Failed to compile sources"
wenzelm@50689
   213
    fi
wenzelm@50689
   214
  )
wenzelm@45673
   215
wenzelm@43523
   216
  mkdir -p "$TARGET_DIR/ext" || fail "Failed to create directory $TARGET_DIR/ext"
wenzelm@43280
   217
wenzelm@43285
   218
  pushd classes >/dev/null
wenzelm@43280
   219
wenzelm@43517
   220
  CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
wenzelm@43517
   221
  mkdir -p "$(dirname "$CHARSET_SERVICE")"
wenzelm@43517
   222
  echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
wenzelm@43517
   223
wenzelm@47115
   224
  isabelle_jdk jar cfe "$(jvmpath "$TARGET")" isabelle.GUI_Setup META-INF isabelle || \
wenzelm@43523
   225
    fail "Failed to produce $TARGET"
wenzelm@34282
   226
wenzelm@49449
   227
  cp "$SCALA_HOME/lib/scala-compiler.jar" \
wenzelm@47995
   228
    "$SCALA_HOME/lib/scala-library.jar" \
wenzelm@47995
   229
    "$SCALA_HOME/lib/scala-swing.jar" "$TARGET_DIR/ext"
wenzelm@47995
   230
wenzelm@47849
   231
  [ -e "$SCALA_HOME/lib/scala-actors.jar" ] && \
wenzelm@47849
   232
    cp "$SCALA_HOME/lib/scala-actors.jar" "$TARGET_DIR/ext"
wenzelm@43521
   233
wenzelm@49955
   234
  [ -e "$SCALA_HOME/lib/scala-reflect.jar" ] && \
wenzelm@49955
   235
    cp "$SCALA_HOME/lib/scala-reflect.jar" "$TARGET_DIR/ext"
wenzelm@49955
   236
wenzelm@43280
   237
  popd >/dev/null
wenzelm@43280
   238
wenzelm@34282
   239
  rm -rf classes
wenzelm@34282
   240
fi