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