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