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