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