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