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