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