src/Pure/build-jars
author wenzelm
Tue Mar 07 14:33:14 2017 +0100 (2017-03-07)
changeset 65139 0a2c0712e432
parent 65138 64dfee6bd243
child 65191 4c9c83311cad
permissions -rwxr-xr-x
clarified modules: spell-checker in Pure;
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@65071
    12
  Admin/build_cygwin.scala
wenzelm@64161
    13
  Admin/build_doc.scala
wenzelm@64890
    14
  Admin/build_docker.scala
wenzelm@64160
    15
  Admin/build_history.scala
wenzelm@64929
    16
  Admin/build_jdk.scala
wenzelm@64160
    17
  Admin/build_log.scala
wenzelm@64483
    18
  Admin/build_polyml.scala
wenzelm@64202
    19
  Admin/build_release.scala
wenzelm@64161
    20
  Admin/build_stats.scala
wenzelm@64161
    21
  Admin/check_sources.scala
wenzelm@64160
    22
  Admin/ci_api.scala
wenzelm@64160
    23
  Admin/ci_profile.scala
wenzelm@64148
    24
  Admin/isabelle_cronjob.scala
wenzelm@64369
    25
  Admin/news.scala
wenzelm@64188
    26
  Admin/other_isabelle.scala
wenzelm@64161
    27
  Admin/remote_dmg.scala
wenzelm@56695
    28
  Concurrent/consumer_thread.scala
wenzelm@43660
    29
  Concurrent/counter.scala
wenzelm@56768
    30
  Concurrent/event_timer.scala
wenzelm@43320
    31
  Concurrent/future.scala
wenzelm@56693
    32
  Concurrent/mailbox.scala
wenzelm@59136
    33
  Concurrent/par_list.scala
wenzelm@61556
    34
  Concurrent/standard_thread.scala
wenzelm@56685
    35
  Concurrent/synchronized.scala
wenzelm@57647
    36
  GUI/color_value.scala
wenzelm@57647
    37
  GUI/gui.scala
wenzelm@57647
    38
  GUI/gui_thread.scala
wenzelm@57647
    39
  GUI/html5_panel.scala
wenzelm@57908
    40
  GUI/jfx_gui.scala
wenzelm@57647
    41
  GUI/popup.scala
wenzelm@57647
    42
  GUI/wrap_panel.scala
wenzelm@55511
    43
  General/antiquote.scala
wenzelm@54439
    44
  General/bytes.scala
wenzelm@64610
    45
  General/codepoint.scala
wenzelm@55673
    46
  General/completion.scala
wenzelm@64056
    47
  General/date.scala
wenzelm@62508
    48
  General/exn.scala
wenzelm@48411
    49
  General/file.scala
wenzelm@64699
    50
  General/file_watcher.scala
wenzelm@46611
    51
  General/graph.scala
wenzelm@59244
    52
  General/graph_display.scala
wenzelm@51098
    53
  General/graphics_file.scala
wenzelm@65077
    54
  General/http.scala
wenzelm@63644
    55
  General/json.scala
wenzelm@43320
    56
  General/linear_set.scala
wenzelm@64606
    57
  General/logger.scala
wenzelm@56800
    58
  General/long_name.scala
wenzelm@63997
    59
  General/mercurial.scala
wenzelm@52975
    60
  General/multi_map.scala
wenzelm@56782
    61
  General/output.scala
wenzelm@43600
    62
  General/path.scala
wenzelm@43320
    63
  General/position.scala
wenzelm@43320
    64
  General/pretty.scala
wenzelm@43780
    65
  General/properties.scala
wenzelm@43320
    66
  General/scan.scala
wenzelm@43320
    67
  General/sha1.scala
wenzelm@63788
    68
  General/sql.scala
wenzelm@64123
    69
  General/ssh.scala
wenzelm@43320
    70
  General/symbol.scala
wenzelm@45674
    71
  General/time.scala
wenzelm@45666
    72
  General/timing.scala
wenzelm@57647
    73
  General/untyped.scala
wenzelm@56501
    74
  General/url.scala
wenzelm@64639
    75
  General/utf8.scala
wenzelm@63805
    76
  General/value.scala
wenzelm@56599
    77
  General/word.scala
wenzelm@64000
    78
  General/xz.scala
wenzelm@63604
    79
  Isar/document_structure.scala
wenzelm@43320
    80
  Isar/keyword.scala
wenzelm@63603
    81
  Isar/line_structure.scala
wenzelm@43320
    82
  Isar/outer_syntax.scala
wenzelm@43320
    83
  Isar/parse.scala
wenzelm@43320
    84
  Isar/token.scala
wenzelm@55497
    85
  ML/ml_lex.scala
wenzelm@62528
    86
  ML/ml_syntax.scala
wenzelm@59362
    87
  PIDE/batch_session.scala
wenzelm@43320
    88
  PIDE/command.scala
wenzelm@57905
    89
  PIDE/command_span.scala
wenzelm@43320
    90
  PIDE/document.scala
wenzelm@52530
    91
  PIDE/document_id.scala
wenzelm@52971
    92
  PIDE/editor.scala
wenzelm@64611
    93
  PIDE/line.scala
wenzelm@45670
    94
  PIDE/markup.scala
wenzelm@43320
    95
  PIDE/markup_tree.scala
wenzelm@45709
    96
  PIDE/protocol.scala
wenzelm@59713
    97
  PIDE/protocol_message.scala
wenzelm@56385
    98
  PIDE/prover.scala
wenzelm@52981
    99
  PIDE/query_operation.scala
wenzelm@64622
   100
  PIDE/rendering.scala
wenzelm@56208
   101
  PIDE/resources.scala
wenzelm@56210
   102
  PIDE/session.scala
wenzelm@43320
   103
  PIDE/text.scala
wenzelm@44698
   104
  PIDE/xml.scala
wenzelm@44698
   105
  PIDE/yxml.scala
wenzelm@57647
   106
  ROOT.scala
wenzelm@62584
   107
  System/bash.scala
wenzelm@61925
   108
  System/command_line.scala
wenzelm@61282
   109
  System/cygwin.scala
wenzelm@62845
   110
  System/distribution.scala
wenzelm@62431
   111
  System/getopts.scala
wenzelm@43744
   112
  System/invoke_scala.scala
wenzelm@43517
   113
  System/isabelle_charset.scala
wenzelm@43320
   114
  System/isabelle_process.scala
wenzelm@43320
   115
  System/isabelle_system.scala
wenzelm@62829
   116
  System/isabelle_tool.scala
wenzelm@64264
   117
  System/numa.scala
wenzelm@48365
   118
  System/options.scala
wenzelm@43320
   119
  System/platform.scala
wenzelm@56860
   120
  System/posix_interrupt.scala
wenzelm@62400
   121
  System/process_result.scala
wenzelm@61276
   122
  System/progress.scala
wenzelm@45027
   123
  System/system_channel.scala
wenzelm@43320
   124
  Thy/html.scala
wenzelm@50707
   125
  Thy/present.scala
wenzelm@62631
   126
  Thy/sessions.scala
wenzelm@43320
   127
  Thy/thy_header.scala
wenzelm@43651
   128
  Thy/thy_info.scala
wenzelm@43320
   129
  Thy/thy_syntax.scala
wenzelm@58523
   130
  Tools/bibtex.scala
wenzelm@57647
   131
  Tools/build.scala
wenzelm@59891
   132
  Tools/check_keywords.scala
wenzelm@60749
   133
  Tools/debugger.scala
wenzelm@52444
   134
  Tools/doc.scala
wenzelm@50687
   135
  Tools/main.scala
wenzelm@62559
   136
  Tools/ml_console.scala
wenzelm@62586
   137
  Tools/ml_process.scala
wenzelm@50981
   138
  Tools/ml_statistics.scala
wenzelm@56864
   139
  Tools/print_operation.scala
wenzelm@64342
   140
  Tools/profiling_report.scala
wenzelm@54730
   141
  Tools/simplifier_trace.scala
wenzelm@65139
   142
  Tools/spell_checker.scala
wenzelm@50980
   143
  Tools/task_statistics.scala
wenzelm@58610
   144
  Tools/update_cartouches.scala
wenzelm@58872
   145
  Tools/update_header.scala
wenzelm@61216
   146
  Tools/update_then.scala
wenzelm@61337
   147
  Tools/update_theorems.scala
wenzelm@43320
   148
  library.scala
wenzelm@43730
   149
  term.scala
wenzelm@43779
   150
  term_xml.scala
wenzelm@64609
   151
  ../Tools/Graphview/graph_file.scala
wenzelm@64609
   152
  ../Tools/Graphview/graph_panel.scala
wenzelm@64609
   153
  ../Tools/Graphview/graphview.scala
wenzelm@64609
   154
  ../Tools/Graphview/layout.scala
wenzelm@64609
   155
  ../Tools/Graphview/main_panel.scala
wenzelm@64609
   156
  ../Tools/Graphview/metrics.scala
wenzelm@64609
   157
  ../Tools/Graphview/model.scala
wenzelm@64609
   158
  ../Tools/Graphview/mutator.scala
wenzelm@64609
   159
  ../Tools/Graphview/mutator_dialog.scala
wenzelm@64609
   160
  ../Tools/Graphview/mutator_event.scala
wenzelm@64609
   161
  ../Tools/Graphview/popups.scala
wenzelm@64609
   162
  ../Tools/Graphview/shapes.scala
wenzelm@64609
   163
  ../Tools/Graphview/tree_panel.scala
wenzelm@65138
   164
  ../Tools/VSCode/src/build_vscode.scala
wenzelm@64609
   165
  ../Tools/VSCode/src/channel.scala
wenzelm@64609
   166
  ../Tools/VSCode/src/document_model.scala
wenzelm@64738
   167
  ../Tools/VSCode/src/grammar.scala
wenzelm@64609
   168
  ../Tools/VSCode/src/protocol.scala
wenzelm@64609
   169
  ../Tools/VSCode/src/server.scala
wenzelm@64622
   170
  ../Tools/VSCode/src/vscode_rendering.scala
wenzelm@64623
   171
  ../Tools/VSCode/src/vscode_resources.scala
wenzelm@43320
   172
)
wenzelm@43320
   173
wenzelm@34282
   174
wenzelm@34282
   175
## diagnostics
wenzelm@34282
   176
wenzelm@43280
   177
PRG="$(basename "$0")"
wenzelm@43280
   178
wenzelm@43280
   179
function usage()
wenzelm@43280
   180
{
wenzelm@43280
   181
  echo
wenzelm@43280
   182
  echo "Usage: isabelle $PRG [OPTIONS]"
wenzelm@43280
   183
  echo
wenzelm@43280
   184
  echo "  Options are:"
wenzelm@43280
   185
  echo "    -f           fresh build"
wenzelm@43280
   186
  echo
wenzelm@43280
   187
  exit 1
wenzelm@43280
   188
}
wenzelm@43280
   189
wenzelm@34282
   190
function fail()
wenzelm@34282
   191
{
wenzelm@34282
   192
  echo "$1" >&2
wenzelm@34282
   193
  exit 2
wenzelm@34282
   194
}
wenzelm@34282
   195
wenzelm@42899
   196
[ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
wenzelm@34282
   197
wenzelm@34282
   198
wenzelm@43280
   199
## process command line
wenzelm@43280
   200
wenzelm@43280
   201
# options
wenzelm@43280
   202
wenzelm@43280
   203
FRESH=""
wenzelm@43280
   204
wenzelm@64370
   205
while getopts "f" OPT
wenzelm@43280
   206
do
wenzelm@43280
   207
  case "$OPT" in
wenzelm@43280
   208
    f)
wenzelm@43280
   209
      FRESH=true
wenzelm@43280
   210
      ;;
wenzelm@43280
   211
    \?)
wenzelm@43280
   212
      usage
wenzelm@43280
   213
      ;;
wenzelm@43280
   214
  esac
wenzelm@43280
   215
done
wenzelm@43280
   216
wenzelm@43280
   217
shift $(($OPTIND - 1))
wenzelm@43280
   218
wenzelm@43280
   219
wenzelm@43280
   220
# args
wenzelm@43280
   221
wenzelm@43280
   222
[ "$#" -ne 0 ] && usage
wenzelm@43280
   223
wenzelm@43280
   224
wenzelm@49558
   225
## build
wenzelm@34282
   226
wenzelm@34284
   227
TARGET_DIR="$ISABELLE_HOME/lib/classes"
wenzelm@53577
   228
TARGET="$TARGET_DIR/Pure.jar"
wenzelm@34282
   229
wenzelm@43405
   230
declare -a UPDATED=()
wenzelm@43405
   231
wenzelm@43280
   232
if [ -n "$FRESH" ]; then
wenzelm@43280
   233
  OUTDATED=true
wenzelm@43280
   234
else
wenzelm@43280
   235
  OUTDATED=false
wenzelm@43523
   236
  if [ ! -e "$TARGET" ]; then
wenzelm@43523
   237
    OUTDATED=true
wenzelm@43523
   238
  else
wenzelm@43405
   239
    for DEP in "${SOURCES[@]}"
wenzelm@43280
   240
    do
wenzelm@43405
   241
      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
wenzelm@43523
   242
      [ "$DEP" -nt "$TARGET" ] && {
wenzelm@43523
   243
        OUTDATED=true
wenzelm@43523
   244
        UPDATED["${#UPDATED[@]}"]="$DEP"
wenzelm@43523
   245
      }
wenzelm@43280
   246
    done
wenzelm@43405
   247
  fi
wenzelm@43280
   248
fi
wenzelm@34282
   249
wenzelm@34284
   250
if [ "$OUTDATED" = true ]
wenzelm@34284
   251
then
wenzelm@49173
   252
  echo "### Building Isabelle/Scala ..."
wenzelm@34282
   253
wenzelm@43405
   254
  [ "${#UPDATED[@]}" -gt 0 ] && {
wenzelm@43405
   255
    echo "Changed files:"
wenzelm@43405
   256
    for FILE in "${UPDATED[@]}"
wenzelm@43405
   257
    do
wenzelm@43405
   258
      echo "  $FILE"
wenzelm@43405
   259
    done
wenzelm@43405
   260
  }
wenzelm@43405
   261
wenzelm@64375
   262
  rm -f "$TARGET"
wenzelm@34282
   263
  rm -rf classes && mkdir classes
wenzelm@45673
   264
wenzelm@64900
   265
  SCALAC_OPTIONS="$ISABELLE_SCALAC_OPTIONS -d classes"
wenzelm@45673
   266
wenzelm@50689
   267
  (
wenzelm@58791
   268
    classpath "$JAVA_HOME/lib/jfxrt.jar"
wenzelm@53576
   269
    classpath classes
wenzelm@61294
   270
    export CLASSPATH="$(platform_path "$ISABELLE_CLASSPATH")"
wenzelm@50689
   271
wenzelm@64370
   272
    isabelle_scala scalac $SCALAC_OPTIONS "${SOURCES[@]}" || \
wenzelm@64370
   273
      fail "Failed to compile sources"
wenzelm@51508
   274
  ) || exit "$?"
wenzelm@45673
   275
wenzelm@53577
   276
  mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
wenzelm@43280
   277
wenzelm@43285
   278
  pushd classes >/dev/null
wenzelm@43280
   279
wenzelm@43517
   280
  CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
wenzelm@43517
   281
  mkdir -p "$(dirname "$CHARSET_SERVICE")"
wenzelm@43517
   282
  echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
wenzelm@43517
   283
wenzelm@54676
   284
  cp "$ISABELLE_HOME/lib/logo/isabelle_transparent-32.gif" isabelle/.
wenzelm@54709
   285
  cp "$ISABELLE_HOME/lib/logo/isabelle_transparent.gif" isabelle/.
wenzelm@53452
   286
wenzelm@61294
   287
  isabelle_jdk jar cfe "$(platform_path "$TARGET")" isabelle.Main META-INF isabelle || \
wenzelm@43523
   288
    fail "Failed to produce $TARGET"
wenzelm@34282
   289
wenzelm@43280
   290
  popd >/dev/null
wenzelm@43280
   291
wenzelm@34282
   292
  rm -rf classes
wenzelm@34282
   293
fi