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