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