src/Pure/build-jars
author wenzelm
Fri Jul 17 21:40:47 2015 +0200 (2015-07-17)
changeset 60749 f727b99faaf7
parent 59891 9ce697050455
child 60991 2fc5a44346b5
permissions -rwxr-xr-x
skeleton for interactive debugger;
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@43320
    18
  Concurrent/simple_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/system_dialog.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@43320
    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@59362
    58
  PIDE/batch_session.scala
wenzelm@43320
    59
  PIDE/command.scala
wenzelm@57905
    60
  PIDE/command_span.scala
wenzelm@43320
    61
  PIDE/document.scala
wenzelm@52530
    62
  PIDE/document_id.scala
wenzelm@52971
    63
  PIDE/editor.scala
wenzelm@45670
    64
  PIDE/markup.scala
wenzelm@43320
    65
  PIDE/markup_tree.scala
wenzelm@45709
    66
  PIDE/protocol.scala
wenzelm@59713
    67
  PIDE/protocol_message.scala
wenzelm@56385
    68
  PIDE/prover.scala
wenzelm@52981
    69
  PIDE/query_operation.scala
wenzelm@56208
    70
  PIDE/resources.scala
wenzelm@56210
    71
  PIDE/session.scala
wenzelm@43320
    72
  PIDE/text.scala
wenzelm@44698
    73
  PIDE/xml.scala
wenzelm@44698
    74
  PIDE/yxml.scala
wenzelm@57647
    75
  ROOT.scala
wenzelm@48346
    76
  System/command_line.scala
wenzelm@43744
    77
  System/invoke_scala.scala
wenzelm@43517
    78
  System/isabelle_charset.scala
wenzelm@43320
    79
  System/isabelle_process.scala
wenzelm@43320
    80
  System/isabelle_system.scala
wenzelm@48365
    81
  System/options.scala
wenzelm@43320
    82
  System/platform.scala
wenzelm@56860
    83
  System/posix_interrupt.scala
wenzelm@45027
    84
  System/system_channel.scala
wenzelm@50203
    85
  System/utf8.scala
wenzelm@43320
    86
  Thy/html.scala
wenzelm@50707
    87
  Thy/present.scala
wenzelm@43320
    88
  Thy/thy_header.scala
wenzelm@43651
    89
  Thy/thy_info.scala
wenzelm@43320
    90
  Thy/thy_syntax.scala
wenzelm@58523
    91
  Tools/bibtex.scala
wenzelm@57647
    92
  Tools/build.scala
wenzelm@57647
    93
  Tools/build_console.scala
wenzelm@57647
    94
  Tools/build_doc.scala
wenzelm@59891
    95
  Tools/check_keywords.scala
wenzelm@56791
    96
  Tools/check_source.scala
wenzelm@60749
    97
  Tools/debugger.scala
wenzelm@52444
    98
  Tools/doc.scala
wenzelm@50687
    99
  Tools/main.scala
wenzelm@50981
   100
  Tools/ml_statistics.scala
wenzelm@56864
   101
  Tools/print_operation.scala
wenzelm@54730
   102
  Tools/simplifier_trace.scala
wenzelm@50980
   103
  Tools/task_statistics.scala
wenzelm@58610
   104
  Tools/update_cartouches.scala
wenzelm@58872
   105
  Tools/update_header.scala
wenzelm@58861
   106
  Tools/update_semicolons.scala
wenzelm@43320
   107
  library.scala
wenzelm@43730
   108
  term.scala
wenzelm@43779
   109
  term_xml.scala
wenzelm@59441
   110
  "../Tools/Graphview/graph_file.scala"
wenzelm@59202
   111
  "../Tools/Graphview/graph_panel.scala"
wenzelm@59459
   112
  "../Tools/Graphview/graphview.scala"
wenzelm@59232
   113
  "../Tools/Graphview/layout.scala"
wenzelm@59202
   114
  "../Tools/Graphview/main_panel.scala"
wenzelm@59290
   115
  "../Tools/Graphview/metrics.scala"
wenzelm@59202
   116
  "../Tools/Graphview/model.scala"
wenzelm@59392
   117
  "../Tools/Graphview/mutator.scala"
wenzelm@59202
   118
  "../Tools/Graphview/mutator_dialog.scala"
wenzelm@59202
   119
  "../Tools/Graphview/mutator_event.scala"
wenzelm@59202
   120
  "../Tools/Graphview/popups.scala"
wenzelm@59202
   121
  "../Tools/Graphview/shapes.scala"
wenzelm@59392
   122
  "../Tools/Graphview/tree_panel.scala"
wenzelm@43320
   123
)
wenzelm@43320
   124
wenzelm@34282
   125
wenzelm@34282
   126
## diagnostics
wenzelm@34282
   127
wenzelm@43280
   128
PRG="$(basename "$0")"
wenzelm@43280
   129
wenzelm@43280
   130
function usage()
wenzelm@43280
   131
{
wenzelm@43280
   132
  echo
wenzelm@43280
   133
  echo "Usage: isabelle $PRG [OPTIONS]"
wenzelm@43280
   134
  echo
wenzelm@43280
   135
  echo "  Options are:"
wenzelm@43280
   136
  echo "    -f           fresh build"
wenzelm@47408
   137
  echo "    -t           test separate compilation of PIDE"
wenzelm@43280
   138
  echo
wenzelm@43280
   139
  exit 1
wenzelm@43280
   140
}
wenzelm@43280
   141
wenzelm@34282
   142
function fail()
wenzelm@34282
   143
{
wenzelm@34282
   144
  echo "$1" >&2
wenzelm@34282
   145
  exit 2
wenzelm@34282
   146
}
wenzelm@34282
   147
wenzelm@42899
   148
[ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
wenzelm@34282
   149
wenzelm@34282
   150
wenzelm@43280
   151
## process command line
wenzelm@43280
   152
wenzelm@43280
   153
# options
wenzelm@43280
   154
wenzelm@43280
   155
FRESH=""
wenzelm@47408
   156
TEST_PIDE=""
wenzelm@43280
   157
wenzelm@47408
   158
while getopts "ft" OPT
wenzelm@43280
   159
do
wenzelm@43280
   160
  case "$OPT" in
wenzelm@43280
   161
    f)
wenzelm@43280
   162
      FRESH=true
wenzelm@43280
   163
      ;;
wenzelm@47408
   164
    t)
wenzelm@47408
   165
      TEST_PIDE=true
wenzelm@47408
   166
      ;;
wenzelm@43280
   167
    \?)
wenzelm@43280
   168
      usage
wenzelm@43280
   169
      ;;
wenzelm@43280
   170
  esac
wenzelm@43280
   171
done
wenzelm@43280
   172
wenzelm@43280
   173
shift $(($OPTIND - 1))
wenzelm@43280
   174
wenzelm@43280
   175
wenzelm@43280
   176
# args
wenzelm@43280
   177
wenzelm@43280
   178
[ "$#" -ne 0 ] && usage
wenzelm@43280
   179
wenzelm@43280
   180
wenzelm@49558
   181
## build
wenzelm@34282
   182
wenzelm@34284
   183
TARGET_DIR="$ISABELLE_HOME/lib/classes"
wenzelm@53577
   184
TARGET="$TARGET_DIR/Pure.jar"
wenzelm@34282
   185
wenzelm@45673
   186
declare -a PIDE_SOURCES=()
wenzelm@45673
   187
declare -a PURE_SOURCES=()
wenzelm@45673
   188
wenzelm@45673
   189
for DEP in "${SOURCES[@]}"
wenzelm@45673
   190
do
wenzelm@45673
   191
  if grep "Module:.*PIDE" "$DEP" >/dev/null
wenzelm@45673
   192
  then
wenzelm@45673
   193
    PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   194
  else
wenzelm@45673
   195
    PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   196
  fi
wenzelm@45673
   197
done
wenzelm@45673
   198
wenzelm@43405
   199
declare -a UPDATED=()
wenzelm@43405
   200
wenzelm@43280
   201
if [ -n "$FRESH" ]; then
wenzelm@43280
   202
  OUTDATED=true
wenzelm@43280
   203
else
wenzelm@43280
   204
  OUTDATED=false
wenzelm@43523
   205
  if [ ! -e "$TARGET" ]; then
wenzelm@43523
   206
    OUTDATED=true
wenzelm@43523
   207
  else
wenzelm@43405
   208
    for DEP in "${SOURCES[@]}"
wenzelm@43280
   209
    do
wenzelm@43405
   210
      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
wenzelm@43523
   211
      [ "$DEP" -nt "$TARGET" ] && {
wenzelm@43523
   212
        OUTDATED=true
wenzelm@43523
   213
        UPDATED["${#UPDATED[@]}"]="$DEP"
wenzelm@43523
   214
      }
wenzelm@43280
   215
    done
wenzelm@43405
   216
  fi
wenzelm@43280
   217
fi
wenzelm@34282
   218
wenzelm@34284
   219
if [ "$OUTDATED" = true ]
wenzelm@34284
   220
then
wenzelm@49173
   221
  echo "### Building Isabelle/Scala ..."
wenzelm@34282
   222
wenzelm@43405
   223
  [ "${#UPDATED[@]}" -gt 0 ] && {
wenzelm@43405
   224
    echo "Changed files:"
wenzelm@43405
   225
    for FILE in "${UPDATED[@]}"
wenzelm@43405
   226
    do
wenzelm@43405
   227
      echo "  $FILE"
wenzelm@43405
   228
    done
wenzelm@43405
   229
  }
wenzelm@43405
   230
wenzelm@34282
   231
  rm -rf classes && mkdir classes
wenzelm@45673
   232
wenzelm@47009
   233
  SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
wenzelm@45673
   234
wenzelm@50689
   235
  (
wenzelm@58791
   236
    classpath "$JAVA_HOME/lib/jfxrt.jar"
wenzelm@53576
   237
    classpath classes
wenzelm@53576
   238
    export CLASSPATH="$(jvmpath "$ISABELLE_CLASSPATH")"
wenzelm@50689
   239
wenzelm@50689
   240
    if [ "$TEST_PIDE" = true ]; then
wenzelm@50689
   241
      isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
wenzelm@50689
   242
        fail "Failed to compile PIDE sources"
wenzelm@50689
   243
      isabelle_scala scalac $SCALAC_OPTIONS "${PURE_SOURCES[@]}" || \
wenzelm@50689
   244
        fail "Failed to compile Pure sources"
wenzelm@50689
   245
    else
wenzelm@50689
   246
      isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
wenzelm@50689
   247
        fail "Failed to compile sources"
wenzelm@50689
   248
    fi
wenzelm@51508
   249
  ) || exit "$?"
wenzelm@45673
   250
wenzelm@53577
   251
  mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
wenzelm@43280
   252
wenzelm@43285
   253
  pushd classes >/dev/null
wenzelm@43280
   254
wenzelm@43517
   255
  CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
wenzelm@43517
   256
  mkdir -p "$(dirname "$CHARSET_SERVICE")"
wenzelm@43517
   257
  echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
wenzelm@43517
   258
wenzelm@54676
   259
  cp "$ISABELLE_HOME/lib/logo/isabelle_transparent-32.gif" isabelle/.
wenzelm@54709
   260
  cp "$ISABELLE_HOME/lib/logo/isabelle_transparent.gif" isabelle/.
wenzelm@53452
   261
wenzelm@53841
   262
  isabelle_jdk jar cfe "$(jvmpath "$TARGET")" isabelle.Main META-INF isabelle || \
wenzelm@43523
   263
    fail "Failed to produce $TARGET"
wenzelm@34282
   264
wenzelm@43280
   265
  popd >/dev/null
wenzelm@43280
   266
wenzelm@34282
   267
  rm -rf classes
wenzelm@34282
   268
fi