src/Pure/build-jars
author wenzelm
Wed Jan 02 21:02:47 2013 +0100 (2013-01-02)
changeset 50689 0607d557d073
parent 50687 a8db4bf70e90
child 50707 5b2bf7611662
permissions -rwxr-xr-x
some support for chart drawing;
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@50685
    33
  ML/ml_statistics.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@43744
    47
  System/invoke_scala.scala
wenzelm@43517
    48
  System/isabelle_charset.scala
wenzelm@43320
    49
  System/isabelle_process.scala
wenzelm@43320
    50
  System/isabelle_system.scala
wenzelm@49065
    51
  System/jfx_thread.scala
wenzelm@48365
    52
  System/options.scala
wenzelm@43320
    53
  System/platform.scala
wenzelm@43320
    54
  System/session.scala
wenzelm@43320
    55
  System/swing_thread.scala
wenzelm@45027
    56
  System/system_channel.scala
wenzelm@50203
    57
  System/utf8.scala
wenzelm@43320
    58
  Thy/completion.scala
wenzelm@43320
    59
  Thy/html.scala
wenzelm@43320
    60
  Thy/thy_header.scala
wenzelm@43651
    61
  Thy/thy_info.scala
wenzelm@43651
    62
  Thy/thy_load.scala
wenzelm@43320
    63
  Thy/thy_syntax.scala
wenzelm@50686
    64
  Tools/build.scala
wenzelm@50686
    65
  Tools/build_dialog.scala
wenzelm@50687
    66
  Tools/main.scala
wenzelm@43320
    67
  library.scala
wenzelm@43320
    68
  package.scala
wenzelm@43730
    69
  term.scala
wenzelm@43779
    70
  term_xml.scala
wenzelm@43320
    71
)
wenzelm@43320
    72
wenzelm@34282
    73
wenzelm@34282
    74
## diagnostics
wenzelm@34282
    75
wenzelm@43280
    76
PRG="$(basename "$0")"
wenzelm@43280
    77
wenzelm@43280
    78
function usage()
wenzelm@43280
    79
{
wenzelm@43280
    80
  echo
wenzelm@43280
    81
  echo "Usage: isabelle $PRG [OPTIONS]"
wenzelm@43280
    82
  echo
wenzelm@43280
    83
  echo "  Options are:"
wenzelm@43280
    84
  echo "    -f           fresh build"
wenzelm@47408
    85
  echo "    -t           test separate compilation of PIDE"
wenzelm@43280
    86
  echo
wenzelm@43280
    87
  exit 1
wenzelm@43280
    88
}
wenzelm@43280
    89
wenzelm@34282
    90
function fail()
wenzelm@34282
    91
{
wenzelm@34282
    92
  echo "$1" >&2
wenzelm@34282
    93
  exit 2
wenzelm@34282
    94
}
wenzelm@34282
    95
wenzelm@42899
    96
[ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
wenzelm@34282
    97
wenzelm@34282
    98
wenzelm@43280
    99
## process command line
wenzelm@43280
   100
wenzelm@43280
   101
# options
wenzelm@43280
   102
wenzelm@43280
   103
FRESH=""
wenzelm@47408
   104
TEST_PIDE=""
wenzelm@43280
   105
wenzelm@47408
   106
while getopts "ft" OPT
wenzelm@43280
   107
do
wenzelm@43280
   108
  case "$OPT" in
wenzelm@43280
   109
    f)
wenzelm@43280
   110
      FRESH=true
wenzelm@43280
   111
      ;;
wenzelm@47408
   112
    t)
wenzelm@47408
   113
      TEST_PIDE=true
wenzelm@47408
   114
      ;;
wenzelm@43280
   115
    \?)
wenzelm@43280
   116
      usage
wenzelm@43280
   117
      ;;
wenzelm@43280
   118
  esac
wenzelm@43280
   119
done
wenzelm@43280
   120
wenzelm@43280
   121
shift $(($OPTIND - 1))
wenzelm@43280
   122
wenzelm@43280
   123
wenzelm@43280
   124
# args
wenzelm@43280
   125
wenzelm@43280
   126
[ "$#" -ne 0 ] && usage
wenzelm@43280
   127
wenzelm@43280
   128
wenzelm@50689
   129
## dependencies
wenzelm@50689
   130
wenzelm@50689
   131
declare -a JFREECHART_JARS=()
wenzelm@50689
   132
for NAME in $JFREECHART_JAR_NAMES
wenzelm@50689
   133
do
wenzelm@50689
   134
  JFREECHART_JARS["${#JFREECHART_JARS[@]}"]="$JFREECHART_HOME/lib/$NAME"
wenzelm@50689
   135
done
wenzelm@50689
   136
wenzelm@50689
   137
wenzelm@49558
   138
## build
wenzelm@34282
   139
wenzelm@34284
   140
TARGET_DIR="$ISABELLE_HOME/lib/classes"
wenzelm@43523
   141
TARGET="$TARGET_DIR/ext/Pure.jar"
wenzelm@34282
   142
wenzelm@45673
   143
declare -a PIDE_SOURCES=()
wenzelm@45673
   144
declare -a PURE_SOURCES=()
wenzelm@45673
   145
wenzelm@45673
   146
for DEP in "${SOURCES[@]}"
wenzelm@45673
   147
do
wenzelm@45673
   148
  if grep "Module:.*PIDE" "$DEP" >/dev/null
wenzelm@45673
   149
  then
wenzelm@45673
   150
    PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   151
  else
wenzelm@45673
   152
    PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   153
  fi
wenzelm@45673
   154
done
wenzelm@45673
   155
wenzelm@43405
   156
declare -a UPDATED=()
wenzelm@43405
   157
wenzelm@43280
   158
if [ -n "$FRESH" ]; then
wenzelm@43280
   159
  OUTDATED=true
wenzelm@43280
   160
else
wenzelm@43280
   161
  OUTDATED=false
wenzelm@43523
   162
  if [ ! -e "$TARGET" ]; then
wenzelm@43523
   163
    OUTDATED=true
wenzelm@43523
   164
  else
wenzelm@43405
   165
    for DEP in "${SOURCES[@]}"
wenzelm@43280
   166
    do
wenzelm@43405
   167
      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
wenzelm@43523
   168
      [ "$DEP" -nt "$TARGET" ] && {
wenzelm@43523
   169
        OUTDATED=true
wenzelm@43523
   170
        UPDATED["${#UPDATED[@]}"]="$DEP"
wenzelm@43523
   171
      }
wenzelm@43280
   172
    done
wenzelm@43405
   173
  fi
wenzelm@43280
   174
fi
wenzelm@34282
   175
wenzelm@34284
   176
if [ "$OUTDATED" = true ]
wenzelm@34284
   177
then
wenzelm@49173
   178
  echo "### Building Isabelle/Scala ..."
wenzelm@34282
   179
wenzelm@43405
   180
  [ "${#UPDATED[@]}" -gt 0 ] && {
wenzelm@43405
   181
    echo "Changed files:"
wenzelm@43405
   182
    for FILE in "${UPDATED[@]}"
wenzelm@43405
   183
    do
wenzelm@43405
   184
      echo "  $FILE"
wenzelm@43405
   185
    done
wenzelm@43405
   186
  }
wenzelm@43405
   187
wenzelm@34282
   188
  rm -rf classes && mkdir classes
wenzelm@45673
   189
wenzelm@47009
   190
  SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
wenzelm@45673
   191
wenzelm@49067
   192
  JFXRT="$ISABELLE_JDK_HOME/jre/lib/jfxrt.jar"
wenzelm@49067
   193
wenzelm@50689
   194
  (
wenzelm@50689
   195
    for X in "$JFXRT" "${JFREECHART_JARS[@]}" classes
wenzelm@50689
   196
    do
wenzelm@50689
   197
      CLASSPATH="$CLASSPATH:$X"
wenzelm@50689
   198
    done
wenzelm@50689
   199
    CLASSPATH="$(jvmpath "$CLASSPATH")"
wenzelm@50689
   200
wenzelm@50689
   201
    if [ "$TEST_PIDE" = true ]; then
wenzelm@50689
   202
      isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
wenzelm@50689
   203
        fail "Failed to compile PIDE sources"
wenzelm@50689
   204
      isabelle_scala scalac $SCALAC_OPTIONS "${PURE_SOURCES[@]}" || \
wenzelm@50689
   205
        fail "Failed to compile Pure sources"
wenzelm@50689
   206
    else
wenzelm@50689
   207
      isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
wenzelm@50689
   208
        fail "Failed to compile sources"
wenzelm@50689
   209
    fi
wenzelm@50689
   210
  )
wenzelm@45673
   211
wenzelm@43523
   212
  mkdir -p "$TARGET_DIR/ext" || fail "Failed to create directory $TARGET_DIR/ext"
wenzelm@43280
   213
wenzelm@43285
   214
  pushd classes >/dev/null
wenzelm@43280
   215
wenzelm@43517
   216
  CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
wenzelm@43517
   217
  mkdir -p "$(dirname "$CHARSET_SERVICE")"
wenzelm@43517
   218
  echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
wenzelm@43517
   219
wenzelm@47115
   220
  isabelle_jdk jar cfe "$(jvmpath "$TARGET")" isabelle.GUI_Setup META-INF isabelle || \
wenzelm@43523
   221
    fail "Failed to produce $TARGET"
wenzelm@34282
   222
wenzelm@49449
   223
  cp "$SCALA_HOME/lib/scala-compiler.jar" \
wenzelm@47995
   224
    "$SCALA_HOME/lib/scala-library.jar" \
wenzelm@47995
   225
    "$SCALA_HOME/lib/scala-swing.jar" "$TARGET_DIR/ext"
wenzelm@47995
   226
wenzelm@47849
   227
  [ -e "$SCALA_HOME/lib/scala-actors.jar" ] && \
wenzelm@47849
   228
    cp "$SCALA_HOME/lib/scala-actors.jar" "$TARGET_DIR/ext"
wenzelm@43521
   229
wenzelm@49955
   230
  [ -e "$SCALA_HOME/lib/scala-reflect.jar" ] && \
wenzelm@49955
   231
    cp "$SCALA_HOME/lib/scala-reflect.jar" "$TARGET_DIR/ext"
wenzelm@49955
   232
wenzelm@43280
   233
  popd >/dev/null
wenzelm@43280
   234
wenzelm@34282
   235
  rm -rf classes
wenzelm@34282
   236
fi