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