src/Pure/build-jars
author wenzelm
Tue Jul 16 12:31:08 2013 +0200 (2013-07-16)
changeset 52671 9a360530eac8
parent 52667 d2b12523186d
child 52971 31926d2c04ee
permissions -rwxr-xr-x
separate module XZ_File to avoid initial dependency on org.tukaani.xz;
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@52671
    30
  General/xz_file.scala
wenzelm@43320
    31
  Isar/keyword.scala
wenzelm@43320
    32
  Isar/outer_syntax.scala
wenzelm@43320
    33
  Isar/parse.scala
wenzelm@43320
    34
  Isar/token.scala
wenzelm@43320
    35
  PIDE/command.scala
wenzelm@43320
    36
  PIDE/document.scala
wenzelm@52530
    37
  PIDE/document_id.scala
wenzelm@45670
    38
  PIDE/markup.scala
wenzelm@43320
    39
  PIDE/markup_tree.scala
wenzelm@45709
    40
  PIDE/protocol.scala
wenzelm@43320
    41
  PIDE/text.scala
wenzelm@44698
    42
  PIDE/xml.scala
wenzelm@44698
    43
  PIDE/yxml.scala
wenzelm@49294
    44
  System/color_value.scala
wenzelm@48346
    45
  System/command_line.scala
wenzelm@52667
    46
  System/cygwin_init.scala
wenzelm@43320
    47
  System/event_bus.scala
wenzelm@51615
    48
  System/gui.scala
wenzelm@43320
    49
  System/gui_setup.scala
wenzelm@49066
    50
  System/html5_panel.scala
wenzelm@51250
    51
  System/interrupt.scala
wenzelm@43744
    52
  System/invoke_scala.scala
wenzelm@43517
    53
  System/isabelle_charset.scala
wenzelm@51614
    54
  System/isabelle_font.scala
wenzelm@43320
    55
  System/isabelle_process.scala
wenzelm@43320
    56
  System/isabelle_system.scala
wenzelm@49065
    57
  System/jfx_thread.scala
wenzelm@48365
    58
  System/options.scala
wenzelm@43320
    59
  System/platform.scala
wenzelm@43320
    60
  System/session.scala
wenzelm@43320
    61
  System/swing_thread.scala
wenzelm@45027
    62
  System/system_channel.scala
wenzelm@50203
    63
  System/utf8.scala
wenzelm@43320
    64
  Thy/completion.scala
wenzelm@43320
    65
  Thy/html.scala
wenzelm@50707
    66
  Thy/present.scala
wenzelm@43320
    67
  Thy/thy_header.scala
wenzelm@43651
    68
  Thy/thy_info.scala
wenzelm@43651
    69
  Thy/thy_load.scala
wenzelm@43320
    70
  Thy/thy_syntax.scala
wenzelm@50686
    71
  Tools/build.scala
wenzelm@50686
    72
  Tools/build_dialog.scala
wenzelm@52444
    73
  Tools/doc.scala
wenzelm@52439
    74
  Tools/keywords.scala
wenzelm@50687
    75
  Tools/main.scala
wenzelm@50981
    76
  Tools/ml_statistics.scala
wenzelm@50980
    77
  Tools/task_statistics.scala
wenzelm@43320
    78
  library.scala
wenzelm@43320
    79
  package.scala
wenzelm@43730
    80
  term.scala
wenzelm@43779
    81
  term_xml.scala
wenzelm@43320
    82
)
wenzelm@43320
    83
wenzelm@34282
    84
wenzelm@34282
    85
## diagnostics
wenzelm@34282
    86
wenzelm@43280
    87
PRG="$(basename "$0")"
wenzelm@43280
    88
wenzelm@43280
    89
function usage()
wenzelm@43280
    90
{
wenzelm@43280
    91
  echo
wenzelm@43280
    92
  echo "Usage: isabelle $PRG [OPTIONS]"
wenzelm@43280
    93
  echo
wenzelm@43280
    94
  echo "  Options are:"
wenzelm@43280
    95
  echo "    -f           fresh build"
wenzelm@47408
    96
  echo "    -t           test separate compilation of PIDE"
wenzelm@43280
    97
  echo
wenzelm@43280
    98
  exit 1
wenzelm@43280
    99
}
wenzelm@43280
   100
wenzelm@34282
   101
function fail()
wenzelm@34282
   102
{
wenzelm@34282
   103
  echo "$1" >&2
wenzelm@34282
   104
  exit 2
wenzelm@34282
   105
}
wenzelm@34282
   106
wenzelm@42899
   107
[ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
wenzelm@34282
   108
wenzelm@34282
   109
wenzelm@43280
   110
## process command line
wenzelm@43280
   111
wenzelm@43280
   112
# options
wenzelm@43280
   113
wenzelm@43280
   114
FRESH=""
wenzelm@47408
   115
TEST_PIDE=""
wenzelm@43280
   116
wenzelm@47408
   117
while getopts "ft" OPT
wenzelm@43280
   118
do
wenzelm@43280
   119
  case "$OPT" in
wenzelm@43280
   120
    f)
wenzelm@43280
   121
      FRESH=true
wenzelm@43280
   122
      ;;
wenzelm@47408
   123
    t)
wenzelm@47408
   124
      TEST_PIDE=true
wenzelm@47408
   125
      ;;
wenzelm@43280
   126
    \?)
wenzelm@43280
   127
      usage
wenzelm@43280
   128
      ;;
wenzelm@43280
   129
  esac
wenzelm@43280
   130
done
wenzelm@43280
   131
wenzelm@43280
   132
shift $(($OPTIND - 1))
wenzelm@43280
   133
wenzelm@43280
   134
wenzelm@43280
   135
# args
wenzelm@43280
   136
wenzelm@43280
   137
[ "$#" -ne 0 ] && usage
wenzelm@43280
   138
wenzelm@43280
   139
wenzelm@50689
   140
## dependencies
wenzelm@50689
   141
wenzelm@50689
   142
declare -a JFREECHART_JARS=()
wenzelm@50689
   143
for NAME in $JFREECHART_JAR_NAMES
wenzelm@50689
   144
do
wenzelm@50689
   145
  JFREECHART_JARS["${#JFREECHART_JARS[@]}"]="$JFREECHART_HOME/lib/$NAME"
wenzelm@50689
   146
done
wenzelm@50689
   147
wenzelm@50689
   148
wenzelm@49558
   149
## build
wenzelm@34282
   150
wenzelm@34284
   151
TARGET_DIR="$ISABELLE_HOME/lib/classes"
wenzelm@43523
   152
TARGET="$TARGET_DIR/ext/Pure.jar"
wenzelm@34282
   153
wenzelm@45673
   154
declare -a PIDE_SOURCES=()
wenzelm@45673
   155
declare -a PURE_SOURCES=()
wenzelm@45673
   156
wenzelm@45673
   157
for DEP in "${SOURCES[@]}"
wenzelm@45673
   158
do
wenzelm@45673
   159
  if grep "Module:.*PIDE" "$DEP" >/dev/null
wenzelm@45673
   160
  then
wenzelm@45673
   161
    PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   162
  else
wenzelm@45673
   163
    PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   164
  fi
wenzelm@45673
   165
done
wenzelm@45673
   166
wenzelm@43405
   167
declare -a UPDATED=()
wenzelm@43405
   168
wenzelm@43280
   169
if [ -n "$FRESH" ]; then
wenzelm@43280
   170
  OUTDATED=true
wenzelm@43280
   171
else
wenzelm@43280
   172
  OUTDATED=false
wenzelm@43523
   173
  if [ ! -e "$TARGET" ]; then
wenzelm@43523
   174
    OUTDATED=true
wenzelm@43523
   175
  else
wenzelm@43405
   176
    for DEP in "${SOURCES[@]}"
wenzelm@43280
   177
    do
wenzelm@43405
   178
      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
wenzelm@43523
   179
      [ "$DEP" -nt "$TARGET" ] && {
wenzelm@43523
   180
        OUTDATED=true
wenzelm@43523
   181
        UPDATED["${#UPDATED[@]}"]="$DEP"
wenzelm@43523
   182
      }
wenzelm@43280
   183
    done
wenzelm@43405
   184
  fi
wenzelm@43280
   185
fi
wenzelm@34282
   186
wenzelm@34284
   187
if [ "$OUTDATED" = true ]
wenzelm@34284
   188
then
wenzelm@49173
   189
  echo "### Building Isabelle/Scala ..."
wenzelm@34282
   190
wenzelm@43405
   191
  [ "${#UPDATED[@]}" -gt 0 ] && {
wenzelm@43405
   192
    echo "Changed files:"
wenzelm@43405
   193
    for FILE in "${UPDATED[@]}"
wenzelm@43405
   194
    do
wenzelm@43405
   195
      echo "  $FILE"
wenzelm@43405
   196
    done
wenzelm@43405
   197
  }
wenzelm@43405
   198
wenzelm@34282
   199
  rm -rf classes && mkdir classes
wenzelm@45673
   200
wenzelm@47009
   201
  SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
wenzelm@45673
   202
wenzelm@49067
   203
  JFXRT="$ISABELLE_JDK_HOME/jre/lib/jfxrt.jar"
wenzelm@49067
   204
wenzelm@50689
   205
  (
wenzelm@51504
   206
    for X in "$JFXRT" "${JFREECHART_JARS[@]}" "$XZ_JAVA_HOME/lib/xz.jar" classes
wenzelm@50689
   207
    do
wenzelm@50689
   208
      CLASSPATH="$CLASSPATH:$X"
wenzelm@50689
   209
    done
wenzelm@50689
   210
    CLASSPATH="$(jvmpath "$CLASSPATH")"
wenzelm@50689
   211
wenzelm@50689
   212
    if [ "$TEST_PIDE" = true ]; then
wenzelm@50689
   213
      isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
wenzelm@50689
   214
        fail "Failed to compile PIDE sources"
wenzelm@50689
   215
      isabelle_scala scalac $SCALAC_OPTIONS "${PURE_SOURCES[@]}" || \
wenzelm@50689
   216
        fail "Failed to compile Pure sources"
wenzelm@50689
   217
    else
wenzelm@50689
   218
      isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
wenzelm@50689
   219
        fail "Failed to compile sources"
wenzelm@50689
   220
    fi
wenzelm@51508
   221
  ) || exit "$?"
wenzelm@45673
   222
wenzelm@43523
   223
  mkdir -p "$TARGET_DIR/ext" || fail "Failed to create directory $TARGET_DIR/ext"
wenzelm@43280
   224
wenzelm@43285
   225
  pushd classes >/dev/null
wenzelm@43280
   226
wenzelm@43517
   227
  CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
wenzelm@43517
   228
  mkdir -p "$(dirname "$CHARSET_SERVICE")"
wenzelm@43517
   229
  echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
wenzelm@43517
   230
wenzelm@47115
   231
  isabelle_jdk jar cfe "$(jvmpath "$TARGET")" isabelle.GUI_Setup META-INF isabelle || \
wenzelm@43523
   232
    fail "Failed to produce $TARGET"
wenzelm@34282
   233
wenzelm@49449
   234
  cp "$SCALA_HOME/lib/scala-compiler.jar" \
wenzelm@47995
   235
    "$SCALA_HOME/lib/scala-library.jar" \
wenzelm@47995
   236
    "$SCALA_HOME/lib/scala-swing.jar" "$TARGET_DIR/ext"
wenzelm@47995
   237
wenzelm@47849
   238
  [ -e "$SCALA_HOME/lib/scala-actors.jar" ] && \
wenzelm@47849
   239
    cp "$SCALA_HOME/lib/scala-actors.jar" "$TARGET_DIR/ext"
wenzelm@43521
   240
wenzelm@49955
   241
  [ -e "$SCALA_HOME/lib/scala-reflect.jar" ] && \
wenzelm@49955
   242
    cp "$SCALA_HOME/lib/scala-reflect.jar" "$TARGET_DIR/ext"
wenzelm@49955
   243
wenzelm@43280
   244
  popd >/dev/null
wenzelm@43280
   245
wenzelm@34282
   246
  rm -rf classes
wenzelm@34282
   247
fi