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