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