src/Pure/build-jars
author wenzelm
Tue Aug 12 12:06:22 2014 +0200 (2014-08-12)
changeset 57908 1937603dbdf2
parent 57905 c0c5652e796e
child 58523 937c479e62fe
permissions -rwxr-xr-x
separate Java FX modules -- no need to include jfxrt.jar by default;
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@56695
    12
  Concurrent/consumer_thread.scala
wenzelm@43660
    13
  Concurrent/counter.scala
wenzelm@56768
    14
  Concurrent/event_timer.scala
wenzelm@43320
    15
  Concurrent/future.scala
wenzelm@56693
    16
  Concurrent/mailbox.scala
wenzelm@43320
    17
  Concurrent/simple_thread.scala
wenzelm@56685
    18
  Concurrent/synchronized.scala
wenzelm@57647
    19
  GUI/color_value.scala
wenzelm@57647
    20
  GUI/gui.scala
wenzelm@57647
    21
  GUI/gui_thread.scala
wenzelm@57647
    22
  GUI/html5_panel.scala
wenzelm@57908
    23
  GUI/jfx_gui.scala
wenzelm@57647
    24
  GUI/popup.scala
wenzelm@57647
    25
  GUI/system_dialog.scala
wenzelm@57647
    26
  GUI/wrap_panel.scala
wenzelm@55511
    27
  General/antiquote.scala
wenzelm@54439
    28
  General/bytes.scala
wenzelm@55673
    29
  General/completion.scala
wenzelm@43320
    30
  General/exn.scala
wenzelm@48411
    31
  General/file.scala
wenzelm@46611
    32
  General/graph.scala
wenzelm@51098
    33
  General/graphics_file.scala
wenzelm@43320
    34
  General/linear_set.scala
wenzelm@56800
    35
  General/long_name.scala
wenzelm@52975
    36
  General/multi_map.scala
wenzelm@56782
    37
  General/output.scala
wenzelm@43600
    38
  General/path.scala
wenzelm@43320
    39
  General/position.scala
wenzelm@43320
    40
  General/pretty.scala
wenzelm@43780
    41
  General/properties.scala
wenzelm@43320
    42
  General/scan.scala
wenzelm@43320
    43
  General/sha1.scala
wenzelm@43320
    44
  General/symbol.scala
wenzelm@45674
    45
  General/time.scala
wenzelm@45666
    46
  General/timing.scala
wenzelm@57647
    47
  General/untyped.scala
wenzelm@56501
    48
  General/url.scala
wenzelm@56599
    49
  General/word.scala
wenzelm@52671
    50
  General/xz_file.scala
wenzelm@43320
    51
  Isar/keyword.scala
wenzelm@43320
    52
  Isar/outer_syntax.scala
wenzelm@43320
    53
  Isar/parse.scala
wenzelm@43320
    54
  Isar/token.scala
wenzelm@55497
    55
  ML/ml_lex.scala
wenzelm@43320
    56
  PIDE/command.scala
wenzelm@57905
    57
  PIDE/command_span.scala
wenzelm@43320
    58
  PIDE/document.scala
wenzelm@52530
    59
  PIDE/document_id.scala
wenzelm@52971
    60
  PIDE/editor.scala
wenzelm@45670
    61
  PIDE/markup.scala
wenzelm@43320
    62
  PIDE/markup_tree.scala
wenzelm@45709
    63
  PIDE/protocol.scala
wenzelm@56385
    64
  PIDE/prover.scala
wenzelm@52981
    65
  PIDE/query_operation.scala
wenzelm@56208
    66
  PIDE/resources.scala
wenzelm@56210
    67
  PIDE/session.scala
wenzelm@43320
    68
  PIDE/text.scala
wenzelm@44698
    69
  PIDE/xml.scala
wenzelm@44698
    70
  PIDE/yxml.scala
wenzelm@57647
    71
  ROOT.scala
wenzelm@48346
    72
  System/command_line.scala
wenzelm@43744
    73
  System/invoke_scala.scala
wenzelm@43517
    74
  System/isabelle_charset.scala
wenzelm@43320
    75
  System/isabelle_process.scala
wenzelm@43320
    76
  System/isabelle_system.scala
wenzelm@48365
    77
  System/options.scala
wenzelm@43320
    78
  System/platform.scala
wenzelm@56860
    79
  System/posix_interrupt.scala
wenzelm@45027
    80
  System/system_channel.scala
wenzelm@50203
    81
  System/utf8.scala
wenzelm@43320
    82
  Thy/html.scala
wenzelm@50707
    83
  Thy/present.scala
wenzelm@43320
    84
  Thy/thy_header.scala
wenzelm@43651
    85
  Thy/thy_info.scala
wenzelm@57900
    86
  Thy/thy_structure.scala
wenzelm@43320
    87
  Thy/thy_syntax.scala
wenzelm@57647
    88
  Tools/build.scala
wenzelm@57647
    89
  Tools/build_console.scala
wenzelm@57647
    90
  Tools/build_doc.scala
wenzelm@56791
    91
  Tools/check_source.scala
wenzelm@52444
    92
  Tools/doc.scala
wenzelm@52439
    93
  Tools/keywords.scala
wenzelm@50687
    94
  Tools/main.scala
wenzelm@50981
    95
  Tools/ml_statistics.scala
wenzelm@56864
    96
  Tools/print_operation.scala
wenzelm@54730
    97
  Tools/simplifier_trace.scala
wenzelm@50980
    98
  Tools/task_statistics.scala
wenzelm@43320
    99
  library.scala
wenzelm@43730
   100
  term.scala
wenzelm@43779
   101
  term_xml.scala
wenzelm@57032
   102
  "../Tools/Graphview/src/graph_panel.scala"
wenzelm@57032
   103
  "../Tools/Graphview/src/layout_pendulum.scala"
wenzelm@57032
   104
  "../Tools/Graphview/src/main_panel.scala"
wenzelm@57032
   105
  "../Tools/Graphview/src/model.scala"
wenzelm@57032
   106
  "../Tools/Graphview/src/mutator_dialog.scala"
wenzelm@57032
   107
  "../Tools/Graphview/src/mutator_event.scala"
wenzelm@57032
   108
  "../Tools/Graphview/src/mutator.scala"
wenzelm@57032
   109
  "../Tools/Graphview/src/popups.scala"
wenzelm@57032
   110
  "../Tools/Graphview/src/shapes.scala"
wenzelm@57032
   111
  "../Tools/Graphview/src/visualizer.scala"
wenzelm@43320
   112
)
wenzelm@43320
   113
wenzelm@34282
   114
wenzelm@34282
   115
## diagnostics
wenzelm@34282
   116
wenzelm@43280
   117
PRG="$(basename "$0")"
wenzelm@43280
   118
wenzelm@43280
   119
function usage()
wenzelm@43280
   120
{
wenzelm@43280
   121
  echo
wenzelm@43280
   122
  echo "Usage: isabelle $PRG [OPTIONS]"
wenzelm@43280
   123
  echo
wenzelm@43280
   124
  echo "  Options are:"
wenzelm@43280
   125
  echo "    -f           fresh build"
wenzelm@47408
   126
  echo "    -t           test separate compilation of PIDE"
wenzelm@43280
   127
  echo
wenzelm@43280
   128
  exit 1
wenzelm@43280
   129
}
wenzelm@43280
   130
wenzelm@34282
   131
function fail()
wenzelm@34282
   132
{
wenzelm@34282
   133
  echo "$1" >&2
wenzelm@34282
   134
  exit 2
wenzelm@34282
   135
}
wenzelm@34282
   136
wenzelm@42899
   137
[ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
wenzelm@34282
   138
wenzelm@34282
   139
wenzelm@43280
   140
## process command line
wenzelm@43280
   141
wenzelm@43280
   142
# options
wenzelm@43280
   143
wenzelm@43280
   144
FRESH=""
wenzelm@47408
   145
TEST_PIDE=""
wenzelm@43280
   146
wenzelm@47408
   147
while getopts "ft" OPT
wenzelm@43280
   148
do
wenzelm@43280
   149
  case "$OPT" in
wenzelm@43280
   150
    f)
wenzelm@43280
   151
      FRESH=true
wenzelm@43280
   152
      ;;
wenzelm@47408
   153
    t)
wenzelm@47408
   154
      TEST_PIDE=true
wenzelm@47408
   155
      ;;
wenzelm@43280
   156
    \?)
wenzelm@43280
   157
      usage
wenzelm@43280
   158
      ;;
wenzelm@43280
   159
  esac
wenzelm@43280
   160
done
wenzelm@43280
   161
wenzelm@43280
   162
shift $(($OPTIND - 1))
wenzelm@43280
   163
wenzelm@43280
   164
wenzelm@43280
   165
# args
wenzelm@43280
   166
wenzelm@43280
   167
[ "$#" -ne 0 ] && usage
wenzelm@43280
   168
wenzelm@43280
   169
wenzelm@49558
   170
## build
wenzelm@34282
   171
wenzelm@34284
   172
TARGET_DIR="$ISABELLE_HOME/lib/classes"
wenzelm@53577
   173
TARGET="$TARGET_DIR/Pure.jar"
wenzelm@34282
   174
wenzelm@45673
   175
declare -a PIDE_SOURCES=()
wenzelm@45673
   176
declare -a PURE_SOURCES=()
wenzelm@45673
   177
wenzelm@45673
   178
for DEP in "${SOURCES[@]}"
wenzelm@45673
   179
do
wenzelm@45673
   180
  if grep "Module:.*PIDE" "$DEP" >/dev/null
wenzelm@45673
   181
  then
wenzelm@45673
   182
    PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   183
  else
wenzelm@45673
   184
    PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   185
  fi
wenzelm@45673
   186
done
wenzelm@45673
   187
wenzelm@43405
   188
declare -a UPDATED=()
wenzelm@43405
   189
wenzelm@43280
   190
if [ -n "$FRESH" ]; then
wenzelm@43280
   191
  OUTDATED=true
wenzelm@43280
   192
else
wenzelm@43280
   193
  OUTDATED=false
wenzelm@43523
   194
  if [ ! -e "$TARGET" ]; then
wenzelm@43523
   195
    OUTDATED=true
wenzelm@43523
   196
  else
wenzelm@43405
   197
    for DEP in "${SOURCES[@]}"
wenzelm@43280
   198
    do
wenzelm@43405
   199
      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
wenzelm@43523
   200
      [ "$DEP" -nt "$TARGET" ] && {
wenzelm@43523
   201
        OUTDATED=true
wenzelm@43523
   202
        UPDATED["${#UPDATED[@]}"]="$DEP"
wenzelm@43523
   203
      }
wenzelm@43280
   204
    done
wenzelm@43405
   205
  fi
wenzelm@43280
   206
fi
wenzelm@34282
   207
wenzelm@34284
   208
if [ "$OUTDATED" = true ]
wenzelm@34284
   209
then
wenzelm@49173
   210
  echo "### Building Isabelle/Scala ..."
wenzelm@34282
   211
wenzelm@43405
   212
  [ "${#UPDATED[@]}" -gt 0 ] && {
wenzelm@43405
   213
    echo "Changed files:"
wenzelm@43405
   214
    for FILE in "${UPDATED[@]}"
wenzelm@43405
   215
    do
wenzelm@43405
   216
      echo "  $FILE"
wenzelm@43405
   217
    done
wenzelm@43405
   218
  }
wenzelm@43405
   219
wenzelm@34282
   220
  rm -rf classes && mkdir classes
wenzelm@45673
   221
wenzelm@47009
   222
  SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
wenzelm@45673
   223
wenzelm@50689
   224
  (
wenzelm@53576
   225
    classpath "$ISABELLE_JDK_HOME/jre/lib/jfxrt.jar"
wenzelm@53576
   226
    classpath classes
wenzelm@53576
   227
    export CLASSPATH="$(jvmpath "$ISABELLE_CLASSPATH")"
wenzelm@50689
   228
wenzelm@50689
   229
    if [ "$TEST_PIDE" = true ]; then
wenzelm@50689
   230
      isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
wenzelm@50689
   231
        fail "Failed to compile PIDE sources"
wenzelm@50689
   232
      isabelle_scala scalac $SCALAC_OPTIONS "${PURE_SOURCES[@]}" || \
wenzelm@50689
   233
        fail "Failed to compile Pure sources"
wenzelm@50689
   234
    else
wenzelm@50689
   235
      isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
wenzelm@50689
   236
        fail "Failed to compile sources"
wenzelm@50689
   237
    fi
wenzelm@51508
   238
  ) || exit "$?"
wenzelm@45673
   239
wenzelm@53577
   240
  mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
wenzelm@43280
   241
wenzelm@43285
   242
  pushd classes >/dev/null
wenzelm@43280
   243
wenzelm@43517
   244
  CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
wenzelm@43517
   245
  mkdir -p "$(dirname "$CHARSET_SERVICE")"
wenzelm@43517
   246
  echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
wenzelm@43517
   247
wenzelm@54676
   248
  cp "$ISABELLE_HOME/lib/logo/isabelle_transparent-32.gif" isabelle/.
wenzelm@54709
   249
  cp "$ISABELLE_HOME/lib/logo/isabelle_transparent.gif" isabelle/.
wenzelm@53452
   250
wenzelm@53841
   251
  isabelle_jdk jar cfe "$(jvmpath "$TARGET")" isabelle.Main META-INF isabelle || \
wenzelm@43523
   252
    fail "Failed to produce $TARGET"
wenzelm@34282
   253
wenzelm@43280
   254
  popd >/dev/null
wenzelm@43280
   255
wenzelm@34282
   256
  rm -rf classes
wenzelm@34282
   257
fi