src/Pure/build-jars
author wenzelm
Tue Sep 29 13:54:04 2015 +0200 (2015-09-29)
changeset 61276 8a4bd05c1735
parent 61216 4ca490f09ec6
child 61282 3e578ddef85d
permissions -rwxr-xr-x
clarified modules;
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@48346
    77
  System/command_line.scala
wenzelm@43744
    78
  System/invoke_scala.scala
wenzelm@43517
    79
  System/isabelle_charset.scala
wenzelm@43320
    80
  System/isabelle_process.scala
wenzelm@43320
    81
  System/isabelle_system.scala
wenzelm@48365
    82
  System/options.scala
wenzelm@43320
    83
  System/platform.scala
wenzelm@56860
    84
  System/posix_interrupt.scala
wenzelm@61276
    85
  System/progress.scala
wenzelm@45027
    86
  System/system_channel.scala
wenzelm@50203
    87
  System/utf8.scala
wenzelm@43320
    88
  Thy/html.scala
wenzelm@50707
    89
  Thy/present.scala
wenzelm@43320
    90
  Thy/thy_header.scala
wenzelm@43651
    91
  Thy/thy_info.scala
wenzelm@43320
    92
  Thy/thy_syntax.scala
wenzelm@58523
    93
  Tools/bibtex.scala
wenzelm@57647
    94
  Tools/build.scala
wenzelm@57647
    95
  Tools/build_console.scala
wenzelm@57647
    96
  Tools/build_doc.scala
wenzelm@59891
    97
  Tools/check_keywords.scala
wenzelm@56791
    98
  Tools/check_source.scala
wenzelm@60749
    99
  Tools/debugger.scala
wenzelm@52444
   100
  Tools/doc.scala
wenzelm@50687
   101
  Tools/main.scala
wenzelm@50981
   102
  Tools/ml_statistics.scala
wenzelm@56864
   103
  Tools/print_operation.scala
wenzelm@54730
   104
  Tools/simplifier_trace.scala
wenzelm@50980
   105
  Tools/task_statistics.scala
wenzelm@58610
   106
  Tools/update_cartouches.scala
wenzelm@58872
   107
  Tools/update_header.scala
wenzelm@58861
   108
  Tools/update_semicolons.scala
wenzelm@61216
   109
  Tools/update_then.scala
wenzelm@43320
   110
  library.scala
wenzelm@43730
   111
  term.scala
wenzelm@43779
   112
  term_xml.scala
wenzelm@59441
   113
  "../Tools/Graphview/graph_file.scala"
wenzelm@59202
   114
  "../Tools/Graphview/graph_panel.scala"
wenzelm@59459
   115
  "../Tools/Graphview/graphview.scala"
wenzelm@59232
   116
  "../Tools/Graphview/layout.scala"
wenzelm@59202
   117
  "../Tools/Graphview/main_panel.scala"
wenzelm@59290
   118
  "../Tools/Graphview/metrics.scala"
wenzelm@59202
   119
  "../Tools/Graphview/model.scala"
wenzelm@59392
   120
  "../Tools/Graphview/mutator.scala"
wenzelm@59202
   121
  "../Tools/Graphview/mutator_dialog.scala"
wenzelm@59202
   122
  "../Tools/Graphview/mutator_event.scala"
wenzelm@59202
   123
  "../Tools/Graphview/popups.scala"
wenzelm@59202
   124
  "../Tools/Graphview/shapes.scala"
wenzelm@59392
   125
  "../Tools/Graphview/tree_panel.scala"
wenzelm@43320
   126
)
wenzelm@43320
   127
wenzelm@34282
   128
wenzelm@34282
   129
## diagnostics
wenzelm@34282
   130
wenzelm@43280
   131
PRG="$(basename "$0")"
wenzelm@43280
   132
wenzelm@43280
   133
function usage()
wenzelm@43280
   134
{
wenzelm@43280
   135
  echo
wenzelm@43280
   136
  echo "Usage: isabelle $PRG [OPTIONS]"
wenzelm@43280
   137
  echo
wenzelm@43280
   138
  echo "  Options are:"
wenzelm@43280
   139
  echo "    -f           fresh build"
wenzelm@47408
   140
  echo "    -t           test separate compilation of PIDE"
wenzelm@43280
   141
  echo
wenzelm@43280
   142
  exit 1
wenzelm@43280
   143
}
wenzelm@43280
   144
wenzelm@34282
   145
function fail()
wenzelm@34282
   146
{
wenzelm@34282
   147
  echo "$1" >&2
wenzelm@34282
   148
  exit 2
wenzelm@34282
   149
}
wenzelm@34282
   150
wenzelm@42899
   151
[ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
wenzelm@34282
   152
wenzelm@34282
   153
wenzelm@43280
   154
## process command line
wenzelm@43280
   155
wenzelm@43280
   156
# options
wenzelm@43280
   157
wenzelm@43280
   158
FRESH=""
wenzelm@47408
   159
TEST_PIDE=""
wenzelm@43280
   160
wenzelm@47408
   161
while getopts "ft" OPT
wenzelm@43280
   162
do
wenzelm@43280
   163
  case "$OPT" in
wenzelm@43280
   164
    f)
wenzelm@43280
   165
      FRESH=true
wenzelm@43280
   166
      ;;
wenzelm@47408
   167
    t)
wenzelm@47408
   168
      TEST_PIDE=true
wenzelm@47408
   169
      ;;
wenzelm@43280
   170
    \?)
wenzelm@43280
   171
      usage
wenzelm@43280
   172
      ;;
wenzelm@43280
   173
  esac
wenzelm@43280
   174
done
wenzelm@43280
   175
wenzelm@43280
   176
shift $(($OPTIND - 1))
wenzelm@43280
   177
wenzelm@43280
   178
wenzelm@43280
   179
# args
wenzelm@43280
   180
wenzelm@43280
   181
[ "$#" -ne 0 ] && usage
wenzelm@43280
   182
wenzelm@43280
   183
wenzelm@49558
   184
## build
wenzelm@34282
   185
wenzelm@34284
   186
TARGET_DIR="$ISABELLE_HOME/lib/classes"
wenzelm@53577
   187
TARGET="$TARGET_DIR/Pure.jar"
wenzelm@34282
   188
wenzelm@45673
   189
declare -a PIDE_SOURCES=()
wenzelm@45673
   190
declare -a PURE_SOURCES=()
wenzelm@45673
   191
wenzelm@45673
   192
for DEP in "${SOURCES[@]}"
wenzelm@45673
   193
do
wenzelm@45673
   194
  if grep "Module:.*PIDE" "$DEP" >/dev/null
wenzelm@45673
   195
  then
wenzelm@45673
   196
    PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   197
  else
wenzelm@45673
   198
    PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   199
  fi
wenzelm@45673
   200
done
wenzelm@45673
   201
wenzelm@43405
   202
declare -a UPDATED=()
wenzelm@43405
   203
wenzelm@43280
   204
if [ -n "$FRESH" ]; then
wenzelm@43280
   205
  OUTDATED=true
wenzelm@43280
   206
else
wenzelm@43280
   207
  OUTDATED=false
wenzelm@43523
   208
  if [ ! -e "$TARGET" ]; then
wenzelm@43523
   209
    OUTDATED=true
wenzelm@43523
   210
  else
wenzelm@43405
   211
    for DEP in "${SOURCES[@]}"
wenzelm@43280
   212
    do
wenzelm@43405
   213
      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
wenzelm@43523
   214
      [ "$DEP" -nt "$TARGET" ] && {
wenzelm@43523
   215
        OUTDATED=true
wenzelm@43523
   216
        UPDATED["${#UPDATED[@]}"]="$DEP"
wenzelm@43523
   217
      }
wenzelm@43280
   218
    done
wenzelm@43405
   219
  fi
wenzelm@43280
   220
fi
wenzelm@34282
   221
wenzelm@34284
   222
if [ "$OUTDATED" = true ]
wenzelm@34284
   223
then
wenzelm@49173
   224
  echo "### Building Isabelle/Scala ..."
wenzelm@34282
   225
wenzelm@43405
   226
  [ "${#UPDATED[@]}" -gt 0 ] && {
wenzelm@43405
   227
    echo "Changed files:"
wenzelm@43405
   228
    for FILE in "${UPDATED[@]}"
wenzelm@43405
   229
    do
wenzelm@43405
   230
      echo "  $FILE"
wenzelm@43405
   231
    done
wenzelm@43405
   232
  }
wenzelm@43405
   233
wenzelm@34282
   234
  rm -rf classes && mkdir classes
wenzelm@45673
   235
wenzelm@47009
   236
  SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
wenzelm@45673
   237
wenzelm@50689
   238
  (
wenzelm@58791
   239
    classpath "$JAVA_HOME/lib/jfxrt.jar"
wenzelm@53576
   240
    classpath classes
wenzelm@53576
   241
    export CLASSPATH="$(jvmpath "$ISABELLE_CLASSPATH")"
wenzelm@50689
   242
wenzelm@50689
   243
    if [ "$TEST_PIDE" = true ]; then
wenzelm@50689
   244
      isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
wenzelm@50689
   245
        fail "Failed to compile PIDE sources"
wenzelm@50689
   246
      isabelle_scala scalac $SCALAC_OPTIONS "${PURE_SOURCES[@]}" || \
wenzelm@50689
   247
        fail "Failed to compile Pure sources"
wenzelm@50689
   248
    else
wenzelm@50689
   249
      isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
wenzelm@50689
   250
        fail "Failed to compile sources"
wenzelm@50689
   251
    fi
wenzelm@51508
   252
  ) || exit "$?"
wenzelm@45673
   253
wenzelm@53577
   254
  mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
wenzelm@43280
   255
wenzelm@43285
   256
  pushd classes >/dev/null
wenzelm@43280
   257
wenzelm@43517
   258
  CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
wenzelm@43517
   259
  mkdir -p "$(dirname "$CHARSET_SERVICE")"
wenzelm@43517
   260
  echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
wenzelm@43517
   261
wenzelm@54676
   262
  cp "$ISABELLE_HOME/lib/logo/isabelle_transparent-32.gif" isabelle/.
wenzelm@54709
   263
  cp "$ISABELLE_HOME/lib/logo/isabelle_transparent.gif" isabelle/.
wenzelm@53452
   264
wenzelm@53841
   265
  isabelle_jdk jar cfe "$(jvmpath "$TARGET")" isabelle.Main META-INF isabelle || \
wenzelm@43523
   266
    fail "Failed to produce $TARGET"
wenzelm@34282
   267
wenzelm@43280
   268
  popd >/dev/null
wenzelm@43280
   269
wenzelm@34282
   270
  rm -rf classes
wenzelm@34282
   271
fi