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