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