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